From 39896998bcf137ef0b5cef3ae6e25f05da5ee99d Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:51 +0530 Subject: [PATCH] feat: add project select to the asset form --- .../assets/form/project-select-field.tsx | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app/components/assets/form/project-select-field.tsx diff --git a/app/components/assets/form/project-select-field.tsx b/app/components/assets/form/project-select-field.tsx new file mode 100644 index 0000000..d050792 --- /dev/null +++ b/app/components/assets/form/project-select-field.tsx @@ -0,0 +1,35 @@ +import { useFormContext, useWatch } from 'react-hook-form'; +import { ClientLogo } from '~/components/ui/client-logo'; +import { Field } from '~/components/ui/field'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '~/components/ui/select'; +import { NO_PROJECT } from '~/data/assets/constants'; +import { useAdminData } from '~/hooks/admin/use-admin-data'; +import type { AssetFormValues } from '~/schemas/assets/asset-form'; +import { toBrand } from '~/services/asset-media'; + +export function ProjectSelectField() { + const { projects } = useAdminData(); + const { control, setValue } = useFormContext(); + const value = useWatch({ control, name: 'project' }); + // Archived projects are only listed when the asset already belongs to one + const options = projects.filter((project) => project.status === 'active' || project.id === value); + + return ( + + + + ); +}