mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
fix issue: user trade access
This commit is contained in:
@@ -2,10 +2,6 @@ import { useMemo, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
import {
|
||||
useAllExternalUsers,
|
||||
userTypeEnum,
|
||||
} from "@/super-admin/hooks/useExternalUsers";
|
||||
import {
|
||||
ALL_TRADE_DIRECTIONS,
|
||||
TRADE_DIRECTION_LABELS,
|
||||
@@ -39,9 +35,9 @@ export default function TradeAccessPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const { data: usersResponse, isLoading: usersLoading } = useAllExternalUsers({
|
||||
userType: userTypeEnum.employee,
|
||||
take: 3000,
|
||||
const { data: usersResponse, isLoading: usersLoading } = useQuery({
|
||||
queryKey: ["staff-users", "employees"],
|
||||
queryFn: userTradeAccessService.employees,
|
||||
});
|
||||
|
||||
const { data: configs, isLoading: configsLoading } = useQuery({
|
||||
|
||||
@@ -25,7 +25,27 @@ export interface MyTradeAccess {
|
||||
directions: TradeDirection[];
|
||||
}
|
||||
|
||||
export interface StaffUser {
|
||||
id: string;
|
||||
/** Localized jsonb on iam.users — not a plain string. */
|
||||
name: { en?: string; am?: string } | null;
|
||||
username: string;
|
||||
email: string | null;
|
||||
}
|
||||
|
||||
export const userTradeAccessService = {
|
||||
/**
|
||||
* Employees to assign scopes to. Served by the freight API rather than IAM's
|
||||
* `/users/filter`, which 400s on its own pagination params (its @Query() DTO
|
||||
* omits skip/take/orderBy while the global whitelist pipe rejects them).
|
||||
*/
|
||||
employees: async (): Promise<{ items: StaffUser[] }> =>
|
||||
(
|
||||
await client.get("/staff/users", {
|
||||
params: { userType: "employee", pageSize: 100 },
|
||||
})
|
||||
).data,
|
||||
|
||||
/** All configured per-user scopes (admin only). */
|
||||
list: async (): Promise<UserTradeAccessRow[]> =>
|
||||
(await client.get("/user-trade-access")).data,
|
||||
|
||||
Reference in New Issue
Block a user