import type {
  AdminServiceCategoryCreatePayload,
  AdminServiceCategoryUpdatePayload,
} from '../../../../api';
import type { AdminServiceCategory } from '../../../../api/index.ts';

export type ServiceCategoryFormValues = {
  name: string;
  slug: string;
};

export const defaultServiceCategoryFormValues: ServiceCategoryFormValues = {
  name: '',
  slug: '',
};

export const createServiceCategoryFormValues = (
  category?: Partial<AdminServiceCategory>,
): ServiceCategoryFormValues => ({
  name: category?.name ?? '',
  slug: category?.slug ?? '',
});

export const mapCategoryFormToCreatePayload = (
  values: ServiceCategoryFormValues,
): AdminServiceCategoryCreatePayload => ({
  name: values.name.trim(),
  slug: values.slug.trim(),
});

export const mapCategoryFormToUpdatePayload = (
  values: ServiceCategoryFormValues,
): AdminServiceCategoryUpdatePayload => ({
  name: values.name.trim(),
  slug: values.slug.trim(),
});
