export type EmployeeRole = 'USER' | 'ADMIN' | 'User' | 'Admin' | string

export type Employee = {
  avatarUrl?: string | null
  id: number
  firstName: string
  lastName: string
  middleName: string
  email?: string
  login?: string
  password?: string
  createdAt?: string
  username?: string
  orgId: number
  role: EmployeeRole
  org: {
    creationDate?: number
    id: number
    logoUrl?: string | null
    name: string
  } | null
}

export type UserSortDirection = 'ASC' | 'DESC'

export type UserSortField = 'ID' | 'Name' | 'Date'

export type ServiceUseOption =
  | 'Disabled'
  | 'Enabled'
  | 'Unspecified'

export type ComponentUseOption =
  | 'Allowed'
  | 'Disallowed'

export type GroupUsePolicyOption =
  | 'Allowed'
  | 'Disallowed'
  | 'Changeable'

export type GetUsersData = {
  getUsers: {
    totalPages: number
    totalElements: number
    page: Employee[]
  }
}

export type GetUsersVariables = {
  page: number
  query?: string
  orgs?: string[]
  roles?: EmployeeRole[]
  sortDirection: UserSortDirection
  sortField: UserSortField
}

export type OrganisationPolicy = {
  bluetooth?: ServiceUseOption | GroupUsePolicyOption
  bluetoothEditable?: boolean
  camera?: ComponentUseOption | GroupUsePolicyOption
  cameraEditable?: boolean
  GPS?: ServiceUseOption | GroupUsePolicyOption
  gpsEditable?: boolean
  sim?: ServiceUseOption | GroupUsePolicyOption
  simEditable?: boolean
  canUseBluetooth?: boolean
  canUseCamera?: boolean
  canUseGPS?: boolean
  canUseSim?: boolean
  offlineTimeThreshold: number
  date?: number
}

export type Organisation = {
  creationDate?: number
  id: number
  name: string
  policy?: OrganisationPolicy | null
  logoUrl?: string | null
}

export type GetOrganisationData = {
  getOrganisation: Organisation | null
}

export type GetOrganisationVariables = {
  id: string
}

export type ChangeOrganisationData = {
  changeOrganisation: {
    id: number
    name: string
  }
}

export type ChangeOrganisationVariables = {
  id: string
  name: string
  bluetooth: ServiceUseOption
  bluetoothEditable: boolean
  camera: ComponentUseOption
  cameraEditable: boolean
  GPS: ServiceUseOption
  gpsEditable: boolean
  sim: ServiceUseOption
  simEditable: boolean
  offlineTimeThreshold: number
}

export type ChangeOrganisationPolicyVariables = {
  id: string
  name: string
  bluetooth: ServiceUseOption
  bluetoothEditable: boolean
  camera: ComponentUseOption
  cameraEditable: boolean
  GPS: ServiceUseOption
  gpsEditable: boolean
  sim: ServiceUseOption
  simEditable: boolean
  offlineTimeThreshold: number
}

export type GetUsersPageData = {
  getUsersPage: {
    page: Employee[]
    nextKey: string | null
  }
}

export type GetUsersPageVariables = {
  key?: string
}

export type GetOrganisationsData = {
  getOrganisations: {
    totalPages: number
    totalElements: number
    page: Organisation[]
  }
}

export type GetOrganisationsVariables = {
  page: number
  query?: string
  sortDirection: OrganisationSortDirection
  sortField: OrganisationSortField
}

export type DeleteOrganisationData = {
  deleteOrganisation: boolean
}

export type DeleteOrganisationVariables = {
  id: string
}

export type CreateUserData = {
  createUser: Employee
}

export type CreateUserVariables = {
  orgId: string
  firstName: string
  lastName: string
  middleName: string
  username: string
  password: string
  role: EmployeeRole
}

export type ChangeUserData = {
  changeUser: Employee
}

export type ChangeUserVariables = {
  userId: string
  orgId: string
  firstName: string
  lastName: string
  middleName: string
  username: string
  role: EmployeeRole
}

export type ChangeUserWithPasswordVariables = ChangeUserVariables & {
  password: string
}

export type SignUpVariables = {
  orgId: string
  firstName: string
  lastName: string
  middleName: string
  username: string
  password: string
  role: EmployeeRole
}

export type CreateOrganisationData = {
  createOrganisation: {
    id: number
    name: string
  }
}

export type CreateOrganisationVariables = {
  name: string
  bluetooth: ServiceUseOption
  bluetoothEditable: boolean
  camera: ComponentUseOption
  cameraEditable: boolean
  GPS: ServiceUseOption
  gpsEditable: boolean
  sim: ServiceUseOption
  simEditable: boolean
  offlineTimeThreshold: number
}

export type OrganisationSortDirection = 'ASC' | 'DESC'

export type OrganisationSortField = 'ID' | 'Name' | 'Date'

export type CreateUploadUserAvatarUrlData = {
  createUploadUserAvatarUrl: string
}

export type CreateUploadUserAvatarUrlVariables = {
  userId: string
}

export type CreateUploadOrganisationLogoUrlData = {
  createUploadOrganisationLogoUrl: string
}

export type CreateUploadOrganisationLogoUrlVariables = {
  orgId: string
}
