From 8c0847b8f99719e232910b9bdd390ce741f72cb8 Mon Sep 17 00:00:00 2001 From: Kevin Foong <55353265+kevin9foong@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:32:51 +0800 Subject: [PATCH] feat: add text prompt selector to popover --- .../MagicFormBuilderContainer.tsx | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/FieldListDrawer/MagicFormBuilderContainer.tsx b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/FieldListDrawer/MagicFormBuilderContainer.tsx index 73ce2d302a..4d446c3531 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/FieldListDrawer/MagicFormBuilderContainer.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/FieldListDrawer/MagicFormBuilderContainer.tsx @@ -3,9 +3,11 @@ import { useForm } from 'react-hook-form' import { BiSolidMagicWand, BiTrash } from 'react-icons/bi' import { HiSparkles } from 'react-icons/hi2' import { + Box, Button, Flex, FormControl, + HStack, Icon, Popover, PopoverAnchor, @@ -18,6 +20,7 @@ import { Text, Textarea, Tooltip, + VStack, } from '@chakra-ui/react' import { BxCheck } from '~/assets/icons' @@ -33,6 +36,24 @@ import { useMagicFormBuilderStore, } from '../../useMagicFormBuilderStore' +const TEXT_PROMPT_IDEAS = [ + { + label: 'Employee satisfaction survey', + prompt: + 'employee feedback on workplace satisfaction, including fields on overall job satisfaction, suggestions for improvement, and comments on company culture.', + }, + { + label: 'Community issue reports', + prompt: + 'community issue reports from citizens, including fields for location, description of the issue, and optional photo uploads.', + }, + { + label: 'Government grant applications', + prompt: + 'applications for government grants from business entities, incorporating sections for project details, budget breakdown, and applicant qualifications.', + }, +] + const GENERATE_FORM_PLACEHOLDER = 'Describe form, fields and sections to create...' @@ -69,6 +90,42 @@ const MagicFormBuilderButton = ({ ) } +const PromptSelectorBar = ({ + promptIdeas, + onClick, +}: { + promptIdeas: { + label: string + prompt: string + }[] + onClick: (prompt: string) => void +}) => { + return ( + + Or, try a sample: + + {promptIdeas.map((idea) => ( + + ))} + + + ) +} + const MagicFormBuilderCreateFormPrompt = ({ onClose, }: { @@ -77,6 +134,7 @@ const MagicFormBuilderCreateFormPrompt = ({ const { register, handleSubmit, + setValue, formState: { errors }, } = useForm() @@ -93,19 +151,25 @@ const MagicFormBuilderCreateFormPrompt = ({ - +