@autobusal/admin-agents 1.0.2 → 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.
Files changed (3) hide show
  1. package/Browse.tsx +3 -1
  2. package/Manage.tsx +38 -11
  3. package/package.json +1 -1
package/Browse.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { useNavigate, useSearchParams } from 'react-router-dom';
3
3
  import { Meta, ContactInfo, Avatar, Table, Row } from '@autobusal/common';
4
- import { usePage } from '@autobusal/hooks';
4
+ import { usePage, useBreadcrumbs } from '@autobusal/hooks';
5
5
  import { DisplayStatus, getParams, success } from '@autobusal/utilities';
6
6
  import { useGetAgents, useDeleteAgent } from './services';
7
7
 
@@ -15,6 +15,8 @@ const Browse = ({ url, t }: Props): JSX.Element => {
15
15
 
16
16
  usePage('agents');
17
17
 
18
+ useBreadcrumbs(t('admin_agents.browse.title', { ns: 'common' }));
19
+
18
20
  const { data, isLoading, isFetching, refetch } = useGetAgents(getParams(searchParams, ['page', 'sort', 'order', 'q']));
19
21
 
20
22
  const { mutate: Delete } = useDeleteAgent();
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, 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,15 +22,25 @@ 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
 
28
30
  const { data, isFetching } = useGetAgent(id);
31
+
32
+ const title = id > 0 ? t('admin_agents.manage.title.update', { company: data?.company, ns: 'common' }) : t('admin_agents.manage.title.new', { ns: 'common' });
33
+
34
+ useBreadcrumbs(title, [{ name: t('admin_agents.browse.title', { ns: 'common' }), url }]);
29
35
 
30
36
  const { mutate: Update, isPending: isPendingSave } = usePostAgent(id);
31
37
 
32
38
  const { mutate: Delete, isPending: isPendingDelete } = useDeleteAgent();
33
39
 
40
+ if (isLoading) {
41
+ return <Box />;
42
+ }
43
+
34
44
  const onSave = (data: AgentData): void => {
35
45
  Update(data, {
36
46
  onSuccess: () => {
@@ -50,8 +60,6 @@ const Manage = ({ url, t }: Props): JSX.Element => {
50
60
  }
51
61
  });
52
62
  };
53
-
54
- const title = id > 0 ? t('admin_agents.manage.title.update', { company: data?.company, ns: 'common' }) : t('admin_agents.manage.title.new', { ns: 'common' });
55
63
 
56
64
  return (
57
65
  <Meta title={ title }>
@@ -95,6 +103,13 @@ const Manage = ({ url, t }: Props): JSX.Element => {
95
103
  type: 'text',
96
104
  value: data?.city,
97
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'
98
113
  }, {}, {
99
114
  label: t('admin_agents.manage.mobile', { ns: 'common' }),
100
115
  name: 'mobile',
@@ -149,7 +164,7 @@ const Manage = ({ url, t }: Props): JSX.Element => {
149
164
  label: t('admin_agents.manage.subscription', { ns: 'common' }),
150
165
  name: 'subscription_id',
151
166
  type: 'select',
152
- value: data?.user.subscription?.subscription.id,
167
+ value: data?.user.subscription?.subscription.id ?? 0,
153
168
  values: subscriptions,
154
169
  rules: 'required',
155
170
  notice: t('admin_agents.manage.subscription_notice', { ns: 'common' })
@@ -183,31 +198,43 @@ const Manage = ({ url, t }: Props): JSX.Element => {
183
198
  label: t('admin_agents.manage.unique', { ns: 'common' }),
184
199
  name: 'unique',
185
200
  type: 'select',
186
- value: data?.user.comissions?.unique,
201
+ value: data?.user.comissions?.unique ?? 0,
187
202
  values: getAllowed(t)
188
203
  }, {
189
204
  label: t('admin_agents.manage.api', { ns: 'common' }),
190
205
  name: 'api',
191
206
  type: 'select',
192
- value: data?.user.api?.api,
207
+ value: data?.user.api?.api ?? 0,
193
208
  values: getAllowed(t)
194
209
  }, {
195
210
  label: t('admin_agents.manage.bkt', { ns: 'common' }),
196
211
  name: 'bkt',
197
212
  type: 'select',
198
- 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,
199
226
  values: getAllowed(t)
200
227
  }, {
201
228
  label: t('admin_agents.manage.devpos', { ns: 'common' }),
202
229
  name: 'devpos',
203
230
  type: 'select',
204
- value: data?.user.api?.devpos,
231
+ value: data?.user.api?.devpos ?? 0,
205
232
  values: getAllowed(t)
206
233
  }, {
207
234
  label: t('admin_agents.manage.external', { ns: 'common' }),
208
235
  name: 'external',
209
236
  type: 'select',
210
- value: data?.user.comissions?.external,
237
+ value: data?.user.comissions?.external ?? 0,
211
238
  values: getAllowed(t)
212
239
  }, {
213
240
  label: t('admin_agents.manage.devpos_settings', { ns: 'common' }),
@@ -220,7 +247,7 @@ const Manage = ({ url, t }: Props): JSX.Element => {
220
247
  label: t('admin_agents.manage.status', { ns: 'common' }),
221
248
  name: 'status',
222
249
  type: 'select',
223
- value: data?.user.status,
250
+ value: data?.user.status ?? 0,
224
251
  values: GetStatus(t)
225
252
  }, {
226
253
  label: t('admin_agents.manage.display_email', { ns: 'common' }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/admin-agents",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }