@licklist/design 0.72.72-dev.0 → 0.72.72-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -2
- package/dist/setting/index.d.ts +0 -2
- package/dist/setting/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/setting/index.ts +0 -2
- package/yarn.lock +23 -23
- package/dist/setting/admin/AdminSettingForm.d.ts +0 -25
- package/dist/setting/admin/AdminSettingForm.d.ts.map +0 -1
- package/dist/setting/admin/AdminSettingForm.js +0 -220
- package/dist/setting/admin/PaymentFeeForm.d.ts +0 -13
- package/dist/setting/admin/PaymentFeeForm.d.ts.map +0 -1
- package/dist/setting/admin/PaymentFeeForm.js +0 -439
- package/dist/setting/admin/index.d.ts +0 -2
- package/dist/setting/admin/index.d.ts.map +0 -1
- package/dist/setting/system/SystemSettingForm.d.ts +0 -10
- package/dist/setting/system/SystemSettingForm.d.ts.map +0 -1
- package/dist/setting/system/SystemSettingForm.js +0 -95
- package/dist/setting/system/index.d.ts +0 -2
- package/dist/setting/system/index.d.ts.map +0 -1
- package/dist/types/currency.d.ts +0 -5
- package/dist/types/currency.d.ts.map +0 -1
- package/src/setting/admin/AdminSetting.stories.tsx +0 -52
- package/src/setting/admin/AdminSettingForm.tsx +0 -196
- package/src/setting/admin/PaymentFeeForm.tsx +0 -309
- package/src/setting/admin/index.ts +0 -1
- package/src/setting/system/SystemSetting.stories.tsx +0 -26
- package/src/setting/system/SystemSettingForm.tsx +0 -62
- package/src/setting/system/index.ts +0 -1
- package/src/types/currency.ts +0 -4
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { useId } from '@react-aria/utils'
|
|
2
|
-
import { Button, Spinner, Form } from 'react-bootstrap'
|
|
3
|
-
import InputGroup from 'react-bootstrap/InputGroup'
|
|
4
|
-
import { FormProvider, useForm } from 'react-hook-form'
|
|
5
|
-
import { useTranslation } from 'react-i18next'
|
|
6
|
-
import { HasPermissionProp } from '@licklist/plugins/dist/types/permission/Permission'
|
|
7
|
-
|
|
8
|
-
import Card from 'react-bootstrap/Card'
|
|
9
|
-
import Row from 'react-bootstrap/Row'
|
|
10
|
-
import Col from 'react-bootstrap/Col'
|
|
11
|
-
import { Link } from 'react-router-dom'
|
|
12
|
-
import HookFormService from '@licklist/plugins/dist/services/Form/HookFormService'
|
|
13
|
-
import { ProvidableType } from '@licklist/core/dist/DataMapper/Provider/ProvidableDataMapper'
|
|
14
|
-
import { FaCommentAlt } from 'react-icons/fa'
|
|
15
|
-
import { PaymentFeeForm, PaymentFeeFormFieldValues } from './PaymentFeeForm'
|
|
16
|
-
import { Currency } from '../../types/currency'
|
|
17
|
-
|
|
18
|
-
export type AdminSettingFormFieldValues = {
|
|
19
|
-
warningOnNumberOfPeople: string
|
|
20
|
-
currency_id?: number
|
|
21
|
-
providerHasMap: null | boolean
|
|
22
|
-
hasBookingManagement: null | boolean
|
|
23
|
-
additionalPaymentMethodsEnabled: null | boolean
|
|
24
|
-
externalPaymentLinkEnabled: null | boolean
|
|
25
|
-
} & PaymentFeeFormFieldValues
|
|
26
|
-
|
|
27
|
-
export interface AdminSettingFormProps extends HasPermissionProp {
|
|
28
|
-
isLoading: boolean
|
|
29
|
-
onSubmit?: (data: AdminSettingFormFieldValues) => void
|
|
30
|
-
defaultValues?: Partial<AdminSettingFormFieldValues>
|
|
31
|
-
currencies?: Array<Currency>
|
|
32
|
-
providerMetadata: {
|
|
33
|
-
country?: string
|
|
34
|
-
providableId?: number
|
|
35
|
-
providerType?: ProvidableType
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const AdminSettingForm = ({
|
|
40
|
-
isLoading = false,
|
|
41
|
-
defaultValues = {},
|
|
42
|
-
onSubmit,
|
|
43
|
-
currencies = [],
|
|
44
|
-
hasPermission = true,
|
|
45
|
-
providerMetadata,
|
|
46
|
-
}: AdminSettingFormProps) => {
|
|
47
|
-
const form = useForm<AdminSettingFormFieldValues>({
|
|
48
|
-
mode: 'onChange',
|
|
49
|
-
defaultValues,
|
|
50
|
-
})
|
|
51
|
-
const {
|
|
52
|
-
register,
|
|
53
|
-
handleSubmit,
|
|
54
|
-
formState: { errors, isValid },
|
|
55
|
-
} = form
|
|
56
|
-
const { t } = useTranslation('Design')
|
|
57
|
-
|
|
58
|
-
const warningOnNumberOfPeopleId = useId()
|
|
59
|
-
const providerHasMapId = useId()
|
|
60
|
-
const hasBookingManagement = useId()
|
|
61
|
-
const additionalPaymentMethodsEnabledId = useId()
|
|
62
|
-
const externalPaymentLinkEnabledId = useId()
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<Form
|
|
66
|
-
className='d-flex flex-column'
|
|
67
|
-
noValidate
|
|
68
|
-
onSubmit={handleSubmit(onSubmit)}
|
|
69
|
-
>
|
|
70
|
-
<FormProvider {...form}>
|
|
71
|
-
<Form.Group controlId={warningOnNumberOfPeopleId}>
|
|
72
|
-
<Form.Label>{t('warningOnNumberOfPeople')}</Form.Label>
|
|
73
|
-
|
|
74
|
-
<InputGroup>
|
|
75
|
-
<InputGroup.Prepend>
|
|
76
|
-
<InputGroup.Text>
|
|
77
|
-
<FaCommentAlt size={16} />
|
|
78
|
-
</InputGroup.Text>
|
|
79
|
-
</InputGroup.Prepend>
|
|
80
|
-
|
|
81
|
-
<Form.Control
|
|
82
|
-
{...register('warningOnNumberOfPeople')}
|
|
83
|
-
disabled={isLoading}
|
|
84
|
-
/>
|
|
85
|
-
</InputGroup>
|
|
86
|
-
</Form.Group>
|
|
87
|
-
|
|
88
|
-
<PaymentFeeForm isLoading={isLoading} />
|
|
89
|
-
|
|
90
|
-
<Form.Label className='mt-5'>{t('defaultVenueCurrency')}</Form.Label>
|
|
91
|
-
<Form.Control
|
|
92
|
-
{...register('currency_id')}
|
|
93
|
-
as='select'
|
|
94
|
-
disabled={isLoading}
|
|
95
|
-
>
|
|
96
|
-
{currencies?.map((currency) => (
|
|
97
|
-
<option value={currency.id} key={currency.id}>
|
|
98
|
-
{currency.title}
|
|
99
|
-
</option>
|
|
100
|
-
))}
|
|
101
|
-
</Form.Control>
|
|
102
|
-
|
|
103
|
-
<Row>
|
|
104
|
-
<Col xs={12}>
|
|
105
|
-
<h5 className='mt-5'>{t('advanced')}</h5>
|
|
106
|
-
</Col>
|
|
107
|
-
</Row>
|
|
108
|
-
|
|
109
|
-
<Card className='mb-3'>
|
|
110
|
-
<Card.Body>
|
|
111
|
-
<Row>
|
|
112
|
-
<Col xs={12}>
|
|
113
|
-
<Form.Group controlId={providerHasMapId}>
|
|
114
|
-
<Form.Check
|
|
115
|
-
{...register('providerHasMap')}
|
|
116
|
-
disabled={isLoading}
|
|
117
|
-
label={t('providerHasMap')}
|
|
118
|
-
/>
|
|
119
|
-
</Form.Group>
|
|
120
|
-
|
|
121
|
-
<Form.Group controlId={hasBookingManagement}>
|
|
122
|
-
<Form.Check
|
|
123
|
-
{...register('hasBookingManagement')}
|
|
124
|
-
disabled={isLoading}
|
|
125
|
-
label={t('hasBookingManagement')}
|
|
126
|
-
/>
|
|
127
|
-
</Form.Group>
|
|
128
|
-
<Form.Group controlId={additionalPaymentMethodsEnabledId}>
|
|
129
|
-
<Form.Check>
|
|
130
|
-
<Form.Check.Input
|
|
131
|
-
{...register('additionalPaymentMethodsEnabled', {
|
|
132
|
-
validate: (value) =>
|
|
133
|
-
!value || Boolean(providerMetadata?.country),
|
|
134
|
-
})}
|
|
135
|
-
disabled={isLoading}
|
|
136
|
-
isInvalid={!!errors?.additionalPaymentMethodsEnabled}
|
|
137
|
-
/>
|
|
138
|
-
<Form.Check.Label>
|
|
139
|
-
{t('additionalPaymentMethodsEnabled')}
|
|
140
|
-
</Form.Check.Label>
|
|
141
|
-
<Form.Control.Feedback type='invalid'>
|
|
142
|
-
{HookFormService.hasError(
|
|
143
|
-
errors.additionalPaymentMethodsEnabled,
|
|
144
|
-
'validate',
|
|
145
|
-
) && (
|
|
146
|
-
<>
|
|
147
|
-
{t('noCountryIsProvided')}
|
|
148
|
-
{/* TODO fix issue react router types
|
|
149
|
-
@ts-expect-error */}
|
|
150
|
-
<Link
|
|
151
|
-
role='button'
|
|
152
|
-
to={`/provider/${providerMetadata?.providerType}/${providerMetadata?.providableId}/update`}
|
|
153
|
-
>
|
|
154
|
-
{/* TODO fix issue react router types
|
|
155
|
-
@ts-expect-error */}
|
|
156
|
-
{t('here')}
|
|
157
|
-
</Link>
|
|
158
|
-
</>
|
|
159
|
-
)}
|
|
160
|
-
</Form.Control.Feedback>
|
|
161
|
-
</Form.Check>
|
|
162
|
-
</Form.Group>
|
|
163
|
-
|
|
164
|
-
<Form.Group controlId={externalPaymentLinkEnabledId}>
|
|
165
|
-
<Form.Check
|
|
166
|
-
{...register('externalPaymentLinkEnabled')}
|
|
167
|
-
disabled={isLoading}
|
|
168
|
-
label={t('externalPaymentLinkEnabled')}
|
|
169
|
-
/>
|
|
170
|
-
</Form.Group>
|
|
171
|
-
</Col>
|
|
172
|
-
</Row>
|
|
173
|
-
</Card.Body>
|
|
174
|
-
</Card>
|
|
175
|
-
</FormProvider>
|
|
176
|
-
{hasPermission && (
|
|
177
|
-
<Button
|
|
178
|
-
type='submit'
|
|
179
|
-
disabled={isLoading || !isValid}
|
|
180
|
-
className='d-flex align-items-center align-self-end mt-5'
|
|
181
|
-
>
|
|
182
|
-
{isLoading && (
|
|
183
|
-
<Spinner
|
|
184
|
-
animation='border'
|
|
185
|
-
size='sm'
|
|
186
|
-
role='status'
|
|
187
|
-
aria-hidden='true'
|
|
188
|
-
className='mr-2'
|
|
189
|
-
/>
|
|
190
|
-
)}
|
|
191
|
-
{t('update')}
|
|
192
|
-
</Button>
|
|
193
|
-
)}
|
|
194
|
-
</Form>
|
|
195
|
-
)
|
|
196
|
-
}
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { useId } from '@react-aria/utils'
|
|
2
|
-
import Card from 'react-bootstrap/Card'
|
|
3
|
-
import Col from 'react-bootstrap/Col'
|
|
4
|
-
import Form from 'react-bootstrap/Form'
|
|
5
|
-
import InputGroup from 'react-bootstrap/InputGroup'
|
|
6
|
-
import Row from 'react-bootstrap/Row'
|
|
7
|
-
import { useFormContext } from 'react-hook-form'
|
|
8
|
-
import { useTranslation } from 'react-i18next'
|
|
9
|
-
import { FaPercentage, FaPoundSign } from 'react-icons/fa'
|
|
10
|
-
import { WarningMessage } from '../../static'
|
|
11
|
-
|
|
12
|
-
export type PaymentFeeFormFieldValues = {
|
|
13
|
-
feeInPercent: number
|
|
14
|
-
minFeeInPounds: number
|
|
15
|
-
maxFeeInPounds: number
|
|
16
|
-
vatInPercent: number
|
|
17
|
-
fixedFee: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type PaymentFeeFormProps = {
|
|
21
|
-
isLoading: boolean
|
|
22
|
-
defaultValues?: Partial<PaymentFeeFormFieldValues>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function PaymentFeeForm({ isLoading = false }: PaymentFeeFormProps) {
|
|
26
|
-
const {
|
|
27
|
-
register,
|
|
28
|
-
formState: { errors },
|
|
29
|
-
watch,
|
|
30
|
-
} = useFormContext<PaymentFeeFormFieldValues>()
|
|
31
|
-
const { t } = useTranslation('Design')
|
|
32
|
-
|
|
33
|
-
const feeInPercentId = useId()
|
|
34
|
-
const minFeeInPoundsId = useId()
|
|
35
|
-
const maxFeeInPoundsId = useId()
|
|
36
|
-
const vatInPercentId = useId()
|
|
37
|
-
const fixedFeeId = useId()
|
|
38
|
-
|
|
39
|
-
const minFee = watch('minFeeInPounds')
|
|
40
|
-
const maxFee = watch('maxFeeInPounds')
|
|
41
|
-
const percentFee = watch('feeInPercent')
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<>
|
|
45
|
-
<Row>
|
|
46
|
-
<Col xs={12}>
|
|
47
|
-
<h5 className='mt-5'>{t('paymentFee')}</h5>
|
|
48
|
-
</Col>
|
|
49
|
-
</Row>
|
|
50
|
-
|
|
51
|
-
<Card className='mb-3'>
|
|
52
|
-
<Card.Body>
|
|
53
|
-
<Row>
|
|
54
|
-
<Col xs={12}>
|
|
55
|
-
<div className='mb-4'>{t('paymentFeeDescription')}</div>
|
|
56
|
-
</Col>
|
|
57
|
-
</Row>
|
|
58
|
-
|
|
59
|
-
<Row>
|
|
60
|
-
<Col xs={12} sm={4} lg={2}>
|
|
61
|
-
<Form.Group controlId={feeInPercentId}>
|
|
62
|
-
<Form.Label>{t('feeInPercent')}</Form.Label>
|
|
63
|
-
|
|
64
|
-
<InputGroup hasValidation>
|
|
65
|
-
<InputGroup.Prepend>
|
|
66
|
-
<InputGroup.Text>
|
|
67
|
-
<FaPercentage size={10} />
|
|
68
|
-
</InputGroup.Text>
|
|
69
|
-
</InputGroup.Prepend>
|
|
70
|
-
|
|
71
|
-
<Form.Control
|
|
72
|
-
type='number'
|
|
73
|
-
min={0}
|
|
74
|
-
max={100}
|
|
75
|
-
step='1'
|
|
76
|
-
placeholder='0'
|
|
77
|
-
onWheel={(event) => event.currentTarget.blur()}
|
|
78
|
-
{...register('feeInPercent', {
|
|
79
|
-
validate: {
|
|
80
|
-
moreThan: (v) => (v ? v >= 0 : true),
|
|
81
|
-
lessThan: (v) => (v ? v <= 100 : true),
|
|
82
|
-
},
|
|
83
|
-
})}
|
|
84
|
-
name='feeInPercent'
|
|
85
|
-
isInvalid={Boolean(errors.feeInPercent)}
|
|
86
|
-
disabled={isLoading}
|
|
87
|
-
/>
|
|
88
|
-
|
|
89
|
-
<Form.Control.Feedback type='invalid'>
|
|
90
|
-
{errors.feeInPercent?.message}
|
|
91
|
-
{errors.feeInPercent?.type === 'moreThan' &&
|
|
92
|
-
t('Validation:fieldMinNumber', {
|
|
93
|
-
attribute: t('feeInPercent'),
|
|
94
|
-
min: 0,
|
|
95
|
-
})}
|
|
96
|
-
{errors.feeInPercent?.type === 'lessThan' &&
|
|
97
|
-
t('Validation:fieldMaxNumber', {
|
|
98
|
-
attribute: t('feeInPercent'),
|
|
99
|
-
max: 100,
|
|
100
|
-
})}
|
|
101
|
-
</Form.Control.Feedback>
|
|
102
|
-
</InputGroup>
|
|
103
|
-
</Form.Group>
|
|
104
|
-
{percentFee && minFee && maxFee ? (
|
|
105
|
-
<WarningMessage message={t('Validation:fieldPercentFee')} />
|
|
106
|
-
) : null}
|
|
107
|
-
</Col>
|
|
108
|
-
|
|
109
|
-
<Col xs={12} sm={4} lg={2}>
|
|
110
|
-
<Form.Group controlId={minFeeInPoundsId}>
|
|
111
|
-
<Form.Label>{t('minFeeInPounds')}</Form.Label>
|
|
112
|
-
|
|
113
|
-
<InputGroup hasValidation>
|
|
114
|
-
<InputGroup.Prepend>
|
|
115
|
-
<InputGroup.Text>
|
|
116
|
-
<FaPoundSign size={10} />
|
|
117
|
-
</InputGroup.Text>
|
|
118
|
-
</InputGroup.Prepend>
|
|
119
|
-
|
|
120
|
-
<Form.Control
|
|
121
|
-
{...register('minFeeInPounds', {
|
|
122
|
-
validate: {
|
|
123
|
-
moreThan: (v) => (v ? v >= 0 : true),
|
|
124
|
-
lessThan: (v) => (v ? v <= 999999.99 : true),
|
|
125
|
-
},
|
|
126
|
-
})}
|
|
127
|
-
name='minFeeInPounds'
|
|
128
|
-
type='number'
|
|
129
|
-
min={0}
|
|
130
|
-
max={999999.99}
|
|
131
|
-
step='0.01'
|
|
132
|
-
placeholder='0,00'
|
|
133
|
-
onWheel={(event) => event.currentTarget.blur()}
|
|
134
|
-
isInvalid={Boolean(errors.minFeeInPounds)}
|
|
135
|
-
disabled={isLoading}
|
|
136
|
-
/>
|
|
137
|
-
|
|
138
|
-
<Form.Control.Feedback type='invalid'>
|
|
139
|
-
{errors.minFeeInPounds?.message}
|
|
140
|
-
{errors.minFeeInPounds?.type === 'moreThan' &&
|
|
141
|
-
t('Validation:fieldMinNumber', {
|
|
142
|
-
attribute: t('minFeeInPounds'),
|
|
143
|
-
min: 0,
|
|
144
|
-
})}
|
|
145
|
-
{errors.minFeeInPounds?.type === 'lessThan' &&
|
|
146
|
-
t('Validation:fieldMaxNumber', {
|
|
147
|
-
attribute: t('minFeeInPounds'),
|
|
148
|
-
max: 999999.99,
|
|
149
|
-
})}
|
|
150
|
-
</Form.Control.Feedback>
|
|
151
|
-
</InputGroup>
|
|
152
|
-
</Form.Group>
|
|
153
|
-
</Col>
|
|
154
|
-
|
|
155
|
-
<Col xs={12} sm={4} lg={3}>
|
|
156
|
-
<Form.Group controlId={maxFeeInPoundsId}>
|
|
157
|
-
<Form.Label>{t('maxFeeInPounds')}</Form.Label>
|
|
158
|
-
|
|
159
|
-
<InputGroup hasValidation>
|
|
160
|
-
<InputGroup.Prepend>
|
|
161
|
-
<InputGroup.Text>
|
|
162
|
-
<FaPoundSign size={10} />
|
|
163
|
-
</InputGroup.Text>
|
|
164
|
-
</InputGroup.Prepend>
|
|
165
|
-
|
|
166
|
-
<Form.Control
|
|
167
|
-
{...register('maxFeeInPounds', {
|
|
168
|
-
validate: {
|
|
169
|
-
moreThan: (v) => (v ? v >= 0 : true),
|
|
170
|
-
lessThan: (v) => (v ? v <= 999999.99 : true),
|
|
171
|
-
},
|
|
172
|
-
})}
|
|
173
|
-
name='maxFeeInPounds'
|
|
174
|
-
type='number'
|
|
175
|
-
min={0}
|
|
176
|
-
max={999999.99}
|
|
177
|
-
step='0.01'
|
|
178
|
-
placeholder='0,00'
|
|
179
|
-
onWheel={(event) => event.currentTarget.blur()}
|
|
180
|
-
isInvalid={Boolean(errors.maxFeeInPounds)}
|
|
181
|
-
disabled={isLoading}
|
|
182
|
-
/>
|
|
183
|
-
|
|
184
|
-
<Form.Control.Feedback type='invalid'>
|
|
185
|
-
{errors.maxFeeInPounds?.message}
|
|
186
|
-
{errors.maxFeeInPounds?.type === 'moreThan' &&
|
|
187
|
-
t('Validation:fieldMinNumber', {
|
|
188
|
-
attribute: t('maxFeeInPounds'),
|
|
189
|
-
min: 0,
|
|
190
|
-
})}
|
|
191
|
-
{errors.maxFeeInPounds?.type === 'lessThan' &&
|
|
192
|
-
t('Validation:fieldMaxNumber', {
|
|
193
|
-
attribute: t('maxFeeInPounds'),
|
|
194
|
-
max: 999999.99,
|
|
195
|
-
})}
|
|
196
|
-
</Form.Control.Feedback>
|
|
197
|
-
</InputGroup>
|
|
198
|
-
</Form.Group>
|
|
199
|
-
{minFee > maxFee ? (
|
|
200
|
-
<WarningMessage
|
|
201
|
-
message={t('Validation:fieldMaxNumber', {
|
|
202
|
-
attribute: t('Min Fee'),
|
|
203
|
-
max: 'Max Fee',
|
|
204
|
-
})}
|
|
205
|
-
/>
|
|
206
|
-
) : null}
|
|
207
|
-
</Col>
|
|
208
|
-
|
|
209
|
-
<Col
|
|
210
|
-
xs={12}
|
|
211
|
-
sm={{ span: 4, offset: 2 }}
|
|
212
|
-
lg={{ span: 2, offset: 0 }}
|
|
213
|
-
>
|
|
214
|
-
<Form.Group controlId={vatInPercentId}>
|
|
215
|
-
<Form.Label>{t('vatInPercent')}</Form.Label>
|
|
216
|
-
|
|
217
|
-
<InputGroup hasValidation>
|
|
218
|
-
<InputGroup.Prepend>
|
|
219
|
-
<InputGroup.Text>
|
|
220
|
-
<FaPercentage size={10} />
|
|
221
|
-
</InputGroup.Text>
|
|
222
|
-
</InputGroup.Prepend>
|
|
223
|
-
|
|
224
|
-
<Form.Control
|
|
225
|
-
{...register('vatInPercent', {
|
|
226
|
-
validate: {
|
|
227
|
-
moreThan: (v) => (v ? v >= 0 : true),
|
|
228
|
-
lessThan: (v) => (v ? v <= 100 : true),
|
|
229
|
-
},
|
|
230
|
-
})}
|
|
231
|
-
name='vatInPercent'
|
|
232
|
-
type='number'
|
|
233
|
-
min={0}
|
|
234
|
-
max={100}
|
|
235
|
-
step='1'
|
|
236
|
-
placeholder='0'
|
|
237
|
-
onWheel={(event) => event.currentTarget.blur()}
|
|
238
|
-
isInvalid={Boolean(errors.vatInPercent)}
|
|
239
|
-
disabled={isLoading}
|
|
240
|
-
/>
|
|
241
|
-
|
|
242
|
-
<Form.Control.Feedback type='invalid'>
|
|
243
|
-
{errors.vatInPercent?.message}
|
|
244
|
-
{errors.vatInPercent?.type === 'moreThan' &&
|
|
245
|
-
t('Validation:fieldMinNumber', {
|
|
246
|
-
attribute: t('vatInPercent'),
|
|
247
|
-
min: 0,
|
|
248
|
-
})}
|
|
249
|
-
{errors.vatInPercent?.type === 'lessThan' &&
|
|
250
|
-
t('Validation:fieldMaxNumber', {
|
|
251
|
-
attribute: t('vatInPercent'),
|
|
252
|
-
max: 100,
|
|
253
|
-
})}
|
|
254
|
-
</Form.Control.Feedback>
|
|
255
|
-
</InputGroup>
|
|
256
|
-
</Form.Group>
|
|
257
|
-
</Col>
|
|
258
|
-
|
|
259
|
-
<Col xs={12} sm={4} lg={3}>
|
|
260
|
-
<Form.Group controlId={fixedFeeId}>
|
|
261
|
-
<Form.Label>{t('fixedFee')}</Form.Label>
|
|
262
|
-
|
|
263
|
-
<InputGroup hasValidation>
|
|
264
|
-
<InputGroup.Prepend>
|
|
265
|
-
<InputGroup.Text>
|
|
266
|
-
<FaPoundSign size={10} />
|
|
267
|
-
</InputGroup.Text>
|
|
268
|
-
</InputGroup.Prepend>
|
|
269
|
-
|
|
270
|
-
<Form.Control
|
|
271
|
-
{...register('fixedFee', {
|
|
272
|
-
validate: {
|
|
273
|
-
moreThan: (v) => (v ? v >= 0 : true),
|
|
274
|
-
lessThan: (v) => (v ? v <= 999999.99 : true),
|
|
275
|
-
},
|
|
276
|
-
})}
|
|
277
|
-
name='fixedFee'
|
|
278
|
-
type='number'
|
|
279
|
-
min={0}
|
|
280
|
-
max={999999.99}
|
|
281
|
-
step='0.01'
|
|
282
|
-
placeholder='0,00'
|
|
283
|
-
onWheel={(event) => event.currentTarget.blur()}
|
|
284
|
-
isInvalid={Boolean(errors.fixedFee)}
|
|
285
|
-
disabled={isLoading}
|
|
286
|
-
/>
|
|
287
|
-
|
|
288
|
-
<Form.Control.Feedback type='invalid'>
|
|
289
|
-
{errors.fixedFee?.message}
|
|
290
|
-
{errors.fixedFee?.type === 'moreThan' &&
|
|
291
|
-
t('Validation:fieldMinNumber', {
|
|
292
|
-
attribute: t('fixedFee'),
|
|
293
|
-
min: 0,
|
|
294
|
-
})}
|
|
295
|
-
{errors.fixedFee?.type === 'lessThan' &&
|
|
296
|
-
t('Validation:fieldMaxNumber', {
|
|
297
|
-
attribute: t('fixedFee'),
|
|
298
|
-
max: 999999.99,
|
|
299
|
-
})}
|
|
300
|
-
</Form.Control.Feedback>
|
|
301
|
-
</InputGroup>
|
|
302
|
-
</Form.Group>
|
|
303
|
-
</Col>
|
|
304
|
-
</Row>
|
|
305
|
-
</Card.Body>
|
|
306
|
-
</Card>
|
|
307
|
-
</>
|
|
308
|
-
)
|
|
309
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AdminSettingForm'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/react'
|
|
2
|
-
import Container from 'react-bootstrap/Container'
|
|
3
|
-
import { SystemSettingForm } from './SystemSettingForm'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Setting/System',
|
|
7
|
-
} as Meta
|
|
8
|
-
|
|
9
|
-
export function Default() {
|
|
10
|
-
return (
|
|
11
|
-
<Container>
|
|
12
|
-
<SystemSettingForm
|
|
13
|
-
isLoading={false}
|
|
14
|
-
onSubmit={(data) => console.log('onSubmit', data)}
|
|
15
|
-
defaultValues={{
|
|
16
|
-
feeInPercent: NaN,
|
|
17
|
-
minFeeInPounds: NaN,
|
|
18
|
-
maxFeeInPounds: NaN,
|
|
19
|
-
vatInPercent: NaN,
|
|
20
|
-
fixedFee: NaN,
|
|
21
|
-
}}
|
|
22
|
-
hasPermission
|
|
23
|
-
/>
|
|
24
|
-
</Container>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Button, Spinner } from 'react-bootstrap'
|
|
2
|
-
import Form from 'react-bootstrap/Form'
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form'
|
|
4
|
-
import { useTranslation } from 'react-i18next'
|
|
5
|
-
import { HasPermissionProp } from '@licklist/plugins/dist/types/permission/Permission'
|
|
6
|
-
import {
|
|
7
|
-
PaymentFeeForm,
|
|
8
|
-
PaymentFeeFormFieldValues,
|
|
9
|
-
} from '../admin/PaymentFeeForm'
|
|
10
|
-
|
|
11
|
-
export type SystemSettingFormFieldValues = PaymentFeeFormFieldValues
|
|
12
|
-
|
|
13
|
-
export interface SystemSettingFormProps extends HasPermissionProp {
|
|
14
|
-
isLoading: boolean
|
|
15
|
-
onSubmit?: (data: SystemSettingFormFieldValues) => void
|
|
16
|
-
defaultValues?: Partial<SystemSettingFormFieldValues>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function SystemSettingForm(props: SystemSettingFormProps) {
|
|
20
|
-
const {
|
|
21
|
-
isLoading = false,
|
|
22
|
-
defaultValues = {},
|
|
23
|
-
onSubmit,
|
|
24
|
-
hasPermission = true,
|
|
25
|
-
} = props
|
|
26
|
-
const form = useForm<SystemSettingFormFieldValues>({
|
|
27
|
-
mode: 'onChange',
|
|
28
|
-
defaultValues,
|
|
29
|
-
})
|
|
30
|
-
const { handleSubmit } = form
|
|
31
|
-
const { t } = useTranslation('Design')
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Form
|
|
35
|
-
className='d-flex flex-column'
|
|
36
|
-
noValidate
|
|
37
|
-
onSubmit={handleSubmit(onSubmit)}
|
|
38
|
-
>
|
|
39
|
-
<FormProvider {...form}>
|
|
40
|
-
<PaymentFeeForm {...props} />
|
|
41
|
-
</FormProvider>
|
|
42
|
-
{hasPermission && (
|
|
43
|
-
<Button
|
|
44
|
-
type='submit'
|
|
45
|
-
disabled={isLoading}
|
|
46
|
-
className='d-flex align-items-center align-self-end mt-5'
|
|
47
|
-
>
|
|
48
|
-
{isLoading && (
|
|
49
|
-
<Spinner
|
|
50
|
-
animation='border'
|
|
51
|
-
size='sm'
|
|
52
|
-
role='status'
|
|
53
|
-
aria-hidden='true'
|
|
54
|
-
className='mr-2'
|
|
55
|
-
/>
|
|
56
|
-
)}
|
|
57
|
-
{t('update')}
|
|
58
|
-
</Button>
|
|
59
|
-
)}
|
|
60
|
-
</Form>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SystemSettingForm'
|
package/src/types/currency.ts
DELETED