feat(schedule): remove sourceType from schedule models and payloads

This commit is contained in:
mlogclub
2026-04-29 15:09:35 +08:00
parent e56fe82b3a
commit 6331ce32c4
12 changed files with 81 additions and 119 deletions
@@ -146,7 +146,6 @@ function buildMovePayload(item: AdminAgentTeamSchedule, date: string): UpdateAdm
teamId: item.teamId,
startAt: formatDateTimeValue(nextStart),
endAt: formatDateTimeValue(nextEnd),
sourceType: item.sourceType,
remark: item.remark,
}
}
@@ -177,7 +176,6 @@ function buildResizePayload(
teamId: item.teamId,
startAt: formatDateTimeValue(startAt),
endAt: formatDateTimeValue(endAt),
sourceType: item.sourceType,
remark: item.remark,
}
}
@@ -242,7 +240,6 @@ export function ScheduleCalendar({
teamId: defaultTeamID || undefined,
startAt: formatDateTimeValue(startAt),
endAt: formatDateTimeValue(endAt),
sourceType: "manual",
remark: "",
})
}
@@ -21,7 +21,6 @@ import {
} from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { OptionCombobox } from "@/components/option-combobox"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Textarea } from "@/components/ui/textarea"
import {
type AdminAgentTeam,
@@ -41,17 +40,10 @@ type ScheduleEditDialogProps = {
onDelete?: (id: number) => Promise<void>
}
const sourceTypeOptions = [
{ value: "manual", label: "手工录入" },
{ value: "batch_import", label: "批量导入" },
{ value: "template_generate", label: "模板生成" },
] as const
const emptyForm: EditForm = {
teamId: "",
startAt: "",
endAt: "",
sourceType: "manual",
remark: "",
}
@@ -59,7 +51,6 @@ const editFormSchema = z.object({
teamId: z.string().trim().regex(/^\d+$/, "请选择客服组"),
startAt: z.string().trim().min(1, "开始时间不能为空"),
endAt: z.string().trim().min(1, "结束时间不能为空"),
sourceType: z.enum(["manual", "batch_import", "template_generate"], { message: "请选择排班来源" }),
remark: z.string().trim(),
}).superRefine((value, ctx) => {
const startAt = parseDateTimeLocal(value.startAt)
@@ -133,7 +124,6 @@ function buildForm(item: AdminAgentTeamSchedule | null, defaultValues?: Partial<
teamId: defaultValues?.teamId ? String(defaultValues.teamId) : emptyForm.teamId,
startAt: toDateTimeLocal(defaultValues?.startAt),
endAt: toDateTimeLocal(defaultValues?.endAt),
sourceType: (defaultValues?.sourceType as EditForm["sourceType"] | undefined) ?? emptyForm.sourceType,
remark: defaultValues?.remark ?? emptyForm.remark,
}
}
@@ -141,7 +131,6 @@ function buildForm(item: AdminAgentTeamSchedule | null, defaultValues?: Partial<
teamId: String(item.teamId),
startAt: toDateTimeLocal(item.startAt),
endAt: toDateTimeLocal(item.endAt),
sourceType: item.sourceType as EditForm["sourceType"],
remark: item.remark || "",
}
}
@@ -151,7 +140,6 @@ function buildPayload(form: EditForm): CreateAdminAgentTeamSchedulePayload {
teamId: Number(form.teamId),
startAt: form.startAt.trim(),
endAt: form.endAt.trim(),
sourceType: form.sourceType,
remark: form.remark.trim(),
}
}
@@ -298,34 +286,6 @@ function ScheduleEditDialogBody({
</FieldContent>
</Field>
</div>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
<Field data-invalid={!!errors.sourceType}>
<FieldLabel></FieldLabel>
<FieldContent>
<Controller
control={control}
name="sourceType"
render={({ field }) => (
<Select value={field.value} onValueChange={field.onChange} modal={false}>
<SelectTrigger className="w-full">
<SelectValue>
{sourceTypeOptions.find((item) => item.value === field.value)?.label ?? "请选择来源"}
</SelectValue>
</SelectTrigger>
<SelectContent>
{sourceTypeOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
)}
/>
<FieldError errors={[errors.sourceType]} />
</FieldContent>
</Field>
</div>
<Field>
<FieldLabel htmlFor="agent-team-schedule-remark"></FieldLabel>
<FieldContent>
@@ -406,7 +406,6 @@ export default function DashboardAgentTeamSchedulesPage() {
<TableRow>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead className="w-[92px] text-right"></TableHead>
</TableRow>
</TableHeader>
@@ -428,9 +427,6 @@ export default function DashboardAgentTeamSchedulesPage() {
<div className="text-sm">{formatDateTime(item.startAt)}</div>
<div className="text-sm text-muted-foreground">{formatDateTime(item.endAt)}</div>
</TableCell>
<TableCell>
<div className="text-sm">{item.sourceType}</div>
</TableCell>
<TableCell className="text-right">
<ButtonGroup className="ml-auto">
<Button variant="outline" size="sm" onClick={() => openEditDialog(item)} disabled={isHistoricalSchedule(item)}>
@@ -459,7 +455,7 @@ export default function DashboardAgentTeamSchedulesPage() {
))}
{!loading && result.results.length === 0 ? (
<TableRow>
<TableCell colSpan={4} className="py-12 text-center text-muted-foreground">
<TableCell colSpan={3} className="py-12 text-center text-muted-foreground">
</TableCell>
</TableRow>
-2
View File
@@ -510,7 +510,6 @@ export type AdminAgentTeamSchedule = {
teamName?: string
startAt: string
endAt: string
sourceType: string
remark: string
}
@@ -518,7 +517,6 @@ export type CreateAdminAgentTeamSchedulePayload = {
teamId: number
startAt: string
endAt: string
sourceType: string
remark: string
}