From 728ac418aedf5c40a492b8449bf052fd52a00401 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Mon, 24 Nov 2025 03:28:52 -0800 Subject: [PATCH] feat: add description field to profiles and update related components for enhanced profile management --- convex/profiles.ts | 4 ++ convex/schema.ts | 1 + src/App.tsx | 5 ++ src/components/ProfileEditor.tsx | 51 +++++++++++++---- src/pages/Dashboard.tsx | 33 +++++------ src/pages/LandingPage.tsx | 3 + src/pages/ProfileDetail.tsx | 5 -- src/pages/ProfileEditorPage.tsx | 86 ++++++++++++++++++++++++++++ src/pages/ProfileFlash.tsx | 97 ++++++++++++++++++++++++++------ 9 files changed, 232 insertions(+), 53 deletions(-) create mode 100644 src/pages/ProfileEditorPage.tsx diff --git a/convex/profiles.ts b/convex/profiles.ts index 35d792f..1ebe09d 100644 --- a/convex/profiles.ts +++ b/convex/profiles.ts @@ -115,6 +115,7 @@ export const getFlashCount = query({ export const create = mutation({ args: { name: v.string(), + description: v.string(), targets: v.optional(v.array(v.string())), config: v.any(), version: v.string(), @@ -127,6 +128,7 @@ export const create = mutation({ const profileId = await ctx.db.insert('profiles', { userId, name: args.name, + description: args.description, config: args.config, version: args.version, updatedAt: Date.now(), @@ -144,6 +146,7 @@ export const update = mutation({ args: { id: v.id('profiles'), name: v.string(), + description: v.string(), targets: v.optional(v.array(v.string())), config: v.any(), version: v.optional(v.string()), @@ -161,6 +164,7 @@ export const update = mutation({ // Update profile await ctx.db.patch(args.id, { name: args.name, + description: args.description, config: args.config, version: args.version, isPublic: args.isPublic, diff --git a/convex/schema.ts b/convex/schema.ts index a5c9dd6..8934f32 100644 --- a/convex/schema.ts +++ b/convex/schema.ts @@ -7,6 +7,7 @@ export default defineSchema({ profiles: defineTable({ userId: v.id('users'), name: v.string(), + description: v.string(), config: v.any(), // JSON object for flags version: v.string(), updatedAt: v.number(), diff --git a/src/App.tsx b/src/App.tsx index e82604e..d61c870 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import BuildDetail from './pages/BuildDetail' import Dashboard from './pages/Dashboard' import LandingPage from './pages/LandingPage' import ProfileDetail from './pages/ProfileDetail' +import ProfileEditorPage from './pages/ProfileEditorPage' import ProfileFlash from './pages/ProfileFlash' function App() { @@ -37,6 +38,10 @@ function App() { } /> } /> } /> + } + /> } /> version: string isPublic: boolean @@ -30,21 +31,28 @@ export default function ProfileEditor({ const createProfile = useMutation(api.profiles.create) const updateProfile = useMutation(api.profiles.update) - const { register, handleSubmit, setValue, watch } = - useForm({ - defaultValues: { - name: initialData?.name || '', - config: initialData?.config || {}, - version: initialData?.version || VERSIONS[0], - isPublic: initialData?.isPublic ?? true, - }, - }) + const { + register, + handleSubmit, + setValue, + watch, + formState: { errors }, + } = useForm({ + defaultValues: { + name: initialData?.name || '', + description: initialData?.description || '', + config: initialData?.config || {}, + version: initialData?.version || VERSIONS[0], + isPublic: initialData?.isPublic ?? true, + }, + }) const onSubmit = async (data: ProfileFormValues) => { if (initialData?._id) { await updateProfile({ id: initialData._id, name: data.name, + description: data.description, config: data.config, version: data.version, isPublic: data.isPublic, @@ -52,6 +60,7 @@ export default function ProfileEditor({ } else { await createProfile({ name: data.name, + description: data.description, config: data.config, version: data.version, isPublic: data.isPublic, @@ -72,10 +81,13 @@ export default function ProfileEditor({ + {errors.name && ( +

{errors.name.message}

+ )}
+
+ +