Demos
Verify a postal code
This demo contains only a mocked API call, so only a postal code of 1391 for Norway and 11432 for Sweden is valid.
const { withConfig } = Connectors.createContext({ fetchConfig: { url: async (value, { countryCode }) => { const url = `[YOUR-API-URL]/postal-code/${value}` await mockFetch(url, getMockDataPostalCode(countryCode)) return url }, }, }) const onChangeValidator = withConfig(Connectors.Bring.postalCode.validator) const onChange = withConfig(Connectors.Bring.postalCode.autofill, { cityPath: '/city', }) render( <Form.Handler onSubmit={console.log}> <Form.Card> <Field.PostalCodeAndCity countryCode="/countryCode" postalCode={{ path: '/postalCode', onChangeValidator, onChange, required: true, }} city={{ path: '/city', required: true, }} /> <Field.SelectCountry path="/countryCode" defaultValue="NO" filterCountries={({ iso }) => ['NO', 'SE'].includes(iso)} /> </Form.Card> <Form.SubmitButton /> </Form.Handler> )
Address suggestion
This demo contains only a mocked API call, so you can enter anything in the Gateadresse/Street field.
const { withConfig } = Connectors.createContext({ fetchConfig: { url: async (value, { countryCode }) => { const url = `[YOUR-API-URL]/address/${value}` await mockFetch(url, getMockDataAddress(countryCode)) return url }, }, }) const addressSuggestionsElement = withConfig( Connectors.Bring.address.suggestionsElement, { countryCode: '/countryCode', cityPath: '/city', postalCodePath: '/postalCode', } ) render( <Form.Handler onSubmit={console.log}> <Form.Card> <Field.Address.Street path="/streetAddress" element={addressSuggestionsElement} /> <Field.PostalCodeAndCity countryCode="/countryCode" postalCode={{ path: '/postalCode', required: true, }} city={{ path: '/city', required: true, }} /> <Field.SelectCountry path="/countryCode" defaultValue="NO" filterCountries={({ iso }) => ['NO', 'SE'].includes(iso)} /> </Form.Card> <Form.SubmitButton /> </Form.Handler> )