-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
31 additions
and
14 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 |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import ClientLaunchEmojicoinPage from "../../components/pages/launch-emojicoin/ClientLaunchEmojicoinPage"; | ||
import { isUserGeoblocked } from "utils/geolocation"; | ||
import { headers } from "next/headers"; | ||
import { type Metadata } from "next"; | ||
import { emoji } from "utils"; | ||
|
||
export const dynamic = "force-static"; | ||
|
||
export const metadata: Metadata = { | ||
title: "launch", | ||
description: `Launch your own emojicoins using emojicoin.fun ${emoji("party popper")}`, | ||
}; | ||
|
||
export default async function LaunchEmojicoinPage() { | ||
const geoblocked = await isUserGeoblocked(headers().get("x-real-ip")); | ||
return <ClientLaunchEmojicoinPage geoblocked={geoblocked} />; | ||
return <ClientLaunchEmojicoinPage />; | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/typescript/frontend/src/hooks/use-is-user-geoblocked.ts
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,15 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { isUserGeoblockedServerAction } from "utils/server/geoblocked"; | ||
|
||
const useIsUserGeoblocked = () => { | ||
const { data } = useQuery({ | ||
queryKey: ["geoblocked"], | ||
queryFn: () => isUserGeoblockedServerAction(), | ||
staleTime: Infinity, | ||
}); | ||
|
||
// Assume the user is geoblocked if the response hasn't completed yet. | ||
return data ?? true; | ||
}; | ||
|
||
export default useIsUserGeoblocked; |
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,8 @@ | ||
"use server"; | ||
|
||
import { headers } from "next/headers"; | ||
import { isUserGeoblocked } from "utils/geolocation"; | ||
|
||
export async function isUserGeoblockedServerAction() { | ||
return await isUserGeoblocked(headers().get("x-real-ip")); | ||
} |