import { User } from "@prisma/client" import { default as useSWR } from "swr" import { FestaIcon } from "./fontawesome" import style from "./user.module.css" import mood from "../../../styles/mood.module.css" import cursor from "../../../styles/cursor.module.css" import classNames from "classnames" import { faAsterisk, faExclamationCircle } from "@fortawesome/free-solid-svg-icons" import { AxiosError } from "axios" export type FestaUserRendererProps = { userId: User["id"], fallbackData?: User } export const FestaUserRenderer = ({ userId, fallbackData }: FestaUserRendererProps) => { const { data, error } = useSWR(`/api/users/${userId}`, { fallbackData, revalidateOnFocus: false, revalidateOnReconnect: false, revalidateOnMount: fallbackData === undefined }) if (error) { return ( {userId} ) } if (!data) { return ( {userId} ) } const avatarURL = data!.displayAvatarURL const avatar = avatarURL ? :
const name = {data?.displayName} return ( {avatar} {name} ) }