实现制度签收轻量回执(05-28-oa-policy-acknowledgement-v1)
这个提交包含在:
+55
-16
@@ -1,5 +1,29 @@
|
||||
import { apiRequestData } from "./http";
|
||||
|
||||
export type AnnouncementCategory = "general" | "policy";
|
||||
export type AnnouncementAcknowledgementStatus = "not_required" | "pending" | "acknowledged" | "overdue";
|
||||
|
||||
export type PortalAnnouncementAcknowledgement = {
|
||||
status: AnnouncementAcknowledgementStatus;
|
||||
acknowledgedAt: string | null;
|
||||
overdue: boolean;
|
||||
};
|
||||
|
||||
export type PortalAnnouncementAcknowledgementSummary = {
|
||||
required: boolean;
|
||||
totalActiveEmployees: number;
|
||||
acknowledgedCount: number;
|
||||
pendingCount: number;
|
||||
overdueCount: number;
|
||||
};
|
||||
|
||||
export type PortalAnnouncementPendingEmployee = {
|
||||
id: string;
|
||||
employeeNo: string;
|
||||
name: string;
|
||||
status: "pending" | "overdue";
|
||||
};
|
||||
|
||||
export type PortalAnnouncement = {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -9,16 +33,18 @@ export type PortalAnnouncement = {
|
||||
endsAt: string | null;
|
||||
enabled: boolean;
|
||||
priority: number;
|
||||
category: AnnouncementCategory;
|
||||
requiresAcknowledgement: boolean;
|
||||
acknowledgementStatement: string | null;
|
||||
acknowledgementDueAt: string | null;
|
||||
acknowledgement?: PortalAnnouncementAcknowledgement;
|
||||
acknowledgementSummary?: PortalAnnouncementAcknowledgementSummary;
|
||||
pendingEmployees?: PortalAnnouncementPendingEmployee[];
|
||||
createdAt: string | null;
|
||||
updatedAt: string | null;
|
||||
};
|
||||
|
||||
export async function fetchAnnouncements(manage = false) {
|
||||
const suffix = manage ? "?manage=1" : "";
|
||||
return apiRequestData<{ items: PortalAnnouncement[] }>(`/api/announcements${suffix}`);
|
||||
}
|
||||
|
||||
export async function createAnnouncement(payload: {
|
||||
export type AnnouncementWritePayload = {
|
||||
title: string;
|
||||
summary: string;
|
||||
linkUrl?: string | null;
|
||||
@@ -26,22 +52,25 @@ export async function createAnnouncement(payload: {
|
||||
endsAt?: string | null;
|
||||
enabled?: boolean;
|
||||
priority?: number;
|
||||
}) {
|
||||
category?: AnnouncementCategory;
|
||||
requiresAcknowledgement?: boolean;
|
||||
acknowledgementStatement?: string | null;
|
||||
acknowledgementDueAt?: string | null;
|
||||
};
|
||||
|
||||
export async function fetchAnnouncements(manage = false) {
|
||||
const suffix = manage ? "?manage=1" : "";
|
||||
return apiRequestData<{ items: PortalAnnouncement[] }>(`/api/announcements${suffix}`);
|
||||
}
|
||||
|
||||
export async function createAnnouncement(payload: AnnouncementWritePayload) {
|
||||
return apiRequestData<{ item: PortalAnnouncement }>("/api/announcements", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateAnnouncement(id: string, payload: Partial<{
|
||||
title: string;
|
||||
summary: string;
|
||||
linkUrl: string | null;
|
||||
startsAt: string | null;
|
||||
endsAt: string | null;
|
||||
enabled: boolean;
|
||||
priority: number;
|
||||
}>) {
|
||||
export async function updateAnnouncement(id: string, payload: Partial<AnnouncementWritePayload>) {
|
||||
return apiRequestData<{ item: PortalAnnouncement }>(`/api/announcements/${id}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
@@ -54,3 +83,13 @@ export async function archiveAnnouncement(id: string) {
|
||||
body: JSON.stringify({}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function acknowledgeAnnouncement(id: string) {
|
||||
return apiRequestData<{ item: { id: string | null; announcementId: string; status: "acknowledged"; acknowledgedAt: string | null } }>(
|
||||
`/api/announcements/${id}/acknowledge`,
|
||||
{
|
||||
method: "POST",
|
||||
body: JSON.stringify({ confirmed: true }),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户