-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sign up form/#7 #50
Merged
Merged
Sign up form/#7 #50
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
c6c9926
feat: Add Alert and AlertDestructive components
seonghunYang b99e407
refactor: Refactor form state structure
seonghunYang 3ce84ad
feat: Add alert component to form
seonghunYang 2eb2eff
feat: Add mock action function in form stories
seonghunYang d7d31d3
rename: Rename auth domain to user domain
seonghunYang 3fb7609
feat: Update user command and add sign-up form
seonghunYang ad7663e
feat: Add user API endpoint to API_PATH
seonghunYang 94acb42
feat: Add mock database
seonghunYang 0778dd6
refactor: Refactor mock handlers structure
seonghunYang 7d14ef1
chore: Add experimental serverActions configuration to next.config.mjs
seonghunYang 13eb3da
refactor: Refactor user command and user type files
seonghunYang 820bc23
feat: set Content-Type header in createUser function
seonghunYang 66defae
feat: Fix createUser function to prevent duplicate user creation
seonghunYang 1ffb3cf
feat: Refactor user creation and error handling
seonghunYang fa05b5b
feat: Add http error handling logic
seonghunYang 138e06c
refactor: Refactor user command and sign-up form
seonghunYang fc60afa
fix: Fix select root component
seonghunYang 03e870a
refactor: Update form field names and translations
seonghunYang 39ddab6
refactor: update error message
seonghunYang c888fd9
fix: Update English level options in sign-up form
seonghunYang 2779ee5
feat: Add msw-storybook-addon dependency
seonghunYang 4198e04
chore: setting msw addon to storybook
seonghunYang 7ba5b37
fix: Update API base URL in api-path.ts
seonghunYang 37665b8
chore: Add test-storybook script to package.json
seonghunYang dd127e0
feat: Add sign-up form component and stories
seonghunYang c6e8e9e
test: Add aliases and mock files for testing in Storybook
seonghunYang 366f2e7
feat: Update user-handler.mock.ts and sign-up-form.stories.tsx
seonghunYang f71e81f
feat: Add isSuccess property to FormState
seonghunYang 11c308b
feat: Add sign-up page component
seonghunYang b22027a
feat: Add useFunnel hook for managing multi-step processes
seonghunYang e862446
refactor: Refactor SignUpForm component to include onNext prop
seonghunYang 00ed836
feat: Add sign-up terms component
seonghunYang dd44e7e
feat: Add sign-up success component
seonghunYang 77873f7
feat: Add sign-up container component
seonghunYang 4b1ff85
refactor: Refactor sign-up page component
seonghunYang 4a7308c
test: Add success and failure scenarios test for sign-up form
seonghunYang 70cd343
refactor: Refactor app-router context provider and remove unused file
seonghunYang 414f300
chore: Update sign-up components with mock content and styles
seonghunYang e20d8fc
refactor: Update SignUpFormSchema to SignUpFormMockSchema
seonghunYang 74f5861
refactor: Remove console.log statement in SelectRoot component
seonghunYang 73f94bc
Update app/hooks/useFunnel.tsx
seonghunYang 2e109ec
fix: Fix typo in useFunnel hook
seonghunYang 812c794
feat: Add ContentContainer component to sign-up page
seonghunYang ffbde27
chore: Remove revenue chart from dashboard page
seonghunYang e5a783d
refactor: Refactor useFunnel hook to include options for step query kβ¦
seonghunYang fa2a5ad
feat: Refactor sign-up page to use Suspense and LoadingSpinner
seonghunYang 9353625
refactor: Refactor useFunnel hook to use defaultStep instead of defauβ¦
seonghunYang 9c49969
chore: update initialization in preview.ts and remove userHandlers inβ¦
seonghunYang 397f150
refactor: Refactor user command module and add form validation
seonghunYang f6e7028
chore: Merge branch 'main' into sign-up-form/#7
seonghunYang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client'; | ||
import useFunnel from '@/app/hooks/useFunnel'; | ||
import SignUpForm from '@/app/ui/user/sign-up-form/sign-up-form'; | ||
import SignUpTerm from './sign-up-terms'; | ||
import SignUpSuccess from './sign-up-success'; | ||
import ContentContainer from '@/app/ui/view/atom/content-container'; | ||
|
||
export default function SignUpContainer() { | ||
const { Funnel, setStep } = useFunnel<'terms' | 'form' | 'success'>('terms'); | ||
yougyung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<div className="p-6"> | ||
<Funnel> | ||
<Funnel.Step name="terms"> | ||
<SignUpTerm | ||
onNext={() => { | ||
setStep('form'); | ||
}} | ||
/> | ||
</Funnel.Step> | ||
<Funnel.Step name="form"> | ||
<SignUpForm | ||
onNext={() => { | ||
setStep('success'); | ||
}} | ||
/> | ||
</Funnel.Step> | ||
<Funnel.Step name="success"> | ||
<SignUpSuccess /> | ||
</Funnel.Step> | ||
</Funnel> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Button from '@/app/ui/view/atom/button/button'; | ||
import Link from 'next/link'; | ||
|
||
// λ΄μ©μ΄λ μ€νμΌμ mockμΈ μνμ λλ€. | ||
export default function SignUpSuccess() { | ||
return ( | ||
<div className="min-h-screen bg-gray-100 flex items-center justify-center px-4 sm:px-6"> | ||
<div className="max-w-md w-full space-y-8"> | ||
<div className="space-y-2"> | ||
<h2 className="text-3xl font-extrabold tracking-tight">Youre all set.</h2> | ||
<p className="text-gray-500"> | ||
Thanks for signing up! We just need to verify your email address to complete the process. | ||
</p> | ||
</div> | ||
<div className="space-y-4"> | ||
<div className="grid grid-cols-2 gap-4"> | ||
<Link className="inline-block w-full" href="/login"> | ||
<Button className="w-full" label={'λ‘κ·ΈμΈ νκΈ°'} /> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Button from '@/app/ui/view/atom/button/button'; | ||
|
||
interface SignUpTermProps { | ||
onNext?: () => void; | ||
} | ||
|
||
// μ½κ΄ λ΄μ©μ΄λ μ€νμΌμ mockμΈ μνμ λλ€. | ||
export default function SignUpTerm({ onNext }: SignUpTermProps) { | ||
const handleAgreeButtonClick = () => { | ||
onNext?.(); | ||
}; | ||
|
||
return ( | ||
<div className="max-w-2xl mx-auto my-8 p-6 bg-white rounded-lg shadow-md"> | ||
<h1 className="text-3xl font-bold text-center mb-6">μλ¦Όλ μ μλ΄λ¬Έ</h1> | ||
<ul className="list-disc space-y-4 text-sm"> | ||
<li> | ||
νμ¬ μ ν¬ κΈ°λ₯μ νκ΅-νκ΅μ μλλΌ νκ΅-μΈκ΅λ κ°λ₯ν©λλ€. κ°μ¬λ³μμ μνμΈ μλλΌλ μ ν¬κ° λ°λλ°κΉμ§λ | ||
무κ΄ν©λλ€λ§, κΌ κ΄μΈμ¬λ¬΄μμ νμνμΈμ! | ||
<ul className="list-disc ml-6 mt-2"> | ||
<li>λμ: κ΅μΈλ°μ‘, λΆλΆλ°μ‘, μ¬ν볡μ§λμ, ICTμ©νλμ, μΌλ°λμ, λ―Έλμ©νλμ(νμΈ)</li> | ||
<li>λ°μ‘: 16 ~ 22μλ°</li> | ||
</ul> | ||
</li> | ||
<li> | ||
κ΅μ§, λμμΈ, μ°κ³κ°λ°, λ¬Όν, μ μ, μμκ΄λ¦¬/νκ³μ§μμ ν΄λΉνλ μ¬μ©μλ κ°μ¬ κΈ°μ€μ λ°λ₯Έ μ μ λμ§ μμ κ°μ¬ | ||
λ³ κ΄λ¦¬νλλ°μ. | ||
</li> | ||
<li>κ²μ¬λ₯Ό μν΄μ μ μ νμ μ§μ μ°λ½λλ €μΌλ§ PCνλ©΄μμ μ§ννλ κ²μ κΆμ₯ν©λλ€.</li> | ||
<li> | ||
κ²μ¬ κΈ°μ€μ μ΅μ λ²μ νμΈλ΄μ(2023.07.24) λ°μνμ¬ μ μ λμμΌλ©°, νμ¬λ΄μμ 맀λ κ°νΈλλ―λ‘ μμ¬μ΄ μΈκ³ μλ | ||
ꡬλ²μ κ³Ό λ€λ₯Ό μ μμ΅λλ€. | ||
<ul className="list-disc ml-6 mt-2"> | ||
<li>λ¬Έμλν: νμ¬λ΄μμ νμΈ ν΄λ¦</li> | ||
</ul> | ||
</li> | ||
<li> | ||
λ³Έ μλΉμ€ μ 보λ 곡μμ μΈ νμΈμ μ μ μμΌλ©°, μ νν μ¦μμ‘°μ¬κ²°κ³Όλ₯Ό μν΄ μλ₯ λλ λ΄λΉκ³Ό κ΅λ₯ν΄μΌν μ¬νμ | ||
μμ§ μμ΅λλ€. | ||
</li> | ||
<li> | ||
μ μλ¬Έ μνμ§ λ°μ΄ν°λ² μ΄μ€λ μ무νλμ΄ μ ν¬κ° κ³ μ μΆμ λ° κ΅μ‘κ³Όμ λ±μμ μ¬μ©λλ©°, μ΄λ€ λ€λ₯Έ μ©λλ‘ μ¬μ© | ||
λμ§ μμ΅λλ€. | ||
</li> | ||
<li>νΉνμ건 κΈ°μ€μ΄ μ λ¬Έ μ μ λμκ±°λ, μ€λ₯λ°μ μ μ°μΈ‘ νλ¨ μ±ν μ°½μΌλ‘ λλ λ΄λΉ λΆμλ‘λ¬Έμν©λλ€.</li> | ||
</ul> | ||
<div className="mt-8 flex justify-center"> | ||
<Button | ||
onClick={handleAgreeButtonClick} | ||
className="ml-4 bg-blue-500 text-white py-2 px-4 rounded-full" | ||
label={'μλ¦Όλ μ μλ΄λ¬Έ'} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ContentContainer from '@/app/ui/view/atom/content-container'; | ||
import SignUpContainer from './components/sign-up-container'; | ||
import { Suspense } from 'react'; | ||
import LoadingSpinner from '@/app/ui/view/atom/loading-spinner'; | ||
|
||
// Refactor: fallback μ€μΌλ ν€μΌλ‘ λ체 | ||
export default function Page() { | ||
return ( | ||
<ContentContainer className="md:w-[768px]"> | ||
<Suspense | ||
fallback={ | ||
<div className="h-96"> | ||
<LoadingSpinner /> | ||
</div> | ||
} | ||
> | ||
<SignUpContainer /> | ||
</Suspense> | ||
</ContentContainer> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
const BASE_URL = process.env.API_MOCKING === 'enable' ? 'http://localhost:9090' : 'http://mock.api.com'; | ||
const BASE_URL = process.env.API_MOCKING === 'enable' ? 'http://localhost:9090' : 'https://mock.api.com'; | ||
|
||
export const API_PATH = { | ||
revenue: `${BASE_URL}/revenue`, | ||
registerUserGrade: `${BASE_URL}/registerUserGrade`, | ||
parsePDFtoText: `${BASE_URL}/parsePDFtoText`, | ||
takenLectures: `${BASE_URL}/taken-lectures`, | ||
user: `${BASE_URL}/users`, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use server'; | ||
|
||
import { FormState } from '@/app/ui/view/molecule/form/form-root'; | ||
import { API_PATH } from '../api-path'; | ||
import { SignUpRequestBody } from './user.type'; | ||
import { httpErrorHandler } from '@/app/utils/http/http-error-handler'; | ||
import { BadRequestError } from '@/app/utils/http/http-error'; | ||
import { SignUpFormSchema } from './user.validation'; | ||
|
||
export async function createUser(prevState: FormState, formData: FormData): Promise<FormState> { | ||
const validatedFields = SignUpFormSchema.safeParse({ | ||
authId: formData.get('authId'), | ||
password: formData.get('password'), | ||
confirmPassword: formData.get('confirmPassword'), | ||
studentNumber: formData.get('studentNumber'), | ||
engLv: formData.get('engLv'), | ||
}); | ||
|
||
if (!validatedFields.success) { | ||
return { | ||
isSuccess: false, | ||
isFailure: true, | ||
validationError: validatedFields.error.flatten().fieldErrors, | ||
message: 'μμμ λ§μΆ° λ€μ μ λ ₯ν΄μ£ΌμΈμ.', | ||
}; | ||
} | ||
|
||
const { authId, password, studentNumber, engLv } = validatedFields.data; | ||
const body: SignUpRequestBody = { | ||
authId, | ||
password, | ||
studentNumber, | ||
engLv, | ||
}; | ||
|
||
try { | ||
const response = await fetch(`${API_PATH.user}/sign-up`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(body), | ||
}); | ||
|
||
const result = await response.json(); | ||
|
||
httpErrorHandler(response, result); | ||
} catch (error) { | ||
if (error instanceof BadRequestError) { | ||
// μλͺ»λ μμ² μ²λ¦¬ λ‘μ§ | ||
return { | ||
isSuccess: false, | ||
isFailure: true, | ||
validationError: {}, | ||
message: error.message, | ||
}; | ||
} else { | ||
// λλ¨Έμ§ μλ¬λ λ μμ μμ€μμ μ²λ¦¬ | ||
throw error; | ||
} | ||
} | ||
|
||
return { | ||
isSuccess: true, | ||
isFailure: false, | ||
validationError: {}, | ||
message: 'νμκ°μ μ΄ μλ£λμμ΅λλ€.', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// https://stackoverflow.com/questions/76957592/error-only-async-functions-are-allowed-to-be-exported-in-a-use-server-file | ||
// server action νμΌμμλ async functionλ§ export κ°λ₯ | ||
|
||
export interface SignUpRequestBody { | ||
authId: string; | ||
password: string; | ||
studentNumber: string; | ||
engLv: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { z } from 'zod'; | ||
|
||
export const SignUpFormSchema = z | ||
.object({ | ||
authId: z | ||
.string() | ||
.min(6, { | ||
message: 'μμ΄λλ 6μ μ΄μ 20μ μ΄νμ¬μΌ ν©λλ€.', | ||
}) | ||
.max(20, { | ||
message: 'User ID must be at most 20 characters', | ||
}), | ||
password: z | ||
.string() | ||
.min(8, { message: 'λΉλ°λ²νΈλ 8μ μ΄μμ΄μ΄μΌ ν©λλ€.' }) | ||
.regex(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*])[A-Za-z\d!@#$%^&*]{8,}$/, { | ||
message: 'λΉλ°λ²νΈλ λ¬Έμ, μ«μ, νΉμλ¬Έμ(!@#$%^&*)λ₯Ό ν¬ν¨ν΄μΌ ν©λλ€.', | ||
}) | ||
.max(20, { message: 'λΉλ°λ²νΈλ 20μ μ΄νμ¬μΌ ν©λλ€.' }), | ||
confirmPassword: z.string(), | ||
studentNumber: z.string().length(8, { message: 'νλ²μ 8μ리μ¬μΌ ν©λλ€.' }).startsWith('60', { | ||
message: 'νλ²μ 60μΌλ‘ μμν΄μΌ ν©λλ€.', | ||
}), | ||
engLv: z.enum(['basic', 'ENG12', 'ENG34', 'bypass'], { | ||
invalid_type_error: 'μ¬λ°λ₯Έ μμ΄ λ 벨μ μ νν΄μ£ΌμΈμ.', | ||
}), | ||
}) | ||
.superRefine(({ confirmPassword, password }, ctx) => { | ||
if (confirmPassword !== password) { | ||
ctx.addIssue({ | ||
code: 'custom', | ||
message: 'λΉλ°λ²νΈκ° μΌμΉνμ§ μμ΅λλ€.', | ||
path: ['confirmPassword'], | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
routerλ‘ λ°λ‘ κ΄λ¦¬νμ§ μκΈ° λλ¬Έμ νμκ°μ νΌμμ λ€λ‘κ°κΈ° λ²νΌ ν΄λ¦ μ μ½κ΄ λͺ¨λ¬μ΄ λμ€μ§ μλ κ±Έ νμΈνμ΅λλ€!
λ°λ‘ μ΄μ κ° μμκΉμ©?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
νμΈνꡬ 리뷰 λ¨κ²Όμ΅λλ€!