generated from Park-min-hyoung/check-location
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:약관동의 및 휴대폰번호 입력 #16
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7d5f7f0
feat: 약관동의, 휴대폰
yj-leee 8ce3b06
fix: 네브바 및 헤더적용
yj-leee 9df88a2
fix: 리뷰 반영
yj-leee 797d644
Merge branch 'dev' into feat/auth-agreement
yj-leee e94a45e
Merge branch 'dev' into feat/auth-agreement
yj-leee 441a2ad
fix: conflict 에러 해결
yj-leee 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 hidden or 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 hidden or 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,7 @@ | ||
| import Agreement from "@/features/auth/components/Agreement"; | ||
|
|
||
| const AgreementView = () => { | ||
| return <Agreement />; | ||
| }; | ||
|
|
||
| export default AgreementView; |
This file contains hidden or 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,7 @@ | ||
| import PhoneNumber from "@/features/auth/components/PhoneNumber"; | ||
|
|
||
| const PhoneNumberInputView = () => { | ||
| return <PhoneNumber />; | ||
| }; | ||
|
|
||
| export default PhoneNumberInputView; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,173 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| import CheckedAllIcon from "@/asset/agreement/checked-all.svg?url"; | ||
| import CheckedItemIcon from "@/asset/agreement/checked-item.svg?url"; | ||
| import UncheckedAllIcon from "@/asset/agreement/unchecked-all.svg?url"; | ||
| import UncheckedItemIcon from "@/asset/agreement/unchecked-item.svg?url"; | ||
| import { postTermsAgree } from "@/features/auth/api/auth"; | ||
| import { useNavigate } from "react-router"; | ||
|
|
||
| import { useAuthStore } from "@/stores/auth-store"; | ||
| import { paths } from "@/config/paths"; | ||
|
|
||
| const AgreementCheckbox = ({ | ||
| checked, | ||
| onChange, | ||
| CheckedIcon, | ||
| UncheckedIcon | ||
| }) => { | ||
| return ( | ||
| <div | ||
| onClick={onChange} | ||
| style={{ cursor: "pointer", display: "inline-block" }} | ||
| > | ||
| <img | ||
| src={checked ? CheckedIcon : UncheckedIcon} | ||
| alt="Checkbox Icon" | ||
| width={28} | ||
| height={28} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const Agreement = () => { | ||
| const navigate = useNavigate(); | ||
| const userId = useAuthStore((state) => state.userId); | ||
|
|
||
| const [checkState, setCheckState] = useState({ | ||
| all: false, | ||
| terms: false, | ||
| privacy: false | ||
| }); | ||
|
|
||
| const handleAllCheck = () => { | ||
| setCheckState((prev) => { | ||
| const newChecked = !prev.all; | ||
| return { | ||
| all: newChecked, | ||
| terms: newChecked, | ||
| privacy: newChecked | ||
| }; | ||
| }); | ||
| }; | ||
| const handleSingleCheck = (key: "terms" | "privacy") => { | ||
| setCheckState((prev) => { | ||
| const newState = { | ||
| ...prev, | ||
| [key]: !prev[key] | ||
| }; | ||
|
|
||
| newState.all = newState.terms && newState.privacy; | ||
|
|
||
| return newState; | ||
| }); | ||
| }; | ||
|
|
||
| const handleSubmit = async () => { | ||
| if (!userId) return; | ||
|
|
||
| try { | ||
| const response = await postTermsAgree({ | ||
| data: { userId } | ||
| }); | ||
|
|
||
| if (response.data.success) { | ||
| navigate(paths.auth.phoneNumber.path); | ||
| } else { | ||
| throw new Error("약관 동의에 실패했습니다."); | ||
| } | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="ml-[20px] mt-[50px] flex h-auto min-h-screen w-[335px] flex-col pb-[74px]"> | ||
| <h1 className="mb-[40px] h-[58px] w-[335px] text-[24px] font-semibold leading-[28.8px] -tracking-wide text-gray-900"> | ||
| <span className="text-[#3CC360]">윌고</span> 서비스 이용을 위한 <br /> | ||
| 약관에 동의해주세요 | ||
| </h1> | ||
|
|
||
| <div className="flex h-auto w-[335px] flex-col"> | ||
| <div className="flex h-[58px] items-center gap-[6px]"> | ||
| <AgreementCheckbox | ||
| checked={checkState.all} | ||
| onChange={handleAllCheck} | ||
| CheckedIcon={CheckedAllIcon} | ||
| UncheckedIcon={UncheckedAllIcon} | ||
| /> | ||
| <label className="font-pretendard h-[20px] w-[96px] text-[18px] font-medium leading-[20px] -tracking-wide"> | ||
| 전체 동의하기 | ||
| </label> | ||
| </div> | ||
|
|
||
| <hr className="mb-6 border-gray-300" /> | ||
|
|
||
| <div className="flex h-auto w-[335px] flex-col gap-[6px]"> | ||
| <div className="flex h-[28px] items-center justify-between gap-[6px]"> | ||
| <div className="flex items-center gap-[6px]"> | ||
| <AgreementCheckbox | ||
| checked={checkState.terms} | ||
| onChange={() => handleSingleCheck("terms")} | ||
| CheckedIcon={CheckedItemIcon} | ||
| UncheckedIcon={UncheckedItemIcon} | ||
| /> | ||
| <span className="text-[14px] font-medium text-[#3CC360]"> | ||
| [필수] | ||
| </span> | ||
| <label className="text-[14px] font-medium text-gray-700"> | ||
| 사용자 이용약관 | ||
| </label> | ||
| </div> | ||
|
|
||
| <button | ||
| className="font-pretendard h-[14px] w-[41px] text-right text-[12px] font-normal leading-[14px] -tracking-wide text-gray-600 underline decoration-solid" | ||
| onClick={() => window.open("약관 URL", "_blank")} | ||
| > | ||
| 전체보기 | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className="flex h-[28px] items-center justify-between gap-[6px]"> | ||
| <div className="flex items-center gap-[6px]"> | ||
| <AgreementCheckbox | ||
| checked={checkState.privacy} | ||
| onChange={() => handleSingleCheck("privacy")} | ||
| CheckedIcon={CheckedItemIcon} | ||
| UncheckedIcon={UncheckedItemIcon} | ||
| /> | ||
| <span className="text-[14px] font-medium text-[#3CC360]"> | ||
| [필수] | ||
| </span> | ||
| <label className="text-[14px] font-medium text-gray-700"> | ||
| 개인정보 처리방침 | ||
| </label> | ||
| </div> | ||
|
|
||
| <button | ||
| className="font-pretendard h-[14px] w-[41px] text-right text-[12px] font-normal leading-[14px] -tracking-wide text-gray-600 underline decoration-solid" | ||
| onClick={() => window.open("약관 URL", "_blank")} | ||
| > | ||
| 전체보기 | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <button | ||
| disabled={!checkState.all} | ||
| onClick={handleSubmit} | ||
| className={`fixed bottom-6 ml-[20px] flex h-[56px] w-[335px] items-center justify-center rounded-[8px] py-[10px] text-[16px] font-semibold leading-[20px] ${ | ||
| !checkState.all | ||
| ? "cursor-pointer bg-[#3CC360] text-white" | ||
| : "cursor-not-allowed bg-gray-300 text-gray-500" | ||
| }`} | ||
| > | ||
| 다음 | ||
| </button> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Agreement; |
This file contains hidden or 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,81 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| import { postPhoneNumber } from "@/features/auth/api/auth"; | ||
| import { useNavigate } from "react-router"; | ||
|
|
||
| import { paths } from "@/config/paths"; | ||
|
|
||
| const PhoneNumber = () => { | ||
| const navigate = useNavigate(); | ||
|
|
||
| const [phoneNumber, setPhoneNumber] = useState<string>(""); | ||
| const [isButtonEnabled, setIsButtonEnabled] = useState<boolean>(false); | ||
|
|
||
| const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const input = e.target.value; | ||
| setPhoneNumber(input); | ||
| setIsButtonEnabled(input.length === 8); | ||
| }; | ||
|
|
||
| const handleSubmit = async () => { | ||
| try { | ||
| const response = await postPhoneNumber({ | ||
| data: { phoneNumber } | ||
| }); | ||
|
|
||
| if (response.data.success) { | ||
| navigate(paths.home.path); | ||
| } else { | ||
| throw new Error("약관 동의에 실패했습니다."); | ||
| } | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col items-start space-y-6 p-4"> | ||
| <div className="mt-[24px]"> | ||
| <h2 className="font-[Pretendard] text-[20px] font-medium leading-[24px] tracking-[-2.5%] text-gray-800"> | ||
| 리워드 전달을 위해 | ||
| </h2> | ||
| <h2 className="inline font-[Pretendard] text-[24px] font-semibold leading-[28.8px] tracking-[-2.5%] text-gray-800"> | ||
| 휴대폰 번호 | ||
| </h2> | ||
| <h2 className="inline font-[Pretendard] text-[20px] font-medium leading-[24px] tracking-[-2.5%] text-gray-800"> | ||
| 를 입력해주세요. | ||
| </h2> | ||
| </div> | ||
|
|
||
| <div className="mt-[213px] flex items-center gap-[10px]"> | ||
| <span className="h-[26px] w-[40px] font-[Pretendard] text-[24px] font-medium leading-[26px] tracking-[-2.5%] text-gray-700"> | ||
| 010 | ||
| </span> | ||
| <input | ||
| type="tel" | ||
| maxLength={11} | ||
| placeholder="숫자만 입력" | ||
| inputMode="numeric" | ||
| className="h-[44px] w-[285px] border-0 border-b border-b-[#BDBDBD] text-center focus:outline-none" | ||
| onChange={handleInputChange} | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="mt-[10px]"> | ||
| <button | ||
| onClick={handleSubmit} | ||
| disabled={!isButtonEnabled} | ||
| className={`h-[56px] w-[335px] justify-between rounded-[8px] p-[10px] text-lg font-semibold text-white ${ | ||
| isButtonEnabled | ||
| ? "bg-[#3CC360] text-white" | ||
| : "bg-[#E0E0E0] text-gray-400" | ||
| }`} | ||
| > | ||
| 완료 | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default PhoneNumber; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.