37 lines
859 B
TypeScript
37 lines
859 B
TypeScript
import { type ClassValue, clsx } from "clsx"
|
|
// import { toast } from "sonner"
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export function processFileType(file: string) {
|
|
const ending = file.split(".").pop()
|
|
|
|
if (ending === "ts" || ending === "tsx") return "typescript"
|
|
if (ending === "js" || ending === "jsx") return "javascript"
|
|
|
|
if (ending) return ending
|
|
return "plaintext"
|
|
}
|
|
|
|
export function validateName(
|
|
newName: string,
|
|
oldName: string,
|
|
type: "file" | "folder"
|
|
) {
|
|
if (
|
|
newName === oldName ||
|
|
newName.length === 0 ||
|
|
newName.includes("/") ||
|
|
newName.includes("\\") ||
|
|
newName.includes(" ") ||
|
|
(type === "file" && !newName.includes(".")) ||
|
|
(type === "folder" && newName.includes("."))
|
|
) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|