-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from depromeet/feat/setting
οΏ½feat: setting νμ΄μ§ λ§ν¬μ λ° κΈ°λ₯(λͺ©ν 거리 μμ / νν΄ / λ‘κ·Έμμ)μ ꡬννμ΅λλ€.
- Loading branch information
Showing
34 changed files
with
1,019 additions
and
19 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
import { fetchData } from '@/apis/fetch-data'; | ||
|
||
export type goalProps = { | ||
goal: number; | ||
}; | ||
|
||
export async function PATCH(request: NextRequest) { | ||
try { | ||
const { goal } = (await request.json()) as goalProps; | ||
const data = await fetchData(`/goal`, 'PATCH', { goal }); | ||
|
||
return NextResponse.json(data); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: 'Failed to update goal' }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
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,12 @@ | ||
import { cookies } from 'next/headers'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { fetchData } from '@/apis/fetch-data'; | ||
|
||
export async function GET() { | ||
const data = await fetchData(`/logout`, 'GET'); | ||
cookies().delete('accessToken'); | ||
cookies().delete('refreshToken'); | ||
|
||
return NextResponse.json(data); | ||
} |
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,55 @@ | ||
'use client'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { LoadingArea } from '@/components/atoms'; | ||
import { BackButton, HeaderBar } from '@/components/molecules'; | ||
import { useMemberData } from '@/features/setting/apis'; | ||
import { SettingCalendar } from '@/features/setting/components'; | ||
import { useSaveDialogHandler } from '@/features/setting/hooks'; | ||
|
||
export default function Page() { | ||
const router = useRouter(); | ||
const { data, error } = useMemberData(); | ||
const { openSaveModal } = useSaveDialogHandler(); | ||
|
||
const [selectedDistance, setSelectedDistance] = useState<number | null>(null); | ||
|
||
useEffect(() => { | ||
if (data) { | ||
setSelectedDistance(data.data.goal); | ||
} | ||
}, [data]); | ||
|
||
if (!data) return <LoadingArea />; | ||
if (error) return console.log(error); | ||
|
||
const handleDistanceChange = (distance: number) => { | ||
setSelectedDistance(distance); | ||
}; | ||
|
||
const backButton = () => { | ||
if (data.data.goal !== selectedDistance) { | ||
openSaveModal(); | ||
} else { | ||
router.push('/setting'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<HeaderBar> | ||
<HeaderBar.LeftContent> | ||
<BackButton onClickBack={backButton} /> | ||
</HeaderBar.LeftContent> | ||
<HeaderBar.Title>κΈ°λ‘ μκ°ν κΈ°μ€ κ±°λ¦¬</HeaderBar.Title> | ||
</HeaderBar> | ||
<SettingCalendar | ||
goal={data.data.goal} | ||
selectedDistance={selectedDistance} | ||
onDistanceChange={handleDistanceChange} | ||
/> | ||
</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,51 @@ | ||
'use client'; | ||
|
||
import { useRouter, useSearchParams } from 'next/navigation'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { BackButton, HeaderBar } from '@/components/molecules'; | ||
import { Step1 } from '@/features/setting/components'; | ||
import { Step2 } from '@/features/setting/components'; | ||
import { Step3 } from '@/features/setting/components'; | ||
|
||
export default function Page() { | ||
const router = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const [step, setStep] = useState(1); | ||
|
||
useEffect(() => { | ||
const queryStep = searchParams.get('step'); | ||
if (queryStep) { | ||
setStep(Number(queryStep)); | ||
} | ||
}, [searchParams]); | ||
|
||
const handleListItemClick = () => { | ||
setStep(2); | ||
router.push('?step=2'); | ||
}; | ||
|
||
const getStepComponent = (step: number) => { | ||
switch (step) { | ||
case 1: | ||
return <Step1 onClickListItem={handleListItemClick} />; | ||
case 2: | ||
return <Step2 />; | ||
case 3: | ||
return <Step3 />; | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<HeaderBar> | ||
<HeaderBar.LeftContent> | ||
<BackButton /> | ||
</HeaderBar.LeftContent> | ||
</HeaderBar> | ||
{getStepComponent(step)} | ||
</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,16 @@ | ||
import dynamic from 'next/dynamic'; | ||
import React, { Suspense } from 'react'; | ||
|
||
import { LoadingArea } from '@/components/atoms'; | ||
|
||
const StepComponent = dynamic(() => import('./index'), { | ||
suspense: true, | ||
}); | ||
|
||
export default function Page() { | ||
return ( | ||
<Suspense fallback={<LoadingArea />}> | ||
<StepComponent /> | ||
</Suspense> | ||
); | ||
} |
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,101 @@ | ||
'use client'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
|
||
import { LoadingArea } from '@/components/atoms'; | ||
import { NormalShapeIcon } from '@/components/atoms'; | ||
import { Divider } from '@/components/atoms/divider'; | ||
import { BackButton, HeaderBar } from '@/components/molecules'; | ||
import { useLogout, useMemberData } from '@/features/setting/apis'; | ||
import { ListItem } from '@/features/setting/components'; | ||
import { useLogoutDialogHandler } from '@/features/setting/hooks/use-logout-dialog-handler'; | ||
import { css } from '@/styled-system/css'; | ||
import { flex } from '@/styled-system/patterns'; | ||
|
||
export default function Page() { | ||
const logout = useLogout(); | ||
const router = useRouter(); | ||
|
||
const { data, isLoading, error } = useMemberData(); | ||
const { openLogoutModal } = useLogoutDialogHandler(logout); | ||
|
||
if (isLoading) { | ||
return <LoadingArea />; | ||
} | ||
|
||
if (error) { | ||
return <div>Error: {error.message}</div>; | ||
} | ||
|
||
const handleGoToDeleteAccount = () => { | ||
router.push('/delete-account?step=1'); | ||
}; | ||
|
||
// TODO: κ΄λ ¨ νμ΄μ§ μμ νμ | ||
const handleGoToSetting = () => { | ||
// console.log('λΌμ°ν κ²½λ‘ μ§μ νμ'); | ||
}; | ||
|
||
const handleGoToChangeDistance = () => { | ||
router.push('/change-distance'); | ||
}; | ||
|
||
if (isLoading) return <LoadingArea />; | ||
if (error) return console.log(error); | ||
|
||
return ( | ||
<div> | ||
<HeaderBar> | ||
<HeaderBar.LeftContent> | ||
<BackButton onClickBack={() => router.push('/')} /> | ||
</HeaderBar.LeftContent> | ||
<HeaderBar.Title>μ€μ </HeaderBar.Title> | ||
</HeaderBar> | ||
<ListItem | ||
text="κΈ°λ‘ μκ°ν κΈ°μ€ κ±°λ¦¬" | ||
subText="λ¬λ ₯ ν μΉΈμ νμλλ μ΅λ μμ 거리" | ||
distance={`${data?.data.goal.toLocaleString()}m`} | ||
onClick={handleGoToChangeDistance} | ||
> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
<Divider variant="thick" /> | ||
<ListItem text="μλΉμ€ μ΄μ© μ½κ΄" onClick={handleGoToSetting}> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
<ListItem text="κ°μΈμ 보 μ²λ¦¬λ°©μΉ¨" onClick={handleGoToSetting}> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
<ListItem text="μ€νμμ€ λΌμ΄μ μ€" onClick={handleGoToSetting}> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
<Divider variant="thick" /> | ||
<ListItem text="λ‘κ·Έμμ" onClick={openLogoutModal}> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
<ListItem text="νν΄νκΈ°" onClick={handleGoToDeleteAccount}> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
<Divider variant="thick" /> | ||
<ListItem text="μ€μλ―Ένμκ² λ¬ΈμνκΈ°" onClick={handleGoToSetting}> | ||
<NormalShapeIcon /> | ||
</ListItem> | ||
|
||
<div className={dividerStyles}> | ||
<div className={dividerTextStyles}>μ± λ²μ 1.1</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const dividerStyles = flex({ | ||
height: '266px', | ||
backgroundColor: 'line.alternative', | ||
fontWeight: '500', | ||
}); | ||
|
||
const dividerTextStyles = css({ | ||
color: 'text.alternative', | ||
textStyle: 'body2.normal', | ||
padding: '20px 16px', | ||
}); |
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
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,20 @@ | ||
export function NormalShapeIcon() { | ||
return ( | ||
<svg | ||
width="8" | ||
height="16" | ||
viewBox="0 0 8 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<g id="Shape"> | ||
<path | ||
id="Vector" | ||
d="M1.72064 3.05413C1.38218 3.39259 1.38218 3.94133 1.72064 4.27979L5.44114 8.00029L1.72064 11.7208C1.38218 12.0593 1.38218 12.608 1.72064 12.9465C2.05909 13.2849 2.60783 13.2849 2.94629 12.9465L7.27961 8.61312C7.61807 8.27466 7.61807 7.72592 7.27961 7.38747L2.94629 3.05413C2.60783 2.71568 2.05909 2.71568 1.72064 3.05413Z" | ||
fill="#37383C" | ||
fillOpacity="0.61" | ||
/> | ||
</g> | ||
</svg> | ||
); | ||
} |
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
Oops, something went wrong.