issue # ci/cd 테스트
This commit is contained in:
9
.gitlab-ci.yml
Normal file
9
.gitlab-ci.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
stages:
|
||||||
|
-build
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
image: node:25.1.0
|
||||||
|
script:
|
||||||
|
- npm run build
|
||||||
|
- ls
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
|
|||||||
9
src/data/form/emailVerification.schema.ts
Normal file
9
src/data/form/emailVerification.schema.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import * as z from 'zod';
|
||||||
|
|
||||||
|
export const EmailVerificationSchema = z.object({
|
||||||
|
email: z
|
||||||
|
.email()
|
||||||
|
, verificationCode: z
|
||||||
|
.string()
|
||||||
|
.length(6, "이메일 인증 번호 6자리를 입력해주십시오.")
|
||||||
|
});
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
export { SignUpSchema } from './signup.schema';
|
export { SignUpSchema } from './signup.schema';
|
||||||
export { LoginSchema } from './login.schema';
|
export { LoginSchema } from './login.schema';
|
||||||
export { ResetPasswordSchema } from './resetPassword.schema';
|
export { ResetPasswordSchema } from './resetPassword.schema';
|
||||||
|
export { EmailVerificationSchema } from './emailVerification.schema';
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
import { zodResolver } from '@/hookform/resolvers/zod';
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
|
|
||||||
const LoginSchema = z.object({
|
export const LoginSchema = z.object({
|
||||||
email: z
|
email: z
|
||||||
.email()
|
.email()
|
||||||
, password: z
|
, password: z
|
||||||
.string()
|
.string()
|
||||||
.min(8, "비밀번호는 8-12 자리여야 합니다.")
|
.min(8, "비밀번호는 8-12 자리여야 합니다.")
|
||||||
.max(12, "비밀번호는 8-12 자리여야 합니다.")
|
.max(12, "비밀번호는 8-12 자리여야 합니다.")
|
||||||
.regex(\^[a-z](?=.*[0-9])(?=.*[!@#$]).*$\)
|
.regex(/^[a-z](?=.*[0-9])(?=.*[!@#$]).*$/, "비밀번호는 영소문자로 시작하여 숫자, 특수문자(!@#$)를 한 개 이상 포함하여야 합니다.")
|
||||||
});
|
});
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
import { zodResolver } from '@/hookform/resolvers/zod';
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
|
|
||||||
const ResetPasswordSchema = z.object({
|
export const ResetPasswordSchema = z.object({
|
||||||
email: z
|
email: z
|
||||||
.email()
|
.email()
|
||||||
});
|
});
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
import { zodResolver } from '@/hookform/resolvers/zod';
|
|
||||||
import { useForm } from 'react-hook-form';
|
|
||||||
|
|
||||||
const SignUpSchema = z.object({
|
export const SignUpSchema = z.object({
|
||||||
email: z
|
email: z
|
||||||
.email()
|
.string()
|
||||||
|
.min(1, "이메일을 입력해주십시오.")
|
||||||
, password: z
|
, password: z
|
||||||
.string()
|
.string()
|
||||||
.min(8, "비밀번호는 8-12 자리여야 합니다.")
|
.min(8, "비밀번호는 8-12 자리여야 합니다.")
|
||||||
.max(12, "비밀번호는 8-12 자리여야 합니다.")
|
.max(12, "비밀번호는 8-12 자리여야 합니다.")
|
||||||
.regex(\^[a-z](?=.*[0-9])(?=.*[!@#$]).*$\, "영문 소문자로 시작하고 숫자와 특수문자(!@#$)를 포함해야 합니다.")
|
.regex(/^[a-z](?=.*[0-9])(?=.*[!@#$]).*$/, "영문 소문자로 시작하고 숫자와 특수문자(!@#$)를 포함해야 합니다.")
|
||||||
, name: z
|
, name: z
|
||||||
.string()
|
.string()
|
||||||
|
.min(1, "이름을 입력해주시십시오.")
|
||||||
, nickname: z
|
, nickname: z
|
||||||
.string()
|
.string()
|
||||||
|
.min(1, "닉네임을 입력해주십시오.")
|
||||||
, passwordConfirm: z
|
, passwordConfirm: z
|
||||||
.string()
|
.string()
|
||||||
})
|
})
|
||||||
|
|||||||
40
src/hooks/useModal.tsx
Normal file
40
src/hooks/useModal.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { useState, type ReactNode } from "react";
|
||||||
|
import { Dialog, DialogTrigger, DialogTitle, DialogContent, DialogHeader, DialogFooter} from "@/components/ui/dialog";
|
||||||
|
import { type DialogProps } from "@radix-ui/react-dialog";
|
||||||
|
|
||||||
|
export function useModal() {
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
|
const open = () => setIsOpen(true);
|
||||||
|
const close = () => setIsOpen(false);
|
||||||
|
|
||||||
|
type ModalProps = DialogProps & {
|
||||||
|
children: ReactNode;
|
||||||
|
trigger: ReactNode;
|
||||||
|
title: string;
|
||||||
|
footer: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
const Modal = ({ children, trigger, title, footer, ...props }: ModalProps) => (
|
||||||
|
<Dialog
|
||||||
|
open={isOpen}
|
||||||
|
onOpenChange={val => setIsOpen(val)}
|
||||||
|
modal={true}
|
||||||
|
{...props}>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
{trigger}
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{title}</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
{children}
|
||||||
|
<DialogFooter>
|
||||||
|
{footer}
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
|
||||||
|
return { isOpen, open, close, Modal };
|
||||||
|
}
|
||||||
@@ -122,3 +122,15 @@
|
|||||||
html, body, #root {
|
html, body, #root {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Chrome, Safari, Edge */
|
||||||
|
input[type="number"]::-webkit-inner-spin-button,
|
||||||
|
input[type="number"]::-webkit-outer-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Firefox */
|
||||||
|
input[type="number"] {
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
98
src/ui/component/modal/EmailVerificationModal.tsx
Normal file
98
src/ui/component/modal/EmailVerificationModal.tsx
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { useModal } from "@/hooks/useModal";
|
||||||
|
import { useState, type ReactNode } from "react";
|
||||||
|
import { EmailVerificationSchema } from "@/data/form";
|
||||||
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
import z from "zod";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { Field, FieldError, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||||
|
import { InputOTP, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp";
|
||||||
|
|
||||||
|
type EmailVerificationModalProps = {
|
||||||
|
trigger: ReactNode;
|
||||||
|
email: string;
|
||||||
|
handler: () => void;
|
||||||
|
}
|
||||||
|
export default function EmailVerificationModal(
|
||||||
|
{ trigger, email, handler } : EmailVerificationModalProps
|
||||||
|
) {
|
||||||
|
const [isVerifying, setIsVerifying] = useState<boolean>(false);
|
||||||
|
const { open, close, Modal } = useModal();
|
||||||
|
|
||||||
|
const emailVerificationForm = useForm<z.infer<typeof EmailVerificationSchema>>({
|
||||||
|
resolver: zodResolver(EmailVerificationSchema),
|
||||||
|
defaultValues: {
|
||||||
|
email: email,
|
||||||
|
verificationCode: ""
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleOnOpenChange = (isOpen: boolean) => {
|
||||||
|
if (!isVerifying) {
|
||||||
|
if (isOpen) {
|
||||||
|
open();
|
||||||
|
} else {
|
||||||
|
emailVerificationForm.clearErrors();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const verifyCode = () => {
|
||||||
|
console.log(emailVerificationForm.getValues("verificationCode"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOnOTPComplete = (otp: string) => {
|
||||||
|
setIsVerifying(true);
|
||||||
|
emailVerificationForm.setValue("verificationCode", otp, { shouldValidate: true });
|
||||||
|
emailVerificationForm.handleSubmit(verifyCode)();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<Modal
|
||||||
|
onOpenChange={handleOnOpenChange}
|
||||||
|
children={
|
||||||
|
<form id="form-email-verification" onSubmit={verifyCode}>
|
||||||
|
<FieldGroup>
|
||||||
|
<Controller
|
||||||
|
name="verificationCode"
|
||||||
|
control={emailVerificationForm.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<Field
|
||||||
|
data-invalid={fieldState.invalid}
|
||||||
|
className="w-full flex flex-col justify-center items-center"
|
||||||
|
>
|
||||||
|
<FieldLabel htmlFor="form-email-verification-code">
|
||||||
|
인증 번호
|
||||||
|
</FieldLabel>
|
||||||
|
<div
|
||||||
|
className="flex flex-row justify-center items-center"
|
||||||
|
>
|
||||||
|
<InputOTP
|
||||||
|
maxLength={6}
|
||||||
|
inputMode="numeric"
|
||||||
|
pattern="\d*"
|
||||||
|
id="form-email-verification-code"
|
||||||
|
onComplete={handleOnOTPComplete}
|
||||||
|
required>
|
||||||
|
<InputOTPGroup className="gap-2.5 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border">
|
||||||
|
<InputOTPSlot index={0} />
|
||||||
|
<InputOTPSlot index={1} />
|
||||||
|
<InputOTPSlot index={2} />
|
||||||
|
<InputOTPSlot index={3} />
|
||||||
|
<InputOTPSlot index={4} />
|
||||||
|
<InputOTPSlot index={5} />
|
||||||
|
</InputOTPGroup>
|
||||||
|
</InputOTP>
|
||||||
|
</div>
|
||||||
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</FieldGroup>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
trigger={trigger}
|
||||||
|
title="이메일 인증"
|
||||||
|
footer={null}
|
||||||
|
/>);
|
||||||
|
}
|
||||||
0
src/ui/page/login/LoginPage.tsx
Normal file
0
src/ui/page/login/LoginPage.tsx
Normal file
@@ -5,23 +5,165 @@ import { Input } from '@/components/ui/input';
|
|||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle
|
CardFooter
|
||||||
} from '@/components/ui/card';
|
} from '@/components/ui/card';
|
||||||
import { Form, FormField } from '@/components/ui/form';
|
import { Field, FieldError, FieldGroup, FieldLabel, FieldLegend } from '@/components/ui/field';
|
||||||
|
import { SignUpSchema } from '@/data/form';
|
||||||
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
|
import * as z from 'zod';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import EmailVerificationModal from '@/ui/component/modal/EmailVerificationModal';
|
||||||
|
|
||||||
export default function SignUpPage() {
|
export default function SignUpPage() {
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [isCheckedEmailDuplication, setIsCheckdEmailDupliation] = useState<boolean>(false);
|
||||||
|
const [isEmailVerificated, setIsEmailVerificated] = useState<boolean>(false);
|
||||||
|
const [duplicationCheckedEmail, setDuplicationCheckedEmail] = useState<string>("");
|
||||||
|
|
||||||
|
const signUpForm = useForm<z.infer<typeof SignUpSchema>>({
|
||||||
|
resolver: zodResolver(SignUpSchema),
|
||||||
|
defaultValues: {
|
||||||
|
email: "",
|
||||||
|
password: "",
|
||||||
|
passwordConfirm: "",
|
||||||
|
name: "",
|
||||||
|
nickname: "",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleOnChangeEmail = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setIsCheckdEmailDupliation(
|
||||||
|
e.currentTarget.value === duplicationCheckedEmail
|
||||||
|
);
|
||||||
|
// setIsEmailVerificated(
|
||||||
|
// e.currentTarget.value === duplicationCheckedEmail
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleEmailDuplicationCheckButtonClick = () => {
|
||||||
|
console.log(signUpForm.getValues("email"));
|
||||||
|
setDuplicationCheckedEmail(signUpForm.getValues("email"));
|
||||||
|
setIsCheckdEmailDupliation(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOnSubmitSignUpForm = () => {
|
||||||
|
if (!isCheckedEmailDuplication) {
|
||||||
|
signUpForm.setError("email", { message: "이메일 중복 확인이 필요합니다." });
|
||||||
|
}
|
||||||
|
// if (!isEmailVerificated) {
|
||||||
|
// signUpForm.setError("email", { message: "이메일 인증이 완료되지 않았습니다." });
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full flex flex-col justify-center items-center">
|
<div className="w-full h-full flex flex-col justify-center items-center">
|
||||||
<Card className="w-xl h-4/6">
|
<Card className="w-md pl-2 pr-2">
|
||||||
<CardHeader className="ml-2.5 select-none">
|
<CardHeader>회원가입</CardHeader>
|
||||||
<CardTitle className="text-3xl">로그인</CardTitle>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Label>a</Label>
|
<form id="form-signup" onSubmit={signUpForm.handleSubmit(handleOnSubmitSignUpForm)}>
|
||||||
|
<FieldGroup>
|
||||||
|
<Controller
|
||||||
|
name="name"
|
||||||
|
control={signUpForm.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<Field data-invalid={fieldState.invalid}>
|
||||||
|
<FieldLabel htmlFor="form-signup-name">이름</FieldLabel>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id="form-signup-name"
|
||||||
|
aria-invalid={fieldState.invalid}
|
||||||
|
/>
|
||||||
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="nickname"
|
||||||
|
control={signUpForm.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<Field data-invalid={fieldState.invalid}>
|
||||||
|
<FieldLabel htmlFor="form-signup-nickname">닉네임</FieldLabel>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id="form-signup-nickname"
|
||||||
|
aria-invalid={fieldState.invalid}
|
||||||
|
/>
|
||||||
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="email"
|
||||||
|
control={signUpForm.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<Field data-invalid={fieldState.invalid}>
|
||||||
|
<FieldLabel htmlFor="form-signup-email">이메일</FieldLabel>
|
||||||
|
<div id="email-group" className="w-full flex flex-row justify-between gap-2.5">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id="form-signup-email"
|
||||||
|
aria-invalid={fieldState.invalid}
|
||||||
|
placeholder="example@domain.com"
|
||||||
|
type="email"
|
||||||
|
onInput={handleOnChangeEmail}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
onClick={handleEmailDuplicationCheckButtonClick}
|
||||||
|
>
|
||||||
|
중복 확인
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<FieldError errors={[fieldState.error]}/>
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="password"
|
||||||
|
control={signUpForm.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<Field data-invalid={fieldState.invalid}>
|
||||||
|
<FieldLabel htmlFor="form-signup-password">비밀번호</FieldLabel>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id="form-signup-password"
|
||||||
|
aria-invalid={fieldState.invalid}
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="passwordConfirm"
|
||||||
|
control={signUpForm.control}
|
||||||
|
render={({ field, fieldState }) => (
|
||||||
|
<Field data-invalid={fieldState.invalid}>
|
||||||
|
<FieldLabel htmlFor="form-signup-password-confirm">비밀번호 확인</FieldLabel>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
id="form-signup-password-confirm"
|
||||||
|
aria-invalid={fieldState.invalid}
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
<FieldError errors={[fieldState.error]} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</FieldGroup>
|
||||||
|
</form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<EmailVerificationModal
|
||||||
|
trigger={
|
||||||
|
<Button type="submit" form="form-signup">
|
||||||
|
회원가입
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
email={duplicationCheckedEmail}
|
||||||
|
handler={() => {}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user