feat: integrate operator queue into Campaign
This commit is contained in:
57
webui/src/features/campaigns/CampaignModulePage.tsx
Normal file
57
webui/src/features/campaigns/CampaignModulePage.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import { lazy } from "react";
|
||||
import {
|
||||
ModuleSubnav,
|
||||
hasAnyScope,
|
||||
useGuardedNavigate,
|
||||
type ApiSettings,
|
||||
type AuthInfo,
|
||||
type ModuleSubnavGroup
|
||||
} from "@govoplan/core-webui";
|
||||
import { OPERATOR_QUEUE_ROUTE_SCOPES } from "../operator/operatorQueueAccess";
|
||||
|
||||
const CampaignListPage = lazy(() => import("./CampaignListPage"));
|
||||
const OperatorQueuePage = lazy(() => import("../operator/OperatorQueuePage"));
|
||||
|
||||
export type CampaignModuleSection = "campaigns" | "queue";
|
||||
|
||||
export default function CampaignModulePage({
|
||||
active,
|
||||
settings,
|
||||
auth
|
||||
}: {
|
||||
active: CampaignModuleSection;
|
||||
settings: ApiSettings;
|
||||
auth: AuthInfo;
|
||||
}) {
|
||||
const navigate = useGuardedNavigate();
|
||||
const groups: ModuleSubnavGroup<CampaignModuleSection>[] = [{
|
||||
items: [
|
||||
{
|
||||
id: "campaigns",
|
||||
label: "i18n:govoplan-campaign.all_campaigns.2bd1ee3a",
|
||||
primary: true
|
||||
},
|
||||
...(hasAnyScope(auth, OPERATOR_QUEUE_ROUTE_SCOPES)
|
||||
? [{
|
||||
id: "queue" as const,
|
||||
label: "i18n:govoplan-campaign.operator_queue.72492fb5"
|
||||
}]
|
||||
: [])
|
||||
]
|
||||
}];
|
||||
|
||||
function select(section: CampaignModuleSection) {
|
||||
navigate(section === "queue" ? "/campaigns/queue" : "/campaigns");
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="workspace campaign-module-workspace">
|
||||
<ModuleSubnav active={active} groups={groups} onSelect={select} />
|
||||
<section className="workspace-content">
|
||||
{active === "queue"
|
||||
? <OperatorQueuePage settings={settings} auth={auth} />
|
||||
: <CampaignListPage settings={settings} />}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user