'use client'; import 'react-loading-skeleton/dist/skeleton.css'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faSpinner, faCheckCircle, faXmarkCircle } from "@fortawesome/free-solid-svg-icons"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { updateIsUsernamePublic } from "./hooks/updateIsUsernamePublic"; import ProtectedRoute from "../components/protected-route"; import VibrateTest from "../components/vibrate-test"; import { useSession } from "next-auth/react" import { LoginButton, LogoutButton } from "../components/auth-buttons"; import Skeleton, { SkeletonTheme } from 'react-loading-skeleton'; export default function Page() { const queryClient = useQueryClient() // const sessionContext = Session.useSessionContext() // if (sessionContext.loading) { // return // } const session = useSession() const metadataMutation = useMutation({ mutationFn: updateIsUsernamePublic, mutationKey: ['user/metadata'], onSuccess: () => queryClient.invalidateQueries({ queryKey: ['user/metadata'] }) }) // const metadataQuery = useQuery({ // queryKey: ['user/metadata'], // queryFn: () => fetchMetadata() // }) // const [ isUsernamePublic, setIsUsernamePublic ] = useState() // const [ username, setUsername ] = useState('') // useEffect(() => { // if (metadataQuery.data?.metadata) { // setUsername(formatPatronUsername(metadataQuery.data.metadata.first_name, metadataQuery.data.metadata.last_name)) // setIsUsernamePublic(metadataQuery.data.metadata.isUsernamePublic) // } // }, [metadataQuery.data]) const isUsernamePublic = (session.data?.profile?.username_visibility === 'public') return (
{/* {(metadataQuery.isPending) && } */}

Debug section

{/* {(metadataQuery.isPending) ? isPending=true : isPending=false} */} {/*

metadataQuery as follows

*/} {/*
{JSON.stringify(metadataQuery.data, null, 2)}
*/}

session as follows

{JSON.stringify(session, null, 2)}
{(session.status === 'unauthenticated') && }
{(session.data?.user) &&

Profile

{/*

{username}

*/}

{session.data?.user?.name}

Patron Perks

Test Perk (not real)

Hey look at you, you're granted access to this perk!

Website Shoutout

Display {(!!session.data.user.name) ? session.data.user.name : } publicly? metadataMutation.mutate({ isUsernamePublic: evt.target.checked })}/> {(metadataMutation.status === 'success') && } {(metadataMutation.status === 'pending') && } {(metadataMutation.status === 'error') && }

Premium Content Delivery Network (CDN1)

You have access to Futureporn's Premium CDN for reliable video playback

Economy Content Delivery Network (CDN2)

You have access to Futureporn's Economy CDN for basic video playback

Vibrate (test)

}
) // if (metadataQuery.isPending) return ; // return
{JSON.stringify(metadataQuery.data, null, 2)}
// return

@todo

// if (!isPending) return ; // if (!data) return

there is no data

; // if (!data?.metadata) return

there is no data.metadata

; // const { first_name, last_name } = data.metadata // const username = formatPatronUsername(first_name, last_name) // const { metadata } = data || {} // const { isUsernamePublic } = metadata // return ( // <> //
//
//

Profile

//
//
Username
//

// {isPending && // // // // } // {!isPending &&

{username}

} //

//
//
//
User ID
//
//

{sessionContext.userId}

//
//
//

Patron Perks

//

Website Shoutout

// //
// Display {(!!username) ? username : } publicly? // metadataMutation.mutate({ isUsernamePublic: evt.target.checked })}/> // {(metadataMutation.status === 'success') && } // {(metadataMutation.status === 'pending') && } // {(metadataMutation.status === 'error') && } //
//
//

Content Delivery Network (CDN)

// //

You have access to Futureporn's CDN for reliable video playback

//
//

Vibrate (test)

// //
//
// // ) }