import { ResourceOverride } from "./types/overrides";

export const configuration: Record<string, ResourceOverride> = {
  expenses: {
    fields: {
      payee: {
        displayField: "name",
      },
      payor: {
        display: false,
        displayField: "username",
      },
      account: {
        displayField: "name",
      },
      tags: {
        displayField: "icon",
      },
      occurred_at: {
        formatter: (val: string) => {
            const date = new Date(val);
            const day = date.getDate();
            const month = date.toLocaleString('default', { month: 'long' });
            const year = date.getFullYear();
            const suffix = (day: number) => {
                if (day > 3 && day < 21) return 'th';
                switch (day % 10) {
                    case 1: return "st";
                    case 2: return "nd";
                    case 3: return "rd";
                    default: return "th";
                }
            };
            return `${day}${suffix(day)} ${month} ${year}`;
        }
      },
      created_at: {
        display: false
      }
    },
  },
};

export const profileConfiguration = {
  "extraFields": ['name'],
  "resource": "payors",
  // not in use
  "hidden": true,
};
