Skip to content

Commit

Permalink
fix: 빌드 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
summermong committed Aug 26, 2024
1 parent 1c2d542 commit 92e1503
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 61 deletions.
13 changes: 4 additions & 9 deletions app/api/logout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ import { NextResponse } from 'next/server';
import { fetchData } from '@/apis/fetch-data';

export async function GET() {
try {
const data = await fetchData(`/logout`, 'GET');
cookies().delete('accessToken');
cookies().delete('refreshToken');
const data = await fetchData(`/logout`, 'GET');
cookies().delete('accessToken');
cookies().delete('refreshToken');

return NextResponse.json(data);
} catch (error) {
console.error('Error in DELETE request:', error);
return NextResponse.error();
}
return NextResponse.json(data);
}
10 changes: 2 additions & 8 deletions app/api/member/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ export interface MemberProps {
}

export async function GET() {
try {
const data = await fetchData<MemberProps>('/member', 'GET');
const data = await fetchData<MemberProps>('/member', 'GET');

return NextResponse.json(data);
} catch (error) {
console.error('Error fetching member data:', error);

return NextResponse.error();
}
return NextResponse.json(data);
}
51 changes: 51 additions & 0 deletions app/delete-account/index.tsx
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>
);
}
53 changes: 9 additions & 44 deletions app/delete-account/page.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
'use client';
import dynamic from 'next/dynamic';
import React, { Suspense } from 'react';

import { useRouter, useSearchParams } from 'next/navigation';
import { useEffect, useState } from 'react';
import { LoadingArea } from '@/components/atoms';

import { BackButton, HeaderBar } from '@/components/molecules';
import Step1 from '@/features/setting/components/organisms/step-1';
import Step2 from '@/features/setting/components/organisms/step-2';
import Step3 from '@/features/setting/components/organisms/step-3';
const StepComponent = dynamic(() => import('./index'), {
suspense: true,
});

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 onListItemClick={handleListItemClick} />;
case 2:
return <Step2 />;
case 3:
return <Step3 />;
default:
return null;
}
};

return (
<div>
<HeaderBar>
<HeaderBar.LeftContent>
<BackButton />
</HeaderBar.LeftContent>
</HeaderBar>
{getStepComponent(step)}
</div>
<Suspense fallback={<LoadingArea />}>
<StepComponent />
</Suspense>
);
}

0 comments on commit 92e1503

Please sign in to comment.