Skip to content
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

[Fix] 메인 페이지 오류 수정 #141

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/constants/cookie.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const COOKIE_KEY = {
ACCESS_TOKEN: "token",
INVITE_USER: "referrerId",
INVITE_USER: "referralId",
} as const;
8 changes: 4 additions & 4 deletions client/src/features/CasperCustom/CasperCustomForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export function CasperCustomForm({ navigateNextStep }: CasperCustomFormProps) {
fetchData: postCasper,
} = useFetch<
PostCasperResponse,
{ token: string; referrerId: string; casper: CasperInformationType }
>(({ token, referrerId, casper }) =>
LotteryAPI.postCasper(token, { ...casper, [COOKIE_KEY.INVITE_USER]: referrerId })
{ token: string; referralId: string; casper: CasperInformationType }
>(({ token, referralId, casper }) =>
LotteryAPI.postCasper(token, { ...casper, [COOKIE_KEY.INVITE_USER]: referralId })
);

const { casperName, expectations, selectedCasperIdx } = useCasperCustomStateContext();
Expand Down Expand Up @@ -85,7 +85,7 @@ export function CasperCustomForm({ navigateNextStep }: CasperCustomFormProps) {

await postCasper({
token: cookies[COOKIE_KEY.ACCESS_TOKEN],
referrerId: cookies[COOKIE_KEY.INVITE_USER],
referralId: cookies[COOKIE_KEY.INVITE_USER],
casper,
});
};
Expand Down
3 changes: 3 additions & 0 deletions client/src/hooks/useFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default function useFetch<T, P = void>(fetch: (params: P) => Promise<T>)
const { showBoundary } = useErrorBoundary();

const fetchData = async (params?: P) => {
setIsError(false);
setIsSuccess(false);

try {
const data = await fetch(params as P);
setData(data);
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/ErrorElement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ interface ErrorElementProps {
}

export default function ErrorElement({ fallbackUrl = "/" }: ErrorElementProps) {
const handleClickButton = () => {
window.location.href = fallbackUrl;
};

return (
<div className="fixed z-10 h-screen w-full bg-n-neutral-950 flex flex-col justify-center items-center">
<img alt="오류 아이콘" src="/assets/icons/casper-error.svg" />
Expand All @@ -13,7 +17,7 @@ export default function ErrorElement({ fallbackUrl = "/" }: ErrorElementProps) {
문제가 발생했습니다. 잠시 후 다시 시도해 보세요.
</h3>
<div className="mt-12" />
<CTAButton label="돌아가기" url={fallbackUrl} hasArrowIcon />
<CTAButton label="돌아가기" hasArrowIcon onClick={handleClickButton} />
</div>
);
}
Loading