@autobusal/admin-agents 1.1.0 → 1.1.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/Manage.tsx +34 -9
- package/package.json +1 -1
package/Manage.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
2
|
import { useParams, useNavigate, useSearchParams } from 'react-router-dom';
|
|
3
|
-
import { Meta, BackWithTitle, Viewer, IpLogs, ApiDetails } from '@autobusal/common';
|
|
4
|
-
import { usePage, useBreadcrumbs, useSubscriptions, useOperators } from '@autobusal/hooks';
|
|
3
|
+
import { Meta, BackWithTitle, Viewer, Box, IpLogs, ApiDetails } from '@autobusal/common';
|
|
4
|
+
import { usePage, useBreadcrumbs, useSubscriptions, useCountries, useOperators } from '@autobusal/hooks';
|
|
5
5
|
import { GetStatus, getAllowed, success } from '@autobusal/utilities';
|
|
6
6
|
import { AgentData } from '@autobusal/providers/types/agents';
|
|
7
7
|
import { useGetAgent, usePostAgent, useDeleteAgent } from './services';
|
|
@@ -22,6 +22,8 @@ const Manage = ({ url, t }: Props): JSX.Element => {
|
|
|
22
22
|
|
|
23
23
|
const navigate = useNavigate();
|
|
24
24
|
|
|
25
|
+
const { data: CountryData, isLoading } = useCountries('all');
|
|
26
|
+
|
|
25
27
|
const subscriptions = useSubscriptions('agent');
|
|
26
28
|
const operators = useOperators();
|
|
27
29
|
|
|
@@ -35,6 +37,10 @@ const Manage = ({ url, t }: Props): JSX.Element => {
|
|
|
35
37
|
|
|
36
38
|
const { mutate: Delete, isPending: isPendingDelete } = useDeleteAgent();
|
|
37
39
|
|
|
40
|
+
if (isLoading) {
|
|
41
|
+
return <Box />;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
const onSave = (data: AgentData): void => {
|
|
39
45
|
Update(data, {
|
|
40
46
|
onSuccess: () => {
|
|
@@ -97,6 +103,13 @@ const Manage = ({ url, t }: Props): JSX.Element => {
|
|
|
97
103
|
type: 'text',
|
|
98
104
|
value: data?.city,
|
|
99
105
|
rules: 'required|min_length:2|max_length:40'
|
|
106
|
+
}, {
|
|
107
|
+
label: t('admin_agents.manage.country', { ns: 'common' }),
|
|
108
|
+
name: 'country_id',
|
|
109
|
+
type: 'select',
|
|
110
|
+
values: CountryData,
|
|
111
|
+
value: data?.country_id ?? 0,
|
|
112
|
+
rules: 'required'
|
|
100
113
|
}, {}, {
|
|
101
114
|
label: t('admin_agents.manage.mobile', { ns: 'common' }),
|
|
102
115
|
name: 'mobile',
|
|
@@ -151,7 +164,7 @@ const Manage = ({ url, t }: Props): JSX.Element => {
|
|
|
151
164
|
label: t('admin_agents.manage.subscription', { ns: 'common' }),
|
|
152
165
|
name: 'subscription_id',
|
|
153
166
|
type: 'select',
|
|
154
|
-
value: data?.user.subscription?.subscription.id,
|
|
167
|
+
value: data?.user.subscription?.subscription.id ?? 0,
|
|
155
168
|
values: subscriptions,
|
|
156
169
|
rules: 'required',
|
|
157
170
|
notice: t('admin_agents.manage.subscription_notice', { ns: 'common' })
|
|
@@ -185,31 +198,43 @@ const Manage = ({ url, t }: Props): JSX.Element => {
|
|
|
185
198
|
label: t('admin_agents.manage.unique', { ns: 'common' }),
|
|
186
199
|
name: 'unique',
|
|
187
200
|
type: 'select',
|
|
188
|
-
value: data?.user.comissions?.unique,
|
|
201
|
+
value: data?.user.comissions?.unique ?? 0,
|
|
189
202
|
values: getAllowed(t)
|
|
190
203
|
}, {
|
|
191
204
|
label: t('admin_agents.manage.api', { ns: 'common' }),
|
|
192
205
|
name: 'api',
|
|
193
206
|
type: 'select',
|
|
194
|
-
value: data?.user.api?.api,
|
|
207
|
+
value: data?.user.api?.api ?? 0,
|
|
195
208
|
values: getAllowed(t)
|
|
196
209
|
}, {
|
|
197
210
|
label: t('admin_agents.manage.bkt', { ns: 'common' }),
|
|
198
211
|
name: 'bkt',
|
|
199
212
|
type: 'select',
|
|
200
|
-
value: data?.user.api?.bkt,
|
|
213
|
+
value: data?.user.api?.bkt ?? 0,
|
|
214
|
+
values: getAllowed(t)
|
|
215
|
+
}, {
|
|
216
|
+
label: t('admin_agents.manage.stripe', { ns: 'common' }),
|
|
217
|
+
name: 'stripe',
|
|
218
|
+
type: 'select',
|
|
219
|
+
value: data?.user.api?.stripe ?? 0,
|
|
220
|
+
values: getAllowed(t)
|
|
221
|
+
}, {
|
|
222
|
+
label: t('admin_agents.manage.mollie', { ns: 'common' }),
|
|
223
|
+
name: 'mollie',
|
|
224
|
+
type: 'select',
|
|
225
|
+
value: data?.user.api?.mollie ?? 0,
|
|
201
226
|
values: getAllowed(t)
|
|
202
227
|
}, {
|
|
203
228
|
label: t('admin_agents.manage.devpos', { ns: 'common' }),
|
|
204
229
|
name: 'devpos',
|
|
205
230
|
type: 'select',
|
|
206
|
-
value: data?.user.api?.devpos,
|
|
231
|
+
value: data?.user.api?.devpos ?? 0,
|
|
207
232
|
values: getAllowed(t)
|
|
208
233
|
}, {
|
|
209
234
|
label: t('admin_agents.manage.external', { ns: 'common' }),
|
|
210
235
|
name: 'external',
|
|
211
236
|
type: 'select',
|
|
212
|
-
value: data?.user.comissions?.external,
|
|
237
|
+
value: data?.user.comissions?.external ?? 0,
|
|
213
238
|
values: getAllowed(t)
|
|
214
239
|
}, {
|
|
215
240
|
label: t('admin_agents.manage.devpos_settings', { ns: 'common' }),
|
|
@@ -222,7 +247,7 @@ const Manage = ({ url, t }: Props): JSX.Element => {
|
|
|
222
247
|
label: t('admin_agents.manage.status', { ns: 'common' }),
|
|
223
248
|
name: 'status',
|
|
224
249
|
type: 'select',
|
|
225
|
-
value: data?.user.status,
|
|
250
|
+
value: data?.user.status ?? 0,
|
|
226
251
|
values: GetStatus(t)
|
|
227
252
|
}, {
|
|
228
253
|
label: t('admin_agents.manage.display_email', { ns: 'common' }),
|