11import { useForm } from 'react-hook-form' ;
2+
23import { InputField } from '../Input/InputField.component' ;
3- import { getCustomNumberValidation } from '../../utils/functions/functions' ;
44
5- const inputField = [
6- { label : 'Fornavn' , name : 'firstName' } ,
7- { label : 'Etternavn' , name : 'lastName' } ,
8- { label : 'Adresse' , name : 'address1' } ,
9- {
10- label : 'Postnummer' ,
11- name : 'postcode' ,
12- customValidation : getCustomNumberValidation (
13- {
14- minLength : 'Postnummer må være minimum 4 tall' ,
15- maxLength : 'Postnummer må være maksimalt 4 tall' ,
16- pattern : 'Postnummer må bare være tall' ,
17- } ,
18- 4
19- ) ,
20- } ,
21- { label : 'Sted' , name : 'city' } ,
22- {
23- label : 'Epost' ,
24- name : 'email' ,
25- customValidation : getCustomNumberValidation (
26- { pattern : 'Du må oppgi en gyldig epost' } ,
27- undefined ,
28- / ^ [ a - z 0 - 9 _ ! # $ % & ' * + \/ = ? ` { | } ~ ^ . - ] + @ [ a - z 0 - 9 . - ] + $ / gim
29- ) ,
30- } ,
31- {
32- label : 'Telefon' ,
33- name : 'phone' ,
34- customValidation : getCustomNumberValidation (
35- {
36- minLength : 'Minimum 8 tall i telefonnummeret' ,
37- maxLength : 'Maksimalt 8 tall i telefonnummeret' ,
38- pattern : 'Ikke gyldig telefonnummer' ,
39- } ,
40- 8
41- ) ,
42- } ,
43- ] ;
5+ import { INPUT_FIELDS } from '../../utils/constants/INPUT_FIELDS' ;
446
457const Billing = ( { onSubmit } ) => {
468 const {
@@ -53,7 +15,7 @@ const Billing = ({ onSubmit }) => {
5315 < section className = "text-gray-700 container p-4 py-2 mx-auto" >
5416 < form onSubmit = { handleSubmit ( onSubmit ) } >
5517 < div className = "mx-auto lg:w-1/2 flex flex-wrap" >
56- { inputField . map ( ( { label, name, customValidation } , key ) => (
18+ { INPUT_FIELDS . map ( ( { label, name, customValidation } , key ) => (
5719 < InputField
5820 key = { key }
5921 label = { label }
0 commit comments