@autobusal/admin-agents 1.2.2 → 1.3.0

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 +37 -7
  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)
@@ -245,13 +253,31 @@ const Manage = ({ url, t }: Props): JSX.Element => {
245
253
  type: 'text',
246
254
  value: data?.credit_limit ?? 0,
247
255
  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
- }, {
256
+ }, ...(id > 0 ? [{
257
+ /*
258
+ * Claude - 2026-09-24 (Ferjolt: one API login type). The old
259
+ * "API Access" yes/no wrote users_api.api, which is 1 for every
260
+ * account and gated nothing. Partner access is the API-consumer
261
+ * flag now, and this panel sets it the way the API Consumers
262
+ * screen does - key issued and shown once - so the agency then
263
+ * appears there too, with its Receivables and reports, while
264
+ * keeping its website account. A new agency is saved first.
265
+ */
266
+ label: t('admin_agents.manage.partner_api', { ns: 'common' }),
267
+ name: 'partner_api',
268
+ type: 'component' as const,
269
+ value: (
270
+ <PartnerApi
271
+ agentId={ id }
272
+ isConsumer={ Boolean(data?.is_api_consumer) }
273
+ hasToken={ data?.user.api?.has_token ?? false }
274
+ enabled={ data?.user.api?.api ?? 0 }
275
+ refresh={ [['admin-agents-manage', { id }], ['admin-agents']] }
276
+ onReveal={ setRevealToken }
277
+ t={ t }
278
+ />
279
+ )
280
+ }] : []), {
255
281
  label: t('admin_agents.manage.bkt', { ns: 'common' }),
256
282
  name: 'bkt',
257
283
  type: 'select',
@@ -321,6 +347,10 @@ const Manage = ({ url, t }: Props): JSX.Element => {
321
347
  onSave={ onSave }
322
348
  onDelete={ onDelete }
323
349
  />
350
+
351
+ { revealToken && (
352
+ <TokenRevealModal token={ revealToken } t={ t } onClose={ () => setRevealToken(null) } />
353
+ ) }
324
354
  </Meta>
325
355
  );
326
356
  };
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.0",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts",