260320:1131 Refactor Overrall #01
Build and Deploy / deploy (push) Has been cancelled

This commit is contained in:
admin
2026-03-20 11:31:27 +07:00
parent f1b81a7d0d
commit 1d3479770b
147 changed files with 1745 additions and 1567 deletions
@@ -24,7 +24,7 @@ export function AuditLogsTable() {
setLogs(data.audit);
}
} catch (error) {
console.error("Failed to fetch audit logs", error);
// Failed to fetch audit logs - empty state shown
} finally {
setLoading(false);
}
@@ -7,7 +7,7 @@ import { Label } from "@/components/ui/label";
import { toast } from "sonner";
import { documentNumberingService } from "@/lib/services/document-numbering.service";
export function BulkImportForm({ projectId = 1 }: { projectId?: number }) {
export function BulkImportForm({ projectId = 1 }: { projectId?: number | string }) {
const [file, setFile] = useState<File | null>(null);
const [loading, setLoading] = useState(false);
@@ -30,7 +30,6 @@ export function BulkImportForm({ projectId = 1 }: { projectId?: number }) {
setFile(null);
} catch (error) {
toast.error("Failed to import numbers.");
console.error(error);
} finally {
setLoading(false);
}
@@ -29,7 +29,7 @@ export function CancelNumberForm() {
const [loading, setLoading] = useState(false);
const form = useForm<CancelNumberFormData>({
resolver: zodResolver(formSchema) as any,
resolver: zodResolver(formSchema) as any, // eslint-disable-line @typescript-eslint/no-explicit-any -- zod 4 + @hookform/resolvers compat
defaultValues: {
documentNumber: "",
reason: "",
@@ -45,7 +45,6 @@ export function CancelNumberForm() {
form.reset();
} catch (error) {
toast.error("Failed to cancel number. It may not exist or is already cancelled.");
console.error(error);
} finally {
setLoading(false);
}
@@ -29,13 +29,13 @@ const formSchema = z.object({
resetScope: z.string().optional()
});
export function ManualOverrideForm({ projectId = 1 }: { projectId?: number }) {
export function ManualOverrideForm({ projectId = 1 }: { projectId?: number | string }) {
const [loading, setLoading] = useState(false);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema) as any,
resolver: zodResolver(formSchema) as any, // eslint-disable-line @typescript-eslint/no-explicit-any -- zod 4 + @hookform/resolvers compat
defaultValues: {
projectId: projectId,
projectId: Number(projectId),
originatorOrganizationId: 0,
recipientOrganizationId: 0,
correspondenceTypeId: 0,
@@ -57,7 +57,6 @@ export function ManualOverrideForm({ projectId = 1 }: { projectId?: number }) {
form.reset();
} catch (error) {
toast.error("Failed to apply override.");
console.error(error);
} finally {
setLoading(false);
}
@@ -16,7 +16,7 @@ export function MetricsDashboard() {
const data = await documentNumberingService.getMetrics();
setMetrics(data);
} catch (error) {
console.error("Failed to fetch metrics", error);
// Failed to fetch metrics - handled by loading state
} finally {
setLoading(false);
}
@@ -21,7 +21,7 @@ export function SequenceViewer() {
const data = Array.isArray(response) ? response : (response as { data?: NumberSequence[] })?.data ?? [];
setSequences(data);
} catch {
console.error('Failed to fetch sequences');
// Failed to fetch sequences - show empty state
setSequences([]);
} finally {
setLoading(false);
@@ -71,7 +71,7 @@ export function TemplateEditor({
// Dynamic context based on selection (optional visual enhancement)
if (v.key === '{TYPE}' && typeId) {
const t = (correspondenceTypes as any[]).find((ct: any) => ct.id?.toString() === typeId);
const t = (correspondenceTypes as { id: number; typeCode: string; typeName: string }[]).find((ct) => ct.id?.toString() === typeId);
if (t) replacement = t.typeCode;
}
@@ -53,7 +53,8 @@ export function TemplateTester({ open, onOpenChange, template }: TemplateTesterP
const [loading, setLoading] = useState(false);
// Master Data Hooks
const projectId = (template as any)?.project?.id ?? (template as any)?.project?.uuid ?? template?.projectId ?? 1;
const templateWithProject = template as (NumberingTemplate & { project?: { id?: number; uuid?: string } }) | null;
const projectId = templateWithProject?.project?.id ?? templateWithProject?.project?.uuid ?? template?.projectId ?? 1;
const { data: organizations } = useOrganizations({ isActive: true });
const { data: correspondenceTypes } = useCorrespondenceTypes();
const { data: contracts } = useContracts(projectId);
@@ -74,14 +75,9 @@ export function TemplateTester({ open, onOpenChange, template }: TemplateTesterP
disciplineId: parseInt(testData.disciplineId || "0"),
});
setGeneratedNumber(result.previewNumber);
} catch (error: any) {
console.error("Failed to generate test number", error);
setGeneratedNumber("");
// Assuming toast is available globally or we can use console for now,
// but better to show visible error.
// Alert is primitive but effective for 'tester' component debugging if toast not imported.
// Actually, let's just set the error string in display if we can, or add a simple red text.
setGeneratedNumber(`Error: ${error.response?.data?.message || error.message || "Unknown error"}`);
} catch (error: unknown) {
const err = error as { response?: { data?: { message?: string } }; message?: string };
setGeneratedNumber(`Error: ${err.response?.data?.message || err.message || "Unknown error"}`);
} finally {
setLoading(false);
}
@@ -29,16 +29,16 @@ const formSchema = z.object({
type VoidReplaceFormData = z.infer<typeof formSchema>;
export function VoidReplaceForm({ projectId = 1 }: { projectId?: number }) {
export function VoidReplaceForm({ projectId = 1 }: { projectId?: number | string }) {
const [loading, setLoading] = useState(false);
const form = useForm<VoidReplaceFormData>({
resolver: zodResolver(formSchema) as any,
resolver: zodResolver(formSchema) as any, // eslint-disable-line @typescript-eslint/no-explicit-any -- zod 4 + @hookform/resolvers compat
defaultValues: {
documentNumber: "",
reason: "",
replace: false,
projectId: projectId
projectId: Number(projectId)
},
});
@@ -53,7 +53,6 @@ export function VoidReplaceForm({ projectId = 1 }: { projectId?: number }) {
form.reset();
} catch (error) {
toast.error("Failed to void number. Check if it exists.");
console.error(error);
} finally {
setLoading(false);
}