import {
  model,
  Model,
  ModelAutoTypeCheckingMode,
  setGlobalConfig,
  tProp,
  types,
} from 'mobx-keystone';
import { v4 as uuidv4 } from 'uuid';

setGlobalConfig({
  modelAutoTypeChecking: ModelAutoTypeCheckingMode.AlwaysOn,
});

@model('keystone/Languages/Language')
export default class Language extends Model({
  id: tProp(types.string, () => uuidv4()),
  name: tProp(types.string),
  label: tProp(types.string),
  type: tProp(types.number),
  fields: tProp(
    types.array(
      types.object(() => ({
        id: types.string,
        translation: types.string,
        customTranslation: types.string,
        changed: types.boolean,
        occursWhere: types.string,
      }))
    )
  ),
}) {}
