@autobusal/admin-agents 1.2.1 → 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.
- package/Manage.tsx +37 -7
- package/package.json +5 -2
- package/services.ts +15 -5
- package/CHANGELOG.md +0 -56
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
package/services.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseMutationResult, UseQueryResult, UseSuspenseQueryResult, useMutation, useQuery, useSuspenseQuery } from '@tanstack/react-query';
|
|
1
|
+
import { UseMutationResult, UseQueryResult, UseSuspenseQueryResult, useMutation, useQuery, useSuspenseQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { apiClient } from '@autobusal/providers';
|
|
3
3
|
import { PaginationData } from '@autobusal/providers/types/pagination';
|
|
4
4
|
import { AgentData } from '@autobusal/providers/types/agents';
|
|
@@ -36,9 +36,19 @@ export const useGetAgent = (id: number): UseSuspenseQueryResult<AgentData> => (
|
|
|
36
36
|
})
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
export const usePostAgent = (id: number): UseMutationResult<void, Error, AgentData, unknown> =>
|
|
40
|
-
|
|
39
|
+
export const usePostAgent = (id: number): UseMutationResult<void, Error, AgentData, unknown> => {
|
|
40
|
+
const queryClient = useQueryClient();
|
|
41
|
+
|
|
42
|
+
return useMutation({
|
|
41
43
|
mutationKey: ['admin-agents-save', { id }],
|
|
44
|
+
// Claude - 2026-09-06: re-read the record after a save. With Save & Stay
|
|
45
|
+
// the page stays on stale data, and the one field that only the server
|
|
46
|
+
// can fill in - the URL of an image just uploaded - never appeared
|
|
47
|
+
// until a reload. The list is refreshed too, for the same reason.
|
|
48
|
+
onSuccess: () => {
|
|
49
|
+
queryClient.invalidateQueries({ queryKey: ['admin-agents-manage', { id }] });
|
|
50
|
+
queryClient.invalidateQueries({ queryKey: ['admin-agents'] });
|
|
51
|
+
},
|
|
42
52
|
mutationFn: async (data: AgentData) => {
|
|
43
53
|
const formData = new FormData();
|
|
44
54
|
|
|
@@ -69,8 +79,8 @@ export const usePostAgent = (id: number): UseMutationResult<void, Error, AgentDa
|
|
|
69
79
|
response.data
|
|
70
80
|
));
|
|
71
81
|
}
|
|
72
|
-
})
|
|
73
|
-
|
|
82
|
+
});
|
|
83
|
+
};
|
|
74
84
|
|
|
75
85
|
export const useDeleteAgent = (): UseMutationResult<void, Error, number, unknown> => (
|
|
76
86
|
useMutation({
|
package/CHANGELOG.md
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.2.1 - 2026-08-29
|
|
4
|
-
|
|
5
|
-
- The heading names the ACCOUNT as well as the company (audit A4-09). This screen is addressed by `agents`.`id` while /account/funds/manage is addressed by `users`.`id`, so the same number opens two different agencies - and company names are not unique either (three agencies are registered as "API Company"), so the name alone could not say which record was open.
|
|
6
|
-
|
|
7
|
-
## 1.2.0 (2026-08-29)
|
|
8
|
-
|
|
9
|
-
- Editors offer Save & Close alongside Save & Stay, so correcting a record no longer bounces you back to its list every time (opt-in per page, editing only).
|
|
10
|
-
|
|
11
|
-
## 1.1.7 (2026-08-28)
|
|
12
|
-
|
|
13
|
-
- Company minimum length 2, matching the server rule - two-letter brand names can be saved (sweep #56).
|
|
14
|
-
|
|
15
|
-
## 1.1.6
|
|
16
|
-
|
|
17
|
-
### Fixed
|
|
18
|
-
|
|
19
|
-
- **License No. is optional on the manage form.** The agent sign-up stopped collecting it on 2026-08-07 and the column is nullable server-side, but the form's required rule made approving a self-registered agency impossible without inventing a number. (Audit AUTH-02b.)
|
|
20
|
-
|
|
21
|
-
## 1.1.5
|
|
22
|
-
|
|
23
|
-
### Added
|
|
24
|
-
|
|
25
|
-
- **Credit limit on the agent form.** Ordinary website agents can now sell
|
|
26
|
-
postpaid: obtapi's funds gate measures the balance's resting position -
|
|
27
|
-
funds minus (amount less commission) - against `-credit_limit` instead of
|
|
28
|
-
refusing anything below the gross total. 0 keeps the historic prepaid
|
|
29
|
-
behaviour; a positive number lets the balance run down to -that-much,
|
|
30
|
-
restored when an admin records the agent's payment on the funds screen.
|
|
31
|
-
|
|
32
|
-
## [1.1.4] - 2026-08-07
|
|
33
|
-
|
|
34
|
-
### Fixed
|
|
35
|
-
|
|
36
|
-
- **Country select no longer defaults to Afghanistan.** `value` was `?? 0`,
|
|
37
|
-
which matches no country, so opening an agent with none on file and
|
|
38
|
-
pressing save filed them in Afghanistan.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## 1.1.3
|
|
42
|
-
|
|
43
|
-
### Changed
|
|
44
|
-
|
|
45
|
-
- **Address is a single-line input, not a textarea**, matching the other
|
|
46
|
-
address fields across the apps.
|
|
47
|
-
|
|
48
|
-
All notable changes to this package are documented here. This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
|
|
49
|
-
|
|
50
|
-
## [1.1.2] - 2026-07-19
|
|
51
|
-
|
|
52
|
-
### Fixed
|
|
53
|
-
|
|
54
|
-
- `Manage.tsx`: the agent edit form's email field is now hydrated with the existing value (`value: data?.user.email`). Previously the email `<input>` rendered empty when editing an agent, so the field appeared blank and a save could overwrite the stored email with an empty value.
|
|
55
|
-
|
|
56
|
-
Authored by Ferjolt Ozuni. Consolidated from the magus and alvavel whitelabel patch sets into canonical @autobusal source (eliminates per-repo patch-package divergence).
|