From ee9070e337d04fd4f12646746d21ec0deb58df20 Mon Sep 17 00:00:00 2001 From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it> Date: Tue, 4 May 2021 10:40:45 +0200 Subject: [PATCH] Location fragment lab component --- .../LocationFragment/LocationFragment.md | 5 + .../LocationFragment/LocationFragment.tsx | 91 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.md create mode 100644 src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.tsx diff --git a/src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.md b/src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.md new file mode 100644 index 0000000..fffab03 --- /dev/null +++ b/src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.md @@ -0,0 +1,5 @@ +Form input fragment for location data insertion using [nominatim](https://nominatim.openstreetmap.org/ui/search.html) standard to insert data. + +```js +<LocationFragment /> +``` diff --git a/src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.tsx b/src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.tsx new file mode 100644 index 0000000..fde9bc1 --- /dev/null +++ b/src/components/AuthUser/SignUpForm/LocationFragment/LocationFragment.tsx @@ -0,0 +1,91 @@ +import React, { FC } from 'react'; +import { InputField } from 'components/AuthUser/InputField/InputField'; + +export const LocationFragment: FC = (control, errors) => ( + <div data-testid="Location"> + <InputField + name="houseNumberStreet" + control={control} + rules={{ + validate: (value: string) => /^[A-Za-z]$/.test(value), + required: { + value: true, + message: 'houseNumberStreet is not valid', + }, + }} + label="House number/Street" + error={!!errors.houseNumberStreet} + errorMessage="Insert houseNumberStreet" + /> + <InputField + name="state" + control={control} + rules={{ + validate: (value: string) => /^[A-Za-z]$/.test(value), + required: { + value: true, + message: 'state is not valid', + }, + }} + label="State" + error={!!errors.state} + errorMessage="Insert state" + /> + <InputField + name="city" + control={control} + rules={{ + validate: (value: string) => /^[A-Za-z]$/.test(value), + required: { + value: true, + message: 'city is not valid', + }, + }} + label="City" + error={!!errors.city} + errorMessage="Insert city" + /> + <InputField + name="country" + control={control} + rules={{ + validate: (value: string) => /^[A-Za-z]$/.test(value), + required: { + value: true, + message: 'country is not valid', + }, + }} + label="Last name" + error={!!errors.country} + errorMessage="Insert country" + /> + <InputField + name="county" + control={control} + rules={{ + validate: (value: string) => /^[A-Za-z]$/.test(value), + required: { + value: true, + message: 'county is not valid', + }, + }} + label="County" + error={!!errors.county} + errorMessage="Insert county" + /> + <InputField + name="postalCode" + control={control} + rules={{ + validate: (value: string) => /^[/d]$/.test(value), + required: { + value: true, + message: 'postalCode is not valid', + }, + }} + label="Postal code" + error={!!errors.postalCode} + errorMessage="Insert postalCode" + /> + </div> +); -- GitLab