From ec0a595d44f910955f5ed64fa248061e29ca3f85 Mon Sep 17 00:00:00 2001 From: Wilson Wong Date: Fri, 24 May 2024 17:59:17 -0700 Subject: [PATCH 1/3] Functionality to search OrgBook API for organization names --- .../src/components/intake/ShasIntakeForm.vue | 41 +++++++++++++++---- frontend/src/services/index.ts | 1 + frontend/src/services/orgBookService.ts | 17 ++++++++ frontend/src/utils/constants.ts | 2 + 4 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 frontend/src/services/orgBookService.ts diff --git a/frontend/src/components/intake/ShasIntakeForm.vue b/frontend/src/components/intake/ShasIntakeForm.vue index 42f46f19..81556f32 100644 --- a/frontend/src/components/intake/ShasIntakeForm.vue +++ b/frontend/src/components/intake/ShasIntakeForm.vue @@ -4,6 +4,8 @@ import { Form, FieldArray, ErrorMessage } from 'vee-validate'; import { onBeforeMount, ref } from 'vue'; import FileUpload from '@/components/file/FileUpload.vue'; +import { EditableDropdown } from '@/components/form'; + import { Calendar, Checkbox, @@ -29,7 +31,7 @@ import { useConfirm, useToast } from '@/lib/primevue'; -import { permitService, submissionService } from '@/services'; +import { orgBookService, permitService, submissionService } from '@/services'; import { useTypeStore } from '@/store'; import { ContactPreferenceList, @@ -42,6 +44,7 @@ import { } from '@/utils/constants'; import { BASIC_RESPONSES, INTAKE_FORM_CATEGORIES, PROJECT_LOCATION } from '@/utils/enums'; +import type { IInputEvent } from '@/interfaces'; import type { Ref } from 'vue'; // Props @@ -71,6 +74,7 @@ const formRef: Ref | null> = ref(null); const geomarkAccordionIndex: Ref = ref(undefined); const isSubmittable: Ref = ref(false); const initialFormValues: Ref = ref(undefined); +const orgBookOptions: Ref> = ref([]); const parcelAccordionIndex: Ref = ref(undefined); const spacialAccordionIndex: Ref = ref(undefined); const validationErrors: Ref = ref([]); @@ -161,6 +165,21 @@ async function onSubmit(data: any) { } } +const onRegisteredNameInput = async (e: IInputEvent) => { + const input = e.target.value; + + if (input.length >= 3) { + const results = (await orgBookService.searchOrgBook(input))?.data?.results ?? []; + orgBookOptions.value = results.map((x: { [key: string]: string }) => x?.value); + } else { + orgBookOptions.value = []; + } +}; + +const getRegisteredNameLabel = (e: any) => { + return e; +}; + onBeforeMount(async () => { let response; if (props.activityId) { @@ -189,6 +208,7 @@ onBeforeMount(async () => {