import { ref } from 'vue'
interface Pagination {
  rowsPerPage: number
}

interface DataDateMonthObject {
  month: number
  year: number
}

interface ChangeActive {
  name: string
  id: number
}

//ข้อมูลส่วนตัว
interface Information {
  cardid: string | null
  prefix: string | null
  prefixId: string | null
  firstname: string | null
  lastname: string | null
  birthDate: Date | null
  genderId: string | null
  bloodId: string | null
  nationality: string | null
  ethnicity: string | null
  religionId: string | null
  tel: string | null
  phone: string | null
  email: string | null
  province: string | null
  provinceId: string | null
  districtId: string | null
  cardIdDate: Date | null
  relationshipId: string | null
  statusId: string | null
  knowledge: string | null
  profileImg: string | null
}

interface Family {
  prefixC: string | null // couple
  prefixIdC: string | null
  firstnameC: string | null
  lastnameC: string | null
  occupationC: string | null
  nationalityC: string | null
  prefixM: string | null // male
  prefixIdM: string | null
  firstnameM: string | null
  lastnameM: string | null
  occupationM: string | null
  nationalityM: string | null
  prefixF: string | null // female
  prefixIdF: string | null
  firstnameF: string | null
  lastnameF: string | null
  occupationF: string | null
  nationalityF: string | null
  same: string | null
}

interface Occupation {
  org: string | null
  pile: string | null
  group: string | null
  salary: string | null
  position: string | null
  positionType: string | null
  tel: string | null
}

interface Contact {
  contactprefixId: string | null
  contactfirstname: string | null
  contactlastname: string | null
  contactrelations: string | null
  contacttel: string | null
}

interface Education {
  educationLevelExamId: string | null
  educationName: string | null
  educationMajor: string | null
  educationLocation: string | null
  educationType: string | null
  educationEndDate: Date | null
  educationScores: number | null
  educationLevelHighId: string | null
}

interface Address {
  address: string | null
  provinceId: string | null
  districtId: string | null
  subdistrictId: string | null
  code?: number | null
  addressC: string | null
  provinceIdC: string | null
  districtIdC: string | null
  subdistrictIdC: string | null
  codeC?: number | null
  same: string | null
}

interface DataOption {
  id: string
  name: string
  zipCode?: number | null
}

interface zipCodeOption {
  id: string
  name: string
  zipCode: string | null
}

interface UploadType {
  id: string
  fileName: string
  fileSize: number
  fileType: string
  detail: string
}

interface ExamCard {
  id: string
  title: string
  announcementDate: Date
  registerRound: Number
  registerDateStart: Date
  registerDateEnd: Date
  yearly: Date
}

const defaultAddress = ref<Address>({
  address: null,
  provinceId: null,
  districtId: null,
  subdistrictId: null,
  //   code: ,
  addressC: null,
  provinceIdC: null,
  districtIdC: null,
  subdistrictIdC: null,
  //   codeC: ,
  same: '1'
})

const defaultInformation = ref<Information>({
  cardid: null,
  prefix: null,
  prefixId: null,
  firstname: null,
  lastname: null,
  birthDate: null,
  genderId: null,
  bloodId: null,
  nationality: 'ไทย',
  ethnicity: null,
  religionId: null,
  tel: null,
  phone: null,
  email: null,
  province: null,
  cardIdDate: new Date(),
  relationshipId: null,
  knowledge: null,
  districtId: null,
  provinceId: null,
  statusId: null,
  profileImg: null
})

const defaultFamily = ref<Family>({
  prefixC: null,
  prefixIdC: null,
  firstnameC: null,
  lastnameC: null,
  occupationC: null,
  nationalityC: null,
  prefixM: null,
  prefixIdM: null,
  firstnameM: null,
  lastnameM: null,
  occupationM: null,
  nationalityM: null,
  prefixF: null,
  prefixIdF: null,
  firstnameF: null,
  lastnameF: null,
  occupationF: null,
  nationalityF: null,
  same: '0'
})

const defaultOccupation = ref<Occupation>({
  org: null,
  pile: null,
  group: null,
  salary: null,
  position: null,
  positionType: 'other',
  tel: null
})

const defaultContact = ref<Contact>({
  contactprefixId: null,
  contactfirstname: null,
  contactlastname: null,
  contactrelations: null,
  contacttel: null
})

const defaultEducation = ref<Education>({
  educationLevelExamId: null,
  educationName: null,
  educationMajor: null,
  educationLocation: null,
  educationType: null,
  educationEndDate: null,
  educationScores: null,
  educationLevelHighId: null
})

const changeData = (system: String, val: any) => {
  if (system == 'information') defaultInformation.value = val
  if (system == 'address') defaultAddress.value = val
  if (system == 'famliy') defaultFamily.value = val
  if (system == 'occupation') defaultOccupation.value = val
  if (system == 'contact') defaultContact.value = val
  if (system == 'education') defaultEducation.value = val
}

export {
  defaultInformation,
  defaultFamily,
  defaultAddress,
  defaultOccupation,
  defaultContact,
  defaultEducation,
  changeData
}
export type {
  Pagination,
  DataOption,
  DataDateMonthObject,
  ChangeActive,
  Information,
  Family,
  Address,
  zipCodeOption,
  Occupation,
  Contact,
  Education,
  ExamCard,
  UploadType
}
