Files
meezi/web/koja/src/lib/utils.ts
T
soroush.asadi 289c808257 Rename public discovery app from "finder" to "koja"
Rebrand the public café-discovery app: directories web/finder→web/koja and
docker/finder→docker/koja, plus all service wiring (docker-compose, Caddy
subdomain koja.meezi.ir, env vars KOJA_PORT / NEXT_PUBLIC_KOJA_URL, CI
workflows) and the app's display name (Koja / کجا).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 17:02:22 +03:30

73 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function formatPrice(price: number, locale: string): string {
if (locale === "fa") {
return new Intl.NumberFormat("fa-IR").format(price) + " تومان";
}
return new Intl.NumberFormat("en-US").format(price) + " ﷼";
}
export function formatRating(rating: number): string {
return rating.toFixed(1);
}
// Convert Persian/Arabic digits to Latin
export function toLatinDigits(str: string): string {
return str
.replace(/[۰-۹]/g, (d) => String(d.charCodeAt(0) - 0x06f0))
.replace(/[٠-٩]/g, (d) => String(d.charCodeAt(0) - 0x0660));
}
// Slugify a Persian or Latin string for URLs
export function slugify(str: string): string {
return toLatinDigits(str)
.toLowerCase()
.trim()
.replace(/[\s_]+/g, "-")
.replace(/[^a-z0-9؀-ۿ-]/g, "")
.replace(/-+/g, "-");
}
const DAY_KEYS_FA: Record<string, string> = {
sat: "شنبه",
sun: "یکشنبه",
mon: "دوشنبه",
tue: "سه‌شنبه",
wed: "چهارشنبه",
thu: "پنجشنبه",
fri: "جمعه",
};
const DAY_KEYS_EN: Record<string, string> = {
sat: "Sat",
sun: "Sun",
mon: "Mon",
tue: "Tue",
wed: "Wed",
thu: "Thu",
fri: "Fri",
};
export function getDayLabel(key: string, locale: string): string {
return locale === "fa" ? DAY_KEYS_FA[key] ?? key : DAY_KEYS_EN[key] ?? key;
}
export const PRICE_TIER_LABELS: Record<string, { fa: string; en: string }> = {
budget: { fa: "مقرون‌به‌صرفه", en: "Budget" },
moderate: { fa: "معمولی", en: "Moderate" },
upscale: { fa: "لوکس", en: "Upscale" },
luxury: { fa: "پریمیوم", en: "Luxury" },
};
export const NOISE_LABELS: Record<string, { fa: string; en: string }> = {
quiet: { fa: "آرام", en: "Quiet" },
moderate: { fa: "نسبتاً آرام", en: "Moderate" },
lively: { fa: "شلوغ", en: "Lively" },
loud: { fa: "پرسروصدا", en: "Loud" },
};