Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tyler/won added CardGrid support for 2 and 3 column grids #90

Merged
merged 9 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ model Session {
}

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
id String @id @default(auto()) @map("_id") @db.ObjectId

// https://github.com/nextauthjs/next-auth/blob/v4/packages/next-auth/src/providers/google.ts
// Fields mappable from PrismaAdapter. We can map the value return from profle() in [...nextauth].
Expand Down Expand Up @@ -86,7 +86,7 @@ enum Role {

model Senior {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
name String @default("")
location String
description String
StudentIDs String[] @db.ObjectId
Expand All @@ -98,13 +98,13 @@ model Senior {
}

model File {
id String @id @default(auto()) @map("_id") @db.ObjectId
date DateTime // will zero out the hours
filetype String
url String
seniorId String @db.ObjectId
senior Senior @relation(fields: [seniorId], references: [id], onDelete: Cascade)
Tags String[]
id String @id @default(auto()) @map("_id") @db.ObjectId
date DateTime // will zero out the hours
filetype String
url String
seniorId String @db.ObjectId
senior Senior @relation(fields: [seniorId], references: [id], onDelete: Cascade)
Tags String[]

@@unique([seniorId, date])
}
Expand Down Expand Up @@ -134,20 +134,20 @@ model Chapter {
}

model Resource {
id String @id @default(auto()) @map("_id") @db.ObjectId
access Role[]
link String
title String
id String @id @default(auto()) @map("_id") @db.ObjectId
access Role[]
link String
title String
}

model Email {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
}

model UserRequest {
id String @id @default(auto()) @map("_id") @db.ObjectId
approved Approval @default(PENDING)
uid String @db.ObjectId @unique
chapterId String @db.ObjectId
}
id String @id @default(auto()) @map("_id") @db.ObjectId
approved Approval @default(PENDING)
uid String @unique @db.ObjectId
chapterId String @db.ObjectId
}
8 changes: 6 additions & 2 deletions src/app/api/chapter-request/route.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ export const ChapterRequest = z.object({
phoneNumber: z.string().length(10, "Phone number must be 10 digits"),
university: z.string().min(1, "Please provide a university"),
universityAddress: z.string().min(1, "Please provide an address"),
leadershipExperience: z.string().min(1, "Please state some leadership experience"),
motivation: z.string().min(1, "Please describe your motivation in joining the legacy project"),
leadershipExperience: z
.string()
.min(1, "Please state some leadership experience"),
motivation: z
.string()
.min(1, "Please describe your motivation in joining the legacy project"),
// TODO: Figure out if availabilities should have a better type
availabilities: z.string().min(1, "Please provide some times"),
questions: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/chapter-request/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ export const POST = async (request: NextRequest) => {
}),
{ status: 500 }
);
}
}
};
172 changes: 86 additions & 86 deletions src/app/api/resources/route.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
import { NextResponse } from "next/server";
import {
batchCreateRequestSchema,
batchDeleteRequestSchema,
batchResponseSchema,
batchUpdateRequestSchema,
} from "./route.schema";
import { prisma } from "@server/db/client";
import { invalidFormReponse } from "../route.schema";
import { withSessionAndRole } from "@server/decorator";
export const POST = withSessionAndRole(["ADMIN"], async (request) => {
const resourceRequest = batchCreateRequestSchema.safeParse(
await request.req.json()
);
if (!resourceRequest.success) {
return NextResponse.json(invalidFormReponse, { status: 400 });
} else {
const body = resourceRequest.data;
const resources = await prisma.$transaction(
body.map((resource) =>
prisma.resource.create({
data: {
access: resource.access,
title: resource.title,
link: resource.link,
},
})
)
);
return NextResponse.json(
batchResponseSchema.parse({ code: "SUCCESS", data: resources })
);
}
});
export const PUT = withSessionAndRole(["ADMIN"], async (request) => {
const resourceRequest = batchUpdateRequestSchema.safeParse(
await request.req.json()
);
if (!resourceRequest.success) {
return NextResponse.json(invalidFormReponse, { status: 400 });
} else {
await prisma.$transaction(
resourceRequest.data.map((resource) =>
prisma.resource.update({
where: {
id: resource.id,
},
data: {
access: resource.access,
title: resource.title,
link: resource.link,
},
})
)
);
return NextResponse.json(
batchResponseSchema.parse({ code: "SUCCESS", data: resourceRequest.data })
);
}
});
export const DELETE = withSessionAndRole(["ADMIN"], async (request) => {
const resourceRequest = batchDeleteRequestSchema.safeParse(
await request.req.json()
);
if (!resourceRequest.success) {
return NextResponse.json(invalidFormReponse, { status: 400 });
} else {
const body = resourceRequest.data;
const resources = await prisma.$transaction(
body.map((id) =>
prisma.resource.delete({
where: {
id: id,
},
})
)
);
return NextResponse.json(
batchResponseSchema.parse({ code: "SUCCESS", data: resources })
);
}
});
import { NextResponse } from "next/server";
import {
batchCreateRequestSchema,
batchDeleteRequestSchema,
batchResponseSchema,
batchUpdateRequestSchema,
} from "./route.schema";
import { prisma } from "@server/db/client";
import { invalidFormReponse } from "../route.schema";
import { withSessionAndRole } from "@server/decorator";

