@autobusal/admin-agents 1.2.0 → 1.2.2

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 CHANGED
@@ -29,7 +29,20 @@ const Manage = ({ url, t }: Props): JSX.Element => {
29
29
 
30
30
  const { data, isFetching } = useGetAgent(id);
31
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' });
32
+ /*
33
+ * Claude - 2026-08-29 (audit A4-09, low)
34
+ *
35
+ * THE COMPANY AND THE ACCOUNT IT BELONGS TO. This screen is addressed by
36
+ * `agents`.`id` while /account/funds/manage is addressed by `users`.`id`,
37
+ * so the same number in the URL opens two different agencies on the two
38
+ * screens - demonstrated live in the audit, where a credit limit was set on
39
+ * an agency nobody meant to touch. Company names are not unique either
40
+ * (three separate agencies are registered as "API Company"), so the
41
+ * heading alone could not say which record was open. The email can.
42
+ */
43
+ const company = [data?.company, data?.user?.email].filter(Boolean).join(' · ');
44
+
45
+ const title = id > 0 ? t('admin_agents.manage.title.update', { company, ns: 'common' }) : t('admin_agents.manage.title.new', { ns: 'common' });
33
46
 
34
47
  useBreadcrumbs(title, [{ name: t('admin_agents.browse.title', { ns: 'common' }), url }]);
35
48
 
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@autobusal/admin-agents",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
- "main": "index.ts"
6
+ "main": "index.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ }
7
10
  }
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
- useMutation({
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,52 +0,0 @@
1
- # Changelog
2
-
3
- ## 1.2.0 (2026-08-29)
4
-
5
- - 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).
6
-
7
- ## 1.1.7 (2026-08-28)
8
-
9
- - Company minimum length 2, matching the server rule - two-letter brand names can be saved (sweep #56).
10
-
11
- ## 1.1.6
12
-
13
- ### Fixed
14
-
15
- - **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.)
16
-
17
- ## 1.1.5
18
-
19
- ### Added
20
-
21
- - **Credit limit on the agent form.** Ordinary website agents can now sell
22
- postpaid: obtapi's funds gate measures the balance's resting position -
23
- funds minus (amount less commission) - against `-credit_limit` instead of
24
- refusing anything below the gross total. 0 keeps the historic prepaid
25
- behaviour; a positive number lets the balance run down to -that-much,
26
- restored when an admin records the agent's payment on the funds screen.
27
-
28
- ## [1.1.4] - 2026-08-07
29
-
30
- ### Fixed
31
-
32
- - **Country select no longer defaults to Afghanistan.** `value` was `?? 0`,
33
- which matches no country, so opening an agent with none on file and
34
- pressing save filed them in Afghanistan.
35
-
36
-
37
- ## 1.1.3
38
-
39
- ### Changed
40
-
41
- - **Address is a single-line input, not a textarea**, matching the other
42
- address fields across the apps.
43
-
44
- All notable changes to this package are documented here. This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
45
-
46
- ## [1.1.2] - 2026-07-19
47
-
48
- ### Fixed
49
-
50
- - `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.
51
-
52
- Authored by Ferjolt Ozuni. Consolidated from the magus and alvavel whitelabel patch sets into canonical @autobusal source (eliminates per-repo patch-package divergence).