diff --git a/app/people/ProfileVisibilityPrefs.tsx b/app/people/ProfileVisibilityPrefs.tsx new file mode 100644 index 00000000..510cc19b --- /dev/null +++ b/app/people/ProfileVisibilityPrefs.tsx @@ -0,0 +1,94 @@ +"use client"; + +import { signIn, useSession } from "next-auth/react"; + +import { usePatchedJSONResource } from "~/components/hooks/resource"; +import { type UserProfile } from "~/src/data/user-profile"; +import { setFlag } from "~/src/flags"; +import { Route } from "~/src/routing"; + +export const ProfileVisibilityPrefs = () => { + const { status: sessionStatus } = useSession(); + return ( +
+ {sessionStatus === "loading" && } + {sessionStatus === "authenticated" && } + {sessionStatus === "unauthenticated" && } +
+ ); +}; + +const Note = ({ children }: { children: React.ReactNode }) => ( +

{children}

+); + +const ProfileVisibilityButton = () => { + const { + model: model, + updating, + setModel, + } = usePatchedJSONResource({ + url: "/account/me", + writeKeys: ["privacyFlags"], + }); + + return ( +
+ + Může pár minut trvat, než se tato změna projeví. +
+ ); +}; + +const LoadingSpinner = () => ( + <> +
+ Načítám… +
+ Načítám… + +); + +const SignedOutText = () => ( + <> +
+ Tip:{" "} + { + e.preventDefault(); + return signIn(); + }} + > + Když se přihlásíš + + , můžeš tady zveřejnit svůj profil. +
+ + + Nebo si založ nový účet + + , pokud žádný nemáš. + + +); diff --git a/app/people/page.tsx b/app/people/page.tsx index 3c9a9694..8173f70d 100644 --- a/app/people/page.tsx +++ b/app/people/page.tsx @@ -2,6 +2,7 @@ import { Suspense } from "react"; import { type Metadata } from "next"; import { stripNonPublicFields } from "~/app/people/matching"; +import { ProfileVisibilityPrefs } from "~/app/people/ProfileVisibilityPrefs"; import { SearchablePeopleBox } from "~/app/people/SearchablePeopleBox"; import { Breadcrumbs } from "~/components/Breadcrumbs"; import { getAllUserProfiles } from "~/src/data/user-profile"; @@ -21,11 +22,13 @@ export const metadata: Metadata = { async function Page() { const profiles = await getAllUserProfiles("Public Profiles"); const strippedProfiles = profiles.map(stripNonPublicFields); + return (

Lidé

-

{metadata.description}

+

{metadata.description}

+