-
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 branch 'main' of https://github.com/GAMZA-BAT/algohub-client in…
…to fix#308/reduce-api-call
- Loading branch information
Showing
12 changed files
with
95 additions
and
30 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
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,19 @@ | ||
import { loginAlertModalAtom } from "@/shared/store/alertModal"; | ||
import { useSetAtom } from "jotai"; | ||
import { useSession } from "next-auth/react"; | ||
import Link from "next/link"; | ||
import type { ComponentProps, MouseEvent } from "react"; | ||
|
||
const ProtectedLink = (props: ComponentProps<typeof Link>) => { | ||
const handleShowModal = useSetAtom(loginAlertModalAtom); | ||
const { status: authStatus } = useSession(); | ||
const handleClick = (e: MouseEvent) => { | ||
if (authStatus === "unauthenticated") { | ||
e.preventDefault(); | ||
handleShowModal(true); | ||
} | ||
}; | ||
return <Link {...props} onClick={handleClick} />; | ||
}; | ||
|
||
export default ProtectedLink; |
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,3 @@ | ||
import { atom } from "jotai"; | ||
|
||
export const loginAlertModalAtom = atom(false); |
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 @@ | ||
export const isHTTPError = ( | ||
error: unknown, | ||
): error is { response: { status: number } } => { | ||
return ( | ||
typeof error === "object" && | ||
error !== null && | ||
"response" in error && | ||
error.response !== null && | ||
typeof error.response === "object" && | ||
"status" in error.response | ||
); | ||
}; |
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
12 changes: 12 additions & 0 deletions
12
src/view/user/index/GroupCard/LoginAlertModalController.tsx
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 @@ | ||
"use client"; | ||
|
||
import LoginAlertModal from "@/shared/component/LoginAlertModal"; | ||
import { loginAlertModalAtom } from "@/shared/store/alertModal"; | ||
import { useAtom } from "jotai"; | ||
|
||
const LoginAlertModalController = () => { | ||
const [isOpen, setIsOpen] = useAtom(loginAlertModalAtom); | ||
return <LoginAlertModal isOpen={isOpen} onClose={() => setIsOpen(false)} />; | ||
}; | ||
|
||
export default LoginAlertModalController; |
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