diff --git a/apps/desktop/layer/renderer/src/modules/profile/email-management.tsx b/apps/desktop/layer/renderer/src/modules/profile/email-management.tsx index 4456411b8..20a2d6612 100644 --- a/apps/desktop/layer/renderer/src/modules/profile/email-management.tsx +++ b/apps/desktop/layer/renderer/src/modules/profile/email-management.tsx @@ -59,43 +59,45 @@ export function EmailManagement() { {user?.emailVerified ? t("profile.email.verified") : t("profile.email.unverified")} -

- {user?.email} +

+
+ {user?.email} - } - className="size-5 p-1" - variant="ghost" - onClick={() => { - present({ - title: t("profile.email.change"), - content: EmailManagementForm, - }) - }} - /> - {user?.email && ( - } + className="size-5 p-1" + variant="ghost" + onClick={() => { + present({ + title: t("profile.email.change"), + content: EmailManagementForm, + }) + }} /> + {user?.email && ( + + )} +
+ {!user?.emailVerified && ( + )} -

- {!user?.emailVerified && ( - - )} +
) } diff --git a/apps/desktop/layer/renderer/src/modules/profile/profile-setting-form.tsx b/apps/desktop/layer/renderer/src/modules/profile/profile-setting-form.tsx index f7d6cd7a6..580ad38b7 100644 --- a/apps/desktop/layer/renderer/src/modules/profile/profile-setting-form.tsx +++ b/apps/desktop/layer/renderer/src/modules/profile/profile-setting-form.tsx @@ -9,7 +9,7 @@ import { FormLabel, FormMessage, } from "@follow/components/ui/form/index.jsx" -import { Input } from "@follow/components/ui/input/index.js" +import { Input, TextArea } from "@follow/components/ui/input/index.js" import { cn } from "@follow/utils/utils" import { zodResolver } from "@hookform/resolvers/zod" import { useMutation } from "@tanstack/react-query" @@ -22,12 +22,57 @@ import { setWhoami, useWhoami } from "~/atoms/user" import { updateUser } from "~/lib/auth" import { toastFetchError } from "~/lib/error-parser" +const socialLinksSchema = z.object({ + twitter: z.string().max(64).optional(), + github: z.string().max(64).optional(), + instagram: z.string().max(64).optional(), + facebook: z.string().max(64).optional(), + youtube: z.string().max(64).optional(), + discord: z.string().max(64).optional(), +}) + const formSchema = z.object({ handle: z.string().max(50).optional(), name: z.string().min(3).max(50), image: z.string().url().or(z.literal("")).optional(), + bio: z.string().max(256).optional(), + website: z.string().url().max(64).optional().or(z.literal("")), + socialLinks: socialLinksSchema.optional(), }) +const socialIconClassNames = { + twitter: "i-mgc-twitter-cute-fi", + github: "i-mgc-github-cute-fi", + instagram: "i-mingcute-ins-fill", + facebook: "i-mingcute-facebook-fill", + youtube: "i-mgc-youtube-cute-fi", + discord: "i-mingcute-discord-fill", +} + +const formItemLabelClassName = tw`pl-3` +// Extended user type to include the new fields +type ExtendedUser = ReturnType & { + bio?: string + website?: string + socialLinks?: { + twitter?: string + github?: string + instagram?: string + facebook?: string + youtube?: string + discord?: string + } +} + +const socialCopyMap = { + twitter: "Twitter", + github: "GitHub", + instagram: "Instagram", + facebook: "Facebook", + youtube: "YouTube", + discord: "Discord", +} + export const ProfileSettingForm = ({ className, buttonClassName, @@ -36,7 +81,7 @@ export const ProfileSettingForm = ({ buttonClassName?: string }) => { const { t } = useTranslation("settings") - const user = useWhoami() + const user = useWhoami() as ExtendedUser const form = useForm>({ resolver: zodResolver(formSchema), @@ -44,6 +89,16 @@ export const ProfileSettingForm = ({ handle: user?.handle || undefined, name: user?.name || "", image: user?.image || "", + bio: user?.bio || "", + website: user?.website || "", + socialLinks: { + twitter: user?.socialLinks?.twitter || "", + github: user?.socialLinks?.github || "", + instagram: user?.socialLinks?.instagram || "", + facebook: user?.socialLinks?.facebook || "", + youtube: user?.socialLinks?.youtube || "", + discord: user?.socialLinks?.discord || "", + }, }, }) @@ -53,6 +108,10 @@ export const ProfileSettingForm = ({ handle: values.handle, image: values.image, name: values.name, + // @ts-expect-error + bio: values.bio, + website: values.website, + socialLinks: values.socialLinks, }), onError: (error) => { toastFetchError(error) @@ -71,6 +130,15 @@ export const ProfileSettingForm = ({ updateMutation.mutate(values) } + const socialLinkFields: (keyof z.infer)[] = [ + "twitter", + "github", + "instagram", + "facebook", + "youtube", + "discord", + ] + return (
@@ -79,7 +147,7 @@ export const ProfileSettingForm = ({ name="handle" render={({ field }) => ( - {t("profile.handle.label")} + {t("profile.handle.label")} @@ -93,7 +161,7 @@ export const ProfileSettingForm = ({ name="name" render={({ field }) => ( - {t("profile.name.label")} + {t("profile.name.label")} @@ -109,7 +177,9 @@ export const ProfileSettingForm = ({ render={({ field }) => (
- {t("profile.avatar.label")} + + {t("profile.avatar.label")} +
@@ -127,6 +197,78 @@ export const ProfileSettingForm = ({ )} /> + ( + + {t("profile.profile.bio")} + +