1
1
import { useForm } from 'react-hook-form' ;
2
+
2
3
import { InputField } from '../Input/InputField.component' ;
3
- import { getCustomNumberValidation } from '../../utils/functions/functions' ;
4
4
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' ;
44
6
45
7
const Billing = ( { onSubmit } ) => {
46
8
const {
@@ -53,7 +15,7 @@ const Billing = ({ onSubmit }) => {
53
15
< section className = "text-gray-700 container p-4 py-2 mx-auto" >
54
16
< form onSubmit = { handleSubmit ( onSubmit ) } >
55
17
< 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 ) => (
57
19
< InputField
58
20
key = { key }
59
21
label = { label }
0 commit comments