export const POST = withSessionAndRole(["ADMIN"], async (request) => {
const resourceRequest = batchCreateRequestSchema.safeParse(
await request.req.json()
);
if (!resourceRequest.success) {
return NextResponse.json(invalidFormReponse, { status: 400 });
} else {
const body = resourceRequest.data;
const resources = await prisma.$transaction(
body.map((resource) =>
prisma.resource.create({
data: {
access: resource.access,
title: resource.title,
link: resource.link,
},
})
)
);
return NextResponse.json(
batchResponseSchema.parse({ code: "SUCCESS", data: resources })
);
}
});

export const PUT = withSessionAndRole(["ADMIN"], async (request) => {
const resourceRequest = batchUpdateRequestSchema.safeParse(
await request.req.json()
);
if (!resourceRequest.success) {
return NextResponse.json(invalidFormReponse, { status: 400 });
} else {
await prisma.$transaction(
resourceRequest.data.map((resource) =>
prisma.resource.update({
where: {
id: resource.id,
},
data: {
access: resource.access,
title: resource.title,
link: resource.link,
},
})
)
);

return NextResponse.json(
batchResponseSchema.parse({ code: "SUCCESS", data: resourceRequest.data })
);
}
});

export const DELETE = withSessionAndRole(["ADMIN"], async (request) => {
const resourceRequest = batchDeleteRequestSchema.safeParse(
await request.req.json()
);
if (!resourceRequest.success) {
return NextResponse.json(invalidFormReponse, { status: 400 });
} else {
const body = resourceRequest.data;
const resources = await prisma.$transaction(
body.map((id) =>
prisma.resource.delete({
where: {
id: id,
},
})
)
);
return NextResponse.json(
batchResponseSchema.parse({ code: "SUCCESS", data: resources })
);
}
});
1 change: 0 additions & 1 deletion src/app/api/toy-example/route.client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { z } from "zod";
import { SignInRequest, SignInResponse } from "./route.schema";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/user/[uid]/edit-profile/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const PATCH = withSession(async ({ session, req, params }) => {
return NextResponse.json(
EditProfileResponse.parse({
code: "UNAUTHORIZED",
message: "The action cannot be performed by the current user"
message: "The action cannot be performed by the current user",
}),
{ status: 400 }
);
Expand Down
1 change: 0 additions & 1 deletion src/app/private/[uid]/admin/home/chapters/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const AdminChaptersPage = async () => {
},
});


return <AdminHomePage chapters={chapters} />;
};

Expand Down
1 change: 0 additions & 1 deletion src/app/private/[uid]/admin/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const AdminHomePageWrapper = async () => {
},
});


return <AdminHomePage chapters={chapters} />;
};

Expand Down
1 change: 0 additions & 1 deletion src/app/private/[uid]/admin/home/resources/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import DisplayResources from "@components/DisplayResources";
import { prisma } from "@server/db/client";


const AdminResourcesPage = async () => {
const resources = await prisma.resource.findMany();

Expand Down
20 changes: 20 additions & 0 deletions src/app/private/[uid]/chapter-leader/edit-profile/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { HeaderContainer } from "@components/container/index";
import { faUser } from "@fortawesome/free-regular-svg-icons";

interface IEditProfileLayout {
children: React.ReactNode;
}

const EditProfileLayout = ({ children }: IEditProfileLayout) => {
return (
<HeaderContainer
header="Profile"
headerIcon={faUser}
showHorizontalLine={true}
>
{children}
</HeaderContainer>
);
};

export default EditProfileLayout;
3 changes: 3 additions & 0 deletions src/app/private/[uid]/chapter-leader/edit-profile/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { EditProfileForm } from "@components/user";

export default EditProfileForm;
27 changes: 27 additions & 0 deletions src/app/private/[uid]/chapter-leader/home/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import TabButtons from "@components/TabButtons";
import { HeaderContainer } from "@components/container/index";
import { faHouse } from "@fortawesome/free-solid-svg-icons";

interface LayoutProps {
children: React.ReactNode;
}

const Layout = async ({ children }: LayoutProps) => {
return (
<HeaderContainer
header="Home"
headerIcon={faHouse}
showHorizontalLine={false}
>
<TabButtons
queries={[
{ segment: "home", name: "My Chapter" },
{ segment: "home/resources", name: "resources" },
]}
/>
{children}
</HeaderContainer>
);
};

export default Layout;
Loading
Loading