mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 20:38:17 +00:00
fix issue, add transit flow, fix cancellation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { api } from "../auth/http";
|
||||
import { api as apiClient } from "../auth/http";
|
||||
import { URL_CONSTANTS } from "../constants/URLS";
|
||||
import type { ResetChannel } from "../types/shippingLineCompany";
|
||||
|
||||
export interface TransitAgent {
|
||||
id: string;
|
||||
@@ -7,14 +8,53 @@ export interface TransitAgent {
|
||||
validFrom: string;
|
||||
validTo: string;
|
||||
isActive: boolean;
|
||||
/** Null on every agent that exists only as a GL-assignable roster entry. */
|
||||
email?: string | null;
|
||||
phoneNumber?: string | null;
|
||||
/** True once an IAM account backs the agent — i.e. it can sign in. */
|
||||
hasAccount?: boolean;
|
||||
}
|
||||
|
||||
export interface InviteTransitAgentDto {
|
||||
email: string;
|
||||
phoneNumber?: string;
|
||||
username?: string;
|
||||
}
|
||||
|
||||
/** What the API reports back about an activation send. */
|
||||
export interface ActivationSendResult {
|
||||
maskedTarget: string;
|
||||
channel: string;
|
||||
expiresAt: string;
|
||||
}
|
||||
|
||||
export const transitAgentsService = {
|
||||
/** Active + currently inside its validity window — the assignment dropdown. */
|
||||
async listAssignable() {
|
||||
const response = await api.get<TransitAgent[]>(
|
||||
const response = await apiClient.get<TransitAgent[]>(
|
||||
URL_CONSTANTS.RULE_ENGINE.TRANSIT_AGENTS_ASSIGNABLE,
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create the portal account for an agent that has none and send its
|
||||
* activation link. Separate from the rule-engine CRUD update because it mints
|
||||
* an IAM user, which a field edit must never do implicitly.
|
||||
*/
|
||||
async invite(id: string, dto: InviteTransitAgentDto) {
|
||||
const response = await apiClient.post<{
|
||||
agent: TransitAgent;
|
||||
activationSentTo: string | null;
|
||||
}>(URL_CONSTANTS.RULE_ENGINE.TRANSIT_AGENT_INVITE(id), dto);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async resendActivation(id: string, channel: ResetChannel) {
|
||||
const response = await apiClient.post<ActivationSendResult>(
|
||||
URL_CONSTANTS.RULE_ENGINE.TRANSIT_AGENT_RESEND_ACTIVATION(id),
|
||||
{ channel },
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user