104 lines
2.1 KiB
TypeScript
104 lines
2.1 KiB
TypeScript
// * Packages
|
|
import { useFormatedDate } from "@/hooks/use-formated-value";
|
|
import useTrans, { UseTransOptions } from "@/hooks/use-translations";
|
|
import { clsx, type ClassValue } from "clsx";
|
|
import {
|
|
ArchiveIcon,
|
|
ArchiveRestoreIcon,
|
|
CopyIcon,
|
|
EyeIcon,
|
|
PencilIcon,
|
|
PlusIcon,
|
|
Trash2Icon,
|
|
} from "lucide-react";
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
/**
|
|
* Merge classes.
|
|
* @param inputs ClassValue[]
|
|
* @returns string
|
|
*/
|
|
export function cn(...inputs: ClassValue[]): string {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
/**
|
|
* Get the translation value.
|
|
*
|
|
* @param string name
|
|
* @return string
|
|
*/
|
|
export const GetTranslation = (keyName: string, options?: UseTransOptions) => {
|
|
return useTrans(keyName, options);
|
|
};
|
|
|
|
/**
|
|
* Get the formated date.
|
|
*
|
|
* @param string date
|
|
* @param string timezone
|
|
* @param boolean time
|
|
* @returns
|
|
*/
|
|
export const GetFormatedDate = (
|
|
date: string,
|
|
timezone?: string,
|
|
time?: boolean,
|
|
) => {
|
|
return useFormatedDate(date, timezone, time);
|
|
};
|
|
|
|
/**
|
|
* List all actions on back-end models.
|
|
* @return object
|
|
*/
|
|
export const Views = {
|
|
CREATION: {
|
|
label: "create",
|
|
value: "create",
|
|
policy: "create",
|
|
icon: PlusIcon,
|
|
},
|
|
VISUALIZATION: {
|
|
label: "visualize",
|
|
value: "show",
|
|
policy: "view",
|
|
icon: EyeIcon,
|
|
},
|
|
EDITION: {
|
|
label: "edit",
|
|
value: "edit",
|
|
policy: "update",
|
|
icon: PencilIcon,
|
|
},
|
|
DUPLICATION: {
|
|
label: "duplicate",
|
|
value: "duplicate",
|
|
policy: "duplicate",
|
|
icon: CopyIcon,
|
|
},
|
|
ARCHIVATION: {
|
|
label: "archive",
|
|
value: "destroy",
|
|
policy: "delete",
|
|
icon: ArchiveIcon,
|
|
},
|
|
RESTORATION: {
|
|
label: "restore",
|
|
value: "restore",
|
|
policy: "restore",
|
|
icon: ArchiveRestoreIcon,
|
|
},
|
|
DELETION: {
|
|
label: "delete",
|
|
value: "destroy",
|
|
policy: "delete",
|
|
icon: Trash2Icon,
|
|
},
|
|
FORCEDELETION: {
|
|
label: "delete",
|
|
value: "forceDestroy",
|
|
policy: "forceDelete",
|
|
icon: Trash2Icon,
|
|
},
|
|
};
|