Skip to content

Commit

Permalink
Use live API on cloud.gov for parsing (#90)
Browse files Browse the repository at this point in the history
* editable stub

* editable stub

* editable stub

* editable stub

* editable stub

* set up api

* set up api

* set up api

* set up api

* Merge jim/api-setup-2 into this branch

* Tweak parsing API constant and removed cruft

---------

Co-authored-by: Daniel Naab <[email protected]>
  • Loading branch information
jimmoffet and danielnaab authored Apr 5, 2024
1 parent 8eee124 commit f9b8afa
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 1,498 deletions.
42 changes: 23 additions & 19 deletions packages/design/src/FormManager/FormEdit/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,38 +92,42 @@ const createPatternPreviewComponent = (
uswdsRoot: string
) => {
const PatternPreviewComponent: PatternComponent = props => {
const context = useFormEditStore(state => state.context);
const selectedPattern = useFormEditStore(state => state.selectedPattern);
const handleEditClick = useFormEditStore(state => state.handleEditClick);

const isSelected = selectedPattern?.id === props._patternId;
const divClassNames = isSelected
? 'form-group-row field-selected'
: 'form-group-row';
const EditComponent = context.editComponents[props.type];

return (
<div className={divClassNames} data-id={props._patternId}>
<Component {...props} />
<span className="edit-button-icon">
<button
className="usa-button usa-button--secondary usa-button--unstyled"
onClick={() => handleEditClick(props._patternId)}
onKeyDown={e => {
if (e.key === 'Enter') {
handleEditClick(props._patternId);
}
}}
tabIndex={0}
aria-label="Edit form group"
>
<svg
className="usa-icon"
aria-hidden="true"
focusable="false"
role="img"
{EditComponent ? (
<button
className="usa-button usa-button--secondary usa-button--unstyled"
onClick={() => handleEditClick(props._patternId)}
onKeyDown={e => {
if (e.key === 'Enter') {
handleEditClick(props._patternId);
}
}}
tabIndex={0}
aria-label="Edit form group"
>
<use xlinkHref={`${uswdsRoot}img/sprite.svg#settings`}></use>
</svg>
</button>
<svg
className="usa-icon"
aria-hidden="true"
focusable="false"
role="img"
>
<use xlinkHref={`${uswdsRoot}img/sprite.svg#settings`}></use>
</svg>
</button>
) : null}
</span>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/documents/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { InputPattern } from '../patterns/input';
import { SequencePattern } from '../patterns/sequence';
import { PDFDocument, getDocumentFieldData } from './pdf';
import { getSuggestedPatternsFromCache } from './suggestions';
import { getSuggestedPatterns } from './suggestions';
import { DocumentFieldMap } from './types';

export type DocumentTemplate = PDFDocument;
Expand All @@ -22,7 +22,7 @@ export const addDocument = async (
}
) => {
const fields = await getDocumentFieldData(fileDetails.data);
const cachedPdf = await getSuggestedPatternsFromCache(fileDetails.data);
const cachedPdf = await getSuggestedPatterns(fileDetails.data);

if (cachedPdf) {
form = updateFormSummary(form, {
Expand Down
1 change: 0 additions & 1 deletion packages/forms/src/documents/pdf/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { getDocumentFieldData } from './extract';
export * from './generate';
export { generateDummyPDF } from './generate-dummy';
export { parseAlabamaNameChangeForm } from './mock-api';

export type PDFDocument = {
type: 'pdf';
Expand Down
294 changes: 0 additions & 294 deletions packages/forms/src/documents/pdf/mock-api.ts

This file was deleted.

Loading

0 comments on commit f9b8afa

Please sign in to comment.