-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: address field #7966
Draft
scottheng96
wants to merge
22
commits into
develop
Choose a base branch
from
feat/address-field-fe
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat: address field #7966
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
33f3694
draft changes to address-field
scottheng96 7fb2dc3
Merge branch 'develop' into feat/address-field-fe
scottheng96 2668417
draft for local-address-field-fe
scottheng96 09fecb6
Merge branch 'develop' into feat/address-field-fe
scottheng96 81bf1d3
added chromatic stories
scottheng96 54484ef
removed unfinished be
scottheng96 841445e
resolved npm run build issues
scottheng96 9721840
added fe unit tests
scottheng96 eed538c
done api service call & custom error handling
scottheng96 2a88fc0
updated FE with chromatic review changes
scottheng96 8f18700
final changes to FE
scottheng96 eda5332
updated chromatic changes ui
scottheng96 edfa1ea
completed FE stories
scottheng96 dab4d38
BE work start chunk
scottheng96 2ccf5a9
Merge branch 'develop' into feat/address-field-fe
scottheng96 3ccb9e9
updated BE v3 response validations
scottheng96 dd32a67
checkpoint for BE validation
scottheng96 78a5871
consolidated fe and aligned be - failing on submission still
scottheng96 815573a
fixed cicd tests
scottheng96 9469d3d
fix imports
scottheng96 ca2d0ce
added splitting of address fields into single responses
scottheng96 ce31aad
submission successful but still 1 string
scottheng96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/EditAddress/EditAddress.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Meta, StoryFn } from '@storybook/react' | ||
|
||
import { AddressCompoundFieldBase, BasicField } from '~shared/types' | ||
|
||
import { createFormBuilderMocks } from '~/mocks/msw/handlers/admin-form' | ||
|
||
import { EditFieldDrawerDecorator, StoryRouter } from '~utils/storybook' | ||
|
||
import { EditAddress, EditAddressProps } from './EditAddress' | ||
|
||
const DEFAULT_ADDRESS_FIELD: AddressCompoundFieldBase = { | ||
title: 'Local address', | ||
description: '', | ||
required: true, | ||
disabled: false, | ||
fieldType: BasicField.Address, | ||
globalId: 'unused', | ||
} | ||
|
||
export default { | ||
title: 'Features/AdminForm/EditFieldDrawer/EditAddress', | ||
component: EditAddress, | ||
decorators: [ | ||
StoryRouter({ | ||
initialEntries: ['/61540ece3d4a6e50ac0cc6ff'], | ||
path: '/:formId', | ||
}), | ||
EditFieldDrawerDecorator, | ||
], | ||
parameters: { | ||
// Required so skeleton "animation" does not hide content. | ||
chromatic: { pauseAnimationAtEnd: true }, | ||
msw: createFormBuilderMocks({}, 0), | ||
}, | ||
args: { | ||
field: DEFAULT_ADDRESS_FIELD, | ||
}, | ||
} as Meta<EditAddressProps> | ||
|
||
interface StoryArgs { | ||
field: AddressCompoundFieldBase | ||
} | ||
|
||
const Template: StoryFn<StoryArgs> = ({ field }) => { | ||
return <EditAddress field={field} /> | ||
} | ||
|
||
export const Default = Template.bind({}) | ||
|
||
export const WithValues = Template.bind({}) | ||
WithValues.args = { | ||
field: { | ||
...DEFAULT_ADDRESS_FIELD, | ||
title: 'Address Field Title', | ||
description: 'Address Field Description', | ||
}, | ||
} |
77 changes: 77 additions & 0 deletions
77
...-design/BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/EditAddress/EditAddress.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useMemo } from 'react' | ||
import { FormControl } from '@chakra-ui/react' | ||
import { extend, pick } from 'lodash' | ||
|
||
import { AddressCompoundFieldBase } from '~shared/types/field' | ||
|
||
import { createBaseValidationRules } from '~utils/fieldValidation' | ||
import FormErrorMessage from '~components/FormControl/FormErrorMessage' | ||
import FormLabel from '~components/FormControl/FormLabel' | ||
import Input from '~components/Input' | ||
import Textarea from '~components/Textarea' | ||
import Toggle from '~components/Toggle' | ||
|
||
import { CreatePageDrawerContentContainer } from '~features/admin-form/create/common' | ||
|
||
import { FormFieldDrawerActions } from '../common/FormFieldDrawerActions' | ||
import { EditFieldProps } from '../common/types' | ||
import { useEditFieldForm } from '../common/useEditFieldForm' | ||
|
||
export type EditAddressProps = EditFieldProps<AddressCompoundFieldBase> | ||
|
||
type EditAddressInputs = Pick< | ||
AddressCompoundFieldBase, | ||
'title' | 'description' | 'required' | ||
> | ||
|
||
export const EditAddress = ({ field }: EditAddressProps): JSX.Element => { | ||
const { | ||
register, | ||
formState: { errors }, | ||
getValues, | ||
buttonText, | ||
handleUpdateField, | ||
watch, | ||
control, | ||
clearErrors, | ||
isLoading, | ||
handleCancel, | ||
setValue, | ||
} = useEditFieldForm<EditAddressInputs, AddressCompoundFieldBase>({ | ||
field, | ||
transform: { | ||
input: (inputField) => | ||
pick(inputField, ['title', 'description', 'required']), | ||
output: (formOutput, originalField) => | ||
extend({}, originalField, formOutput), | ||
}, | ||
}) | ||
|
||
const requiredValidationRule = useMemo( | ||
() => createBaseValidationRules({ required: true }), | ||
[], | ||
) | ||
return ( | ||
<CreatePageDrawerContentContainer> | ||
<FormControl isRequired isReadOnly={isLoading} isInvalid={!!errors.title}> | ||
<FormLabel>Field Name</FormLabel> | ||
<Input autoFocus {...register('title', requiredValidationRule)} /> | ||
<FormErrorMessage>{errors?.title?.message}</FormErrorMessage> | ||
</FormControl> | ||
<FormControl isReadOnly={isLoading} isInvalid={!!errors.description}> | ||
<FormLabel>Description</FormLabel> | ||
<Textarea {...register('description')} /> | ||
<FormErrorMessage>{errors?.description?.message}</FormErrorMessage> | ||
</FormControl> | ||
<FormControl isReadOnly={isLoading}> | ||
<Toggle {...register('required')} label="Required" /> | ||
</FormControl> | ||
<FormFieldDrawerActions | ||
isLoading={isLoading} | ||
buttonText={buttonText} | ||
handleClick={handleUpdateField} | ||
handleCancel={handleCancel} | ||
/> | ||
</CreatePageDrawerContentContainer> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
...der-and-design/BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/EditAddress/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EditAddress } from './EditAddress' |
1 change: 1 addition & 0 deletions
1
.../create/builder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,6 @@ const transformFormInputCountryRegionToUpperCase = | |
.filter((field) => field.fieldType === BasicField.CountryRegion) | ||
.map((field) => field._id), | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental change here? It should be fine to leave a visual break here. |
||
return Object.keys(formInputs).reduce( | ||
(newFormInputs: typeof formInputs, fieldId) => { | ||
const currentInput = formInputs[fieldId] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/nit Regarding
searchAliases
: to get input from Ruchel + Kenneth before we release.