import { NO_NUM, NO_VALUE } from '@/constants';
import type { RecordModel } from 'pocketbase';

import { dayjs } from '@/lib/dayjs';

// import type { LessonType } from './ILessonType';
import type { CreateForm, LessonType } from './lesson-type';

export const LessonTypeCreateFormDefault: CreateForm = {
  name: '',
  type: '',
  pos: 1,
  visible: 'visible',
};

export const defaultLessonType: LessonType = {
  id: 'string',
  name: 'string',
  type: 'string',
  pos: 1,
  visible: 'visible',
  createdAt: dayjs().toDate(),
  //
  // original
  // id: 'string',
  // name: 'string',
  //
  avatar: 'string',
  email: 'string',
  phone: 'string',
  quota: 1,
  status: 'pending',
  // createdAt: Date;
};

export const emptyLessonType: LessonType = {
  ...defaultLessonType,
  isEmpty: true,
};

export function safeAssignment(inTemp: LessonType | RecordModel): LessonType {
  const { id, name, type, pos, visible, createdAt, email, quota, status } = { ...defaultLessonType, ...inTemp };
  const oCreatedAt = dayjs(createdAt).toDate();

  const output: LessonType = {
    id,
    name,
    type,
    pos,
    visible,
    createdAt: oCreatedAt,
    email,
    quota,
    status,
  };
  return output;
}

export const LessonTypeDefaultValue: LessonType = {
  id: 'string',
  name: 'string',
  type: 'string',
  pos: 1,
  visible: 'visible',
  createdAt: dayjs().toDate(),
  //
  // original
  // id: 'string',
  // name: 'string',
  //
  avatar: 'string',
  email: 'string',
  phone: 'string',
  quota: 1,
  status: 'pending',
  // createdAt: Date;
};
