diff --git a/.eslintrc.json b/.eslintrc.json index 15b1ed91a..bffb357a7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,3 @@ { - "extends": "next" + "extends": "next/core-web-vitals" } diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 000000000..123842d5a --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,22 @@ +'use client'; + +import { AuthProvider } from '@/contexts/AuthContext'; +import '@/styles/reset.css'; +import '@/styles/globals.css'; + +export default function RootLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + + + Linkbrary + + + {children} + + + ); +} diff --git a/app/lib/definitions.ts b/app/lib/definitions.ts new file mode 100644 index 000000000..340bed162 --- /dev/null +++ b/app/lib/definitions.ts @@ -0,0 +1,41 @@ +import z from 'zod'; + +export const SignInFormSchema = z.object({ + email: z + .string() + .min(1, { message: '이메일을 입력해주세요' }) + .email({ message: '올바른 이메일 형식이 아닙니다' }), + + password: z + .string() + .min(1, { message: '비밀번호를 입력해주세요' }) + .min(8, { message: '비밀번호는 최소 8자 이상이어야 합니다.' }), +}); + +export type SignInFormFields = z.infer; + +export const SignUpFormSchema = z + .object({ + email: z + .string() + .min(1, { message: '이메일을 입력해주세요' }) + .email({ message: '올바른 이메일 형식이 아닙니다' }), + + password: z + .string() + .min(1, { message: '비밀번호를 입력해주세요' }) + .min(8, { + message: '비밀번호는 최소 8자 이상 영문, 숫자 조합이어야 합니다.', + }) + .regex(/^(?=.*[A-Za-z])(?=.*\d).{8,}$/, { + message: '비밀번호는 영문과 조합이어야 합니다', + }), + + confirmPassword: z.string().min(1, { message: '비밀번호를 입력해주세요' }), + }) + .refine((data) => data.confirmPassword === data.password, { + message: '비밀번호가 일치하지 않습니다.', + path: ['confirmPassword'], + }); + +export type SignUpFormFields = z.infer; diff --git a/app/shared/[folderId]/page.tsx b/app/shared/[folderId]/page.tsx new file mode 100644 index 000000000..bd13c37ee --- /dev/null +++ b/app/shared/[folderId]/page.tsx @@ -0,0 +1,40 @@ +import { axiosInstance } from '@/utils/axiosInstance'; +import SharedLinkCardList from '@/components/SharedLinkCardList/SharedLinkCardList'; +import SharedProfile from '@/components/SharedProfile/SharedProfile'; + +interface Props { + params: { folderId: string }; +} + +async function fetchFolderData(folderId: string) { + const response = await axiosInstance.get(`/folders/${folderId}`); + console.log(response); + return response.data.data[0]; +} + +async function fetchUserInfo(userId: number) { + const response = await axiosInstance.get(`/users/${userId}`); + console.log(response); + return response.data.data[0]; +} + +async function fetchUserLinks(userId: number, folderId: number) { + const response = await axiosInstance.get( + `/users/${userId}/links?folderId=${folderId}` + ); + console.log(response); + return response.data.data; +} + +export default async function Page({ params }: Props) { + const folderData = await fetchFolderData(params.folderId); + const userInfo = await fetchUserInfo(folderData.user_id); + const links = await fetchUserLinks(folderData.user_id, folderData.id); + + return ( + <> + + + + ); +} diff --git a/app/shared/layout.tsx b/app/shared/layout.tsx new file mode 100644 index 000000000..544770cb7 --- /dev/null +++ b/app/shared/layout.tsx @@ -0,0 +1,19 @@ +import { AuthProvider } from '@/contexts/AuthContext'; +import '@/styles/reset.css'; +import '@/styles/globals.css'; +import Header from '@/components/Header/Header'; +import Footer from '@/components/Footer/Footer'; + +export default function SharedPageLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( + <> +
+
{children}
+