From e1fe7cc09d909d2409d0a07c74b928592e47875b Mon Sep 17 00:00:00 2001 From: jspark2000 Date: Thu, 7 Mar 2024 08:00:26 +0000 Subject: [PATCH] chore: save commit --- backend/app/src/main.ts | 20 ++++----- .../migration.sql | 2 - .../migration.sql | 5 +++ backend/prisma/schema.prisma | 29 ++++++------ frontend/src/app/console/account/page.tsx | 2 +- frontend/src/app/console/roster/page.tsx | 10 +++++ frontend/src/components/ConsoleSidebar.tsx | 45 +++++++++---------- 7 files changed, 64 insertions(+), 49 deletions(-) delete mode 100644 backend/prisma/migrations/20240301143414_add_profile_img_url_column_on_user_table/migration.sql rename backend/prisma/migrations/{20240221132022_init => 20240307075942_init}/migration.sql (96%) create mode 100644 frontend/src/app/console/roster/page.tsx diff --git a/backend/app/src/main.ts b/backend/app/src/main.ts index d600908..f65ee7b 100644 --- a/backend/app/src/main.ts +++ b/backend/app/src/main.ts @@ -8,16 +8,16 @@ const bootstrap = async () => { app.useGlobalPipes(new ValidationPipe()) app.use(cookieParser()) app.setGlobalPrefix('api') - app.enableCors({ - origin: - process.env.NODE_ENV === 'production' - ? process.env.VERCEL_HOSTNAME - : 'http://localhost:5173', - credentials: true, - methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS', - allowedHeaders: ['*'], - exposedHeaders: ['Content-Type', 'Authorization'] - }) + + if (process.env.NODE_ENV !== 'production') { + app.enableCors({ + origin: 'http://localhost:5173', + credentials: true, + methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS', + allowedHeaders: ['*'], + exposedHeaders: ['Content-Type', 'Authorization'] + }) + } await app.listen(4000) } diff --git a/backend/prisma/migrations/20240301143414_add_profile_img_url_column_on_user_table/migration.sql b/backend/prisma/migrations/20240301143414_add_profile_img_url_column_on_user_table/migration.sql deleted file mode 100644 index 915a928..0000000 --- a/backend/prisma/migrations/20240301143414_add_profile_img_url_column_on_user_table/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "user" ADD COLUMN "profile_image_url" TEXT; diff --git a/backend/prisma/migrations/20240221132022_init/migration.sql b/backend/prisma/migrations/20240307075942_init/migration.sql similarity index 96% rename from backend/prisma/migrations/20240221132022_init/migration.sql rename to backend/prisma/migrations/20240307075942_init/migration.sql index c7c4e62..090638e 100644 --- a/backend/prisma/migrations/20240221132022_init/migration.sql +++ b/backend/prisma/migrations/20240307075942_init/migration.sql @@ -35,6 +35,7 @@ CREATE TABLE "user" ( "last_password_changed" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "last_login" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "status" "AccountStatus" NOT NULL DEFAULT 'Verifying', + "profile_image_url" TEXT, CONSTRAINT "user_pkey" PRIMARY KEY ("id") ); @@ -76,6 +77,7 @@ CREATE TABLE "attendance" ( -- CreateTable CREATE TABLE "schedule" ( "id" SERIAL NOT NULL, + "survey_group_id" INTEGER NOT NULL, "name" VARCHAR(64) NOT NULL, "date" TIMESTAMP(3) NOT NULL, "type" "ScheduleType" NOT NULL DEFAULT 'Exercise', @@ -175,6 +177,9 @@ ALTER TABLE "attendance" ADD CONSTRAINT "attendance_schedule_id_fkey" FOREIGN KE -- AddForeignKey ALTER TABLE "attendance" ADD CONSTRAINT "attendance_roster_id_fkey" FOREIGN KEY ("roster_id") REFERENCES "roster"("id") ON DELETE CASCADE ON UPDATE CASCADE; +-- AddForeignKey +ALTER TABLE "schedule" ADD CONSTRAINT "schedule_survey_group_id_fkey" FOREIGN KEY ("survey_group_id") REFERENCES "surveyGroup"("id") ON DELETE CASCADE ON UPDATE CASCADE; + -- AddForeignKey ALTER TABLE "surveyTarget" ADD CONSTRAINT "surveyTarget_roster_id_fkey" FOREIGN KEY ("roster_id") REFERENCES "roster"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 775c5fe..64c263d 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -76,7 +76,7 @@ model User { Rosters Roster[] Storages Storage[] Posts Post[] - Comment Comment[] + Comments Comment[] @@map("user") } @@ -100,7 +100,7 @@ model Roster { Storage Storage? @relation(fields: [profileImageId], references: [id], onDelete: SetNull) User User? @relation(fields: [userId], references: [id], onDelete: SetNull) - Attendance Attendance[] + Attendances Attendance[] SurveyTargets SurveyTarget[] @@map("roster") @@ -122,12 +122,14 @@ model Attendance { } model Schedule { - id Int @id @default(autoincrement()) - name String @db.VarChar(64) - date DateTime - type ScheduleType @default(Exercise) - description String @db.Text - + id Int @id @default(autoincrement()) + surveyGroupId Int @map("survey_group_id") + name String @db.VarChar(64) + date DateTime + type ScheduleType @default(Exercise) + description String @db.Text + + SurveyGroup SurveyGroup @relation(fields: [surveyGroupId], references: [id], onDelete: Cascade) Attendances Attendance[] @@map("schedule") @@ -140,7 +142,8 @@ model SurveyGroup { endedAt DateTime @map("ended_at") required Boolean @default(true) - SurveyTarget SurveyTarget[] + SurveyTargets SurveyTarget[] + Schedules Schedule[] @@map("surveyGroup") } @@ -193,10 +196,10 @@ model Comment { createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") - Post Post @relation(fields: [postId], references: [id], onDelete: Cascade) - User User @relation(fields: [userId], references: [id], onDelete: Cascade) - Parent Comment? @relation("SubComments", fields: [parentId], references: [id], onDelete: Cascade) - Children Comment[] @relation("SubComments") + Post Post @relation(fields: [postId], references: [id], onDelete: Cascade) + User User @relation(fields: [userId], references: [id], onDelete: Cascade) + Parent Comment? @relation("SubComments", fields: [parentId], references: [id], onDelete: Cascade) + Childrens Comment[] @relation("SubComments") @@map("comment") } diff --git a/frontend/src/app/console/account/page.tsx b/frontend/src/app/console/account/page.tsx index 9a8852d..191210d 100644 --- a/frontend/src/app/console/account/page.tsx +++ b/frontend/src/app/console/account/page.tsx @@ -4,7 +4,7 @@ import { calculateTotalPages } from '@/lib/utils' import { PAGINATION_LIMIT_DEFAULT } from '@/lib/vars' import UserListTable from './_component/UserListTable' -export default async function Account({ +export default async function AccountPage({ searchParams }: { searchParams?: { diff --git a/frontend/src/app/console/roster/page.tsx b/frontend/src/app/console/roster/page.tsx new file mode 100644 index 0000000..f10a4eb --- /dev/null +++ b/frontend/src/app/console/roster/page.tsx @@ -0,0 +1,10 @@ +export default async function RosterPage() { + return ( +
+
+

부원명단

+
+
+
+ ) +} diff --git a/frontend/src/components/ConsoleSidebar.tsx b/frontend/src/components/ConsoleSidebar.tsx index bbd6a82..68ebb53 100644 --- a/frontend/src/components/ConsoleSidebar.tsx +++ b/frontend/src/components/ConsoleSidebar.tsx @@ -1,19 +1,13 @@ 'use client' -import { getCurrentUserProfile } from '@/lib/actions' import { auth } from '@/lib/auth' +import fetcher from '@/lib/fetcher' import type { UserProfile } from '@/lib/types/user' import { Dialog, Transition } from '@headlessui/react' import { ArrowRightStartOnRectangleIcon, Bars3Icon, - CalendarIcon, - ChartPieIcon, - EnvelopeIcon, - FireIcon, HomeIcon, - LinkIcon, - PencilIcon, UserIcon, UsersIcon, XMarkIcon @@ -32,24 +26,29 @@ const navigation = [ icon: HomeIcon, role: 'User' }, + // { + // name: '건의사항', + // href: '/console/appeal', + // icon: EnvelopeIcon, + // role: 'User' + // }, + // { + // name: '로스터연결', + // href: '/console/roster', + // icon: LinkIcon, + // role: 'User' + // }, { - name: '건의사항', - href: '/console/appeal', - icon: EnvelopeIcon, - role: 'User' - }, - { - name: '로스터연결', + name: '부원관리', href: '/console/roster', - icon: LinkIcon, - role: 'User' + icon: UsersIcon, + role: 'Manager' }, - { name: '부원관리', href: '#', icon: UsersIcon, role: 'Manager' }, - { name: '시합관리', href: '#', icon: FireIcon, role: 'Manager' }, - { name: '일정관리', href: '#', icon: CalendarIcon, role: 'Manager' }, - { name: '계정관리', href: '/console/account', icon: UserIcon, role: 'Admin' }, - { name: '출석변경', href: '#', icon: PencilIcon, role: 'Admin' }, - { name: '출석통계', href: '#', icon: ChartPieIcon, role: 'Admin' } + // { name: '시합관리', href: '#', icon: FireIcon, role: 'Manager' }, + // { name: '일정관리', href: '#', icon: CalendarIcon, role: 'Manager' }, + { name: '계정관리', href: '/console/account', icon: UserIcon, role: 'Admin' } + // { name: '출석변경', href: '#', icon: PencilIcon, role: 'Admin' }, + // { name: '출석통계', href: '#', icon: ChartPieIcon, role: 'Admin' } ] export default function ConsoleSidebar() { @@ -97,7 +96,7 @@ export default function ConsoleSidebar() { useEffect(() => { const getProfile = async () => { - const profile = await getCurrentUserProfile() + const profile = await fetcher.get('/user') setProfile(profile) }