// components/users/utils.js
export function formatDate(d) {
  const date = d instanceof Date ? d : new Date(d);
  const pad = (n) => String(n).padStart(2, "0");
  return `${pad(date.getDate())}.${pad(date.getMonth() + 1)}.${date.getFullYear()} ${pad(
    date.getHours(),
  )}:${pad(date.getMinutes())}`;
}
// data/companies.js
export const slugify = (s = "") =>
  s
    .toString()
    .toLowerCase()
    .trim()
    .replace(/&/g, "and")
    .replace(/[–—]/g, "-")
    .replace(/[\s/]+/g, "-")
    .replace(/[^\w-]+/g, "")
    .replace(/--+/g, "-");

export const companies = [
  {
    id: "c1",
    name: "Hepiyi Sigorta",
    short: "Hepiyi",
    logo: "hepiyi-sigorta-logo.png",
  },
  {
    id: "c2",
    name: "Quick Sigorta",
    short: "Quick",
    logo: "quick.png",
  },
].map((c) => ({ ...c, slug: slugify(c.name) }));

export const getCompanyBySlug = (slug) =>
  companies.find((c) => c.slug === slug) || null;