feat(settlement, admin): introduce new types and functions for downline share and settlement period hints
Added new types for downline share breakdown and settlement period open hints to enhance the agent settlement API. Updated the admin console components to support these new features, improving the user experience with better data presentation and interaction. Additionally, refined the date range field to accommodate new calendar markers and hints, ensuring a more intuitive interface for managing settlement periods.
This commit is contained in:
@@ -1,23 +1,42 @@
|
||||
export type SettlementPeriodView = "bills" | "ledger";
|
||||
export type SettlementPeriodView = "bills" | "operations" | "ledger";
|
||||
|
||||
const VALID_VIEWS: SettlementPeriodView[] = ["bills", "ledger"];
|
||||
const VALID_VIEWS: SettlementPeriodView[] = ["bills", "operations", "ledger"];
|
||||
|
||||
export function settlementCenterListHref(): string {
|
||||
function parsePositiveInt(raw: string | null): number | null {
|
||||
if (raw === null || raw === "") {
|
||||
return null;
|
||||
}
|
||||
const value = Number(raw);
|
||||
return Number.isInteger(value) && value > 0 ? value : null;
|
||||
}
|
||||
|
||||
export function settlementCenterListHref(adminSiteId?: number | null): string {
|
||||
if (adminSiteId != null && adminSiteId > 0) {
|
||||
return `/admin/settlement-center?site=${adminSiteId}`;
|
||||
}
|
||||
return "/admin/settlement-center";
|
||||
}
|
||||
|
||||
export function settlementPeriodViewHref(
|
||||
periodId: number,
|
||||
view: SettlementPeriodView = "bills",
|
||||
adminSiteId?: number | null,
|
||||
): string {
|
||||
return `/admin/settlement-center?period=${periodId}&view=${view}`;
|
||||
const params = new URLSearchParams({
|
||||
period: String(periodId),
|
||||
view,
|
||||
});
|
||||
if (adminSiteId != null && adminSiteId > 0) {
|
||||
params.set("site", String(adminSiteId));
|
||||
}
|
||||
return `/admin/settlement-center?${params.toString()}`;
|
||||
}
|
||||
|
||||
export function parseSettlementCenterView(
|
||||
siteRaw: string | null,
|
||||
periodRaw: string | null,
|
||||
viewRaw: string | null,
|
||||
): { periodId: number | null; view: SettlementPeriodView } {
|
||||
const periodId = periodRaw !== null && periodRaw !== "" ? Number(periodRaw) : NaN;
|
||||
): { siteId: number | null; periodId: number | null; view: SettlementPeriodView } {
|
||||
const normalizedView = viewRaw === "reports" ? "bills" : viewRaw;
|
||||
const view =
|
||||
normalizedView !== null && VALID_VIEWS.includes(normalizedView as SettlementPeriodView)
|
||||
@@ -25,7 +44,8 @@ export function parseSettlementCenterView(
|
||||
: "bills";
|
||||
|
||||
return {
|
||||
periodId: Number.isInteger(periodId) && periodId > 0 ? periodId : null,
|
||||
siteId: parsePositiveInt(siteRaw),
|
||||
periodId: parsePositiveInt(periodRaw),
|
||||
view,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user