Skip to content

Commit

Permalink
Merge pull request #141 from softeerbootcamp4th/feat/#140-main-error
Browse files Browse the repository at this point in the history
[Fix] 메인 페이지 오류 수정
  • Loading branch information
jhj2713 authored Aug 13, 2024
2 parents 00aceac + e80ceda commit 0542086
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
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>
);
}

0 comments on commit 0542086

Please sign in to comment.