@autobusal/admin-agents 1.2.2 → 1.3.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 (2) hide show
  1. package/Manage.tsx +51 -14
  2. package/package.json +1 -1
package/Manage.tsx CHANGED
@@ -1,9 +1,11 @@
1
+ import { useState } from 'react';
1
2
  import { TFunction } from 'i18next';
2
3
  import { useParams, useNavigate, useSearchParams } from 'react-router-dom';
3
4
  import { Meta, BackWithTitle, Viewer, Box, IpLogs, ApiDetails } from '@autobusal/common';
4
5
  import { usePage, useBreadcrumbs, useSubscriptions, useCountries, useOperators } from '@autobusal/hooks';
5
6
  import { GetStatus, getAllowed, success } from '@autobusal/utilities';
6
7
  import { AgentData } from '@autobusal/providers/types/agents';
8
+ import { PartnerApi, TokenRevealModal } from '@autobusal/admin-api-consumers';
7
9
  import { useGetAgent, usePostAgent, useDeleteAgent } from './services';
8
10
 
9
11
  interface Props {
@@ -28,6 +30,12 @@ const Manage = ({ url, t }: Props): JSX.Element => {
28
30
  const operators = useOperators();
29
31
 
30
32
  const { data, isFetching } = useGetAgent(id);
33
+
34
+ // Claude - 2026-09-24: the partner API key, shown once. Held HERE and not
35
+ // in the panel: the panel sits inside Viewer, which swaps its form for a
36
+ // loading box while the record refetches after the key is issued - taking
37
+ // the panel, and any modal it opened, with it.
38
+ const [ revealToken, setRevealToken ] = useState<string | null>(null);
31
39
 
32
40
  /*
33
41
  * Claude - 2026-08-29 (audit A4-09, low)
@@ -213,28 +221,33 @@ const Manage = ({ url, t }: Props): JSX.Element => {
213
221
  label: t('admin_agents.manage.departure', { ns: 'common' }),
214
222
  name: 'departure',
215
223
  type: 'text',
216
- value: data?.user.comissions?.departure_edit
224
+ value: data?.user.comissions?.departure_edit,
225
+ notice: t('admin_agents.manage.departure_notice', { ns: 'common' })
217
226
  }, {
218
227
  label: t('admin_agents.manage.departure_self', { ns: 'common' }),
219
228
  name: 'departure_self',
220
229
  type: 'text',
221
- value: data?.user.comissions?.departure_self_edit
230
+ value: data?.user.comissions?.departure_self_edit,
231
+ notice: t('admin_agents.manage.departure_self_notice', { ns: 'common' })
222
232
  }, {}, {
223
233
  label: t('admin_agents.manage.return', { ns: 'common' }),
224
234
  name: 'return',
225
235
  type: 'text',
226
- value: data?.user.comissions?.return_edit
236
+ value: data?.user.comissions?.return_edit,
237
+ notice: t('admin_agents.manage.return_notice', { ns: 'common' })
227
238
  }, {
228
239
  label: t('admin_agents.manage.return_self', { ns: 'common' }),
229
240
  name: 'return_self',
230
241
  type: 'text',
231
- value: data?.user.comissions?.return_self_edit
242
+ value: data?.user.comissions?.return_self_edit,
243
+ notice: t('admin_agents.manage.return_self_notice', { ns: 'common' })
232
244
  }, {}, {
233
245
  label: t('admin_agents.manage.unique', { ns: 'common' }),
234
246
  name: 'unique',
235
247
  type: 'select',
236
248
  value: data?.user.comissions?.unique ?? 0,
237
- values: getAllowed(t)
249
+ values: getAllowed(t),
250
+ notice: t('admin_agents.manage.unique_notice', { ns: 'common' })
238
251
  }, {
239
252
  // Claude - 2026-08-22: the floor of the agent's funds balance
240
253
  // for website sales - 0 = prepaid (the historic behaviour),
@@ -244,14 +257,33 @@ const Manage = ({ url, t }: Props): JSX.Element => {
244
257
  name: 'credit_limit',
245
258
  type: 'text',
246
259
  value: data?.credit_limit ?? 0,
247
- rules: 'required|numeric'
248
- }, {
249
- label: t('admin_agents.manage.api', { ns: 'common' }),
250
- name: 'api',
251
- type: 'select',
252
- value: data?.user.api?.api ?? 0,
253
- values: getAllowed(t)
254
- }, {
260
+ rules: 'required|numeric',
261
+ notice: t('admin_agents.manage.credit_limit_notice', { ns: 'common' })
262
+ }, ...(id > 0 ? [{
263
+ /*
264
+ * Claude - 2026-09-24 (Ferjolt: one API login type). The old
265
+ * "API Access" yes/no wrote users_api.api, which is 1 for every
266
+ * account and gated nothing. Partner access is the API-consumer
267
+ * flag now, and this panel sets it the way the API Consumers
268
+ * screen does - key issued and shown once - so the agency then
269
+ * appears there too, with its Receivables and reports, while
270
+ * keeping its website account. A new agency is saved first.
271
+ */
272
+ label: t('admin_agents.manage.partner_api', { ns: 'common' }),
273
+ name: 'partner_api',
274
+ type: 'component' as const,
275
+ value: (
276
+ <PartnerApi
277
+ agentId={ id }
278
+ isConsumer={ Boolean(data?.is_api_consumer) }
279
+ hasToken={ data?.user.api?.has_token ?? false }
280
+ enabled={ data?.user.api?.api ?? 0 }
281
+ refresh={ [['admin-agents-manage', { id }], ['admin-agents']] }
282
+ onReveal={ setRevealToken }
283
+ t={ t }
284
+ />
285
+ )
286
+ }] : []), {
255
287
  label: t('admin_agents.manage.bkt', { ns: 'common' }),
256
288
  name: 'bkt',
257
289
  type: 'select',
@@ -280,7 +312,8 @@ const Manage = ({ url, t }: Props): JSX.Element => {
280
312
  name: 'external',
281
313
  type: 'select',
282
314
  value: data?.user.comissions?.external ?? 0,
283
- values: getAllowed(t)
315
+ values: getAllowed(t),
316
+ notice: t('admin_agents.manage.external_notice', { ns: 'common' })
284
317
  }, {
285
318
  label: t('admin_agents.manage.devpos_settings', { ns: 'common' }),
286
319
  name: 'devpos_settings',
@@ -321,6 +354,10 @@ const Manage = ({ url, t }: Props): JSX.Element => {
321
354
  onSave={ onSave }
322
355
  onDelete={ onDelete }
323
356
  />
357
+
358
+ { revealToken && (
359
+ <TokenRevealModal token={ revealToken } t={ t } onClose={ () => setRevealToken(null) } />
360
+ ) }
324
361
  </Meta>
325
362
  );
326
363
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/admin-agents",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts",