first commit

This commit is contained in:
2026-05-23 13:22:10 +03:30
parent 5f9ee72174
commit 6591a52f27
52 changed files with 3937 additions and 133 deletions

109
core/constant/index.ts Normal file
View File

@@ -0,0 +1,109 @@
export const API_URL = "http://localhost:8000/api/v1";
export const requestType = [
{
id: "1",
name: "software",
displayName: "نرم افزار",
},
{
id: "2",
name: "hardware",
displayName: "سخت افزار",
},
{
id: "3",
name: "his",
displayName: "HIS",
},
{
id: "4",
name: "general",
displayName: "عمومي",
},
];
export const ticketStatuses = [
{
id: "open",
displayName: "باز",
bgClass: "bg-blue-50 text-blue-700 ring-blue-200",
dotClass: "bg-blue-600",
},
{
id: "in-progress",
displayName: "در حال بررسی",
bgClass: "bg-amber-50 text-amber-700 ring-amber-200",
dotClass: "bg-amber-600",
},
{
id: "resolved",
displayName: "حل شده",
bgClass: "bg-emerald-50 text-emerald-700 ring-emerald-200",
dotClass: "bg-emerald-600",
},
{
id: "closed",
displayName: "بسته شده",
bgClass: "bg-slate-100 text-slate-700 ring-slate-300",
dotClass: "bg-slate-500",
},
];
export const ticketPriorities = [
{
id: "low",
displayName: "پایین",
bgClass: "bg-slate-50 text-slate-700 ring-slate-200",
dotClass: "bg-slate-500",
},
{
id: "medium",
displayName: "متوسط",
bgClass: "bg-sky-50 text-sky-700 ring-sky-200",
dotClass: "bg-sky-600",
},
{
id: "high",
displayName: "بالا",
bgClass: "bg-orange-50 text-orange-700 ring-orange-200",
dotClass: "bg-orange-600",
},
{
id: "critical",
displayName: "بحرانی",
bgClass: "bg-rose-50 text-rose-700 ring-rose-200",
dotClass: "bg-rose-600",
},
];
export const hospitalSoftwares = [
{
id: "1",
name: "rahkaran",
displayName: "راهكاران",
},
{
id: "2",
name: "timex",
displayName: "تايمكس",
},
{
id: "3",
name: "automation",
displayName: "اتوماسيون",
},
{
id: "4",
name: "pacs",
displayName: "پكس",
},
{
id: "5",
name: "kasra",
displayName: "كسري",
},
{
id: "6",
name: "ican",
displayName: "ican",
},
];

37
core/types/index.ts Normal file
View File

@@ -0,0 +1,37 @@
// اینترفیس برای اطلاعات اساسی اشیاء وابسته
interface Assignee {
fullname: string;
}
interface Department {
displayName: string;
}
// اینترفیس اصلی تیکت
export interface TicketInterface {
id: string;
ticketNumber: string;
description: string;
priority: "low" | "medium" | "high" | "critical"; // اگر مقادیر مشخصی داری
status: "open" | "pending" | "resolved" | "closed";
requestType: string;
relatedSystem: string;
location: string;
internalPhone: string;
helpdeskAction: string;
finalNotes: string;
// فیلدهای کلیدی (FK)
departmentId: string;
assignedTo: string;
createdBy: string;
// فیلدهای شامل شده (Include)
assignee: Assignee;
department: Department;
// تاریخ‌ها
resolvedAt: Date | null;
createdAt: Date;
updatedAt: Date;
}

91
core/utils/index.ts Normal file
View File

@@ -0,0 +1,91 @@
import axios from "axios";
import * as XLSX from "xlsx";
import { saveAs } from "file-saver";
export function handleAxiosError(error: unknown) {
if (axios.isAxiosError(error)) {
// اینجا می‌دونیم که خطا از axios است
return error.response?.data?.error?.message;
} else {
return "Unexpected error";
}
}
export const handleExport = (data: any, type: any) => {
// ۱. تبدیل دیتا به یک Worksheet
const worksheet = XLSX.utils.json_to_sheet(data);
// ۲. ایجاد یک Workbook جدید
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, "Data");
if (type === "excel") {
// خروجی اکسل
const excelBuffer = XLSX.write(workbook, {
bookType: "xlsx",
type: "array",
});
const blob = new Blob([excelBuffer], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
saveAs(blob, "data.xlsx");
} else if (type === "spss") {
// برای SPSS، بهترین فرمت CSV است که در SPSS به خوبی باز می‌شود
const csvData = XLSX.utils.sheet_to_csv(worksheet);
const blob = new Blob([csvData], { type: "text/csv;charset=utf-8;" });
saveAs(blob, "data.csv"); // فایل CSV در SPSS به راحتی Import می‌شود
}
};
export const exportToExcel = (
type: "spss" | "excel",
formattedData: any,
filename: string = "Report",
) => {
// تبدیل داده‌ها به فرمت قابل فهم برای XLSX
let dataToProcess = Array.isArray(formattedData)
? formattedData
: [formattedData];
const worksheet = XLSX.utils.json_to_sheet(formattedData);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, filename);
if (type === "excel") {
// خروجی اکسل
const excelBuffer = XLSX.write(workbook, {
bookType: "xlsx",
type: "array",
});
const blob = new Blob([excelBuffer], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
saveAs(blob, `${filename}.xlsx`);
} else if (type === "spss") {
// برای SPSS، بهترین فرمت CSV است که در SPSS به خوبی باز می‌شود
const csvData = XLSX.utils.sheet_to_csv(worksheet);
const blob = new Blob([csvData], { type: "text/csv;charset=utf-8;" });
saveAs(blob, `${filename}.csv`); // فایل CSV در SPSS به راحتی Import می‌شود
}
};
export function formatDurationPersian(seconds:string) {
const sec = Math.abs(parseFloat(seconds));
if (sec < 1) return "بلافاصله"; // برای مقادیر بسیار ناچیز
if (sec < 60) return `${Math.floor(sec)} ثانیه`;
const minutes = Math.floor(sec / 60);
const remainingSeconds = Math.floor(sec % 60);
if (minutes < 60) {
return `${minutes} دقیقه و ${remainingSeconds} ثانیه`;
}
const hours = Math.floor(minutes / 60);
const remainingMinutes = minutes % 60;
return `${hours} ساعت و ${remainingMinutes} دقیقه`;
}
// مثال برای مقدار شما:
console.log(formatDurationPersian("-0.00100000000000000000"));
// خروجی: "بلافاصله" (یا ۰ ثانیه)