Skip to content

Commit

Permalink
Add documents prop to Form type, to store mapping of form field ID to…
Browse files Browse the repository at this point in the history
… document ID.
  • Loading branch information
danielnaab committed Jan 12, 2024
1 parent 14230f3 commit 621b3be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/spotlight/src/components/react/form/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FormProvider, useForm } from 'react-hook-form';
import { Prompt, createFormContext, createPrompt } from '@atj/forms';
import { getFormFromStorage } from '../../../lib/form-repo';
import { PromptSegment } from './prompts';
import { fillPDF } from '@atj/documents';

// Assuming this is the structure of your JSON data
export interface Field {
Expand Down Expand Up @@ -31,7 +32,12 @@ export const FormView = ({ prompt }: { prompt: Prompt }) => {
const formMethods = useForm<Record<string, string>>({});
return (
<FormProvider {...formMethods}>
<form>
<form
onSubmit={formMethods.handleSubmit(async data => {
console.log(data);
//fillPDF();
})}
>
<fieldset className="usa-fieldset">
{prompt.map((promptPart, index) => (
<PromptSegment key={index} promptPart={promptPart}></PromptSegment>
Expand Down
5 changes: 5 additions & 0 deletions packages/forms/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export type Form<T extends FormStrategy = SequentialStrategy> = {
summary: FormSummary;
questions: Record<QuestionId, Question>;
strategy: T;
documents: {
path: string;
fieldMap: Record<string, string>;
}[];
};

export type FormContext<T extends FormStrategy> = {
Expand Down Expand Up @@ -55,6 +59,7 @@ export const createForm = (
return question.id;
}),
},
documents: [],
};
};

Expand Down

0 comments on commit 621b3be

Please sign in to comment.