TicketState.ts 855 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { TicketState } from '#shared/graphql/types.ts'
  3. import type { DeepPartial } from '#shared/types/utils.ts'
  4. import {
  5. convertToGraphQLId,
  6. getIdFromGraphQLId,
  7. } from '#shared/graphql/utils.ts'
  8. import { faker } from '@faker-js/faker'
  9. import { updateGeneratedIds } from '../builders/utils.ts'
  10. const states: (() => DeepPartial<TicketState>)[] = [
  11. () => ({ id: convertToGraphQLId('TicketState', 1), name: 'new' }),
  12. () => ({ id: convertToGraphQLId('TicketState', 2), name: 'open' }),
  13. ]
  14. export default (): DeepPartial<TicketState> => {
  15. const state: DeepPartial<TicketState> = faker.helpers.arrayElement(states)()
  16. state.stateType = {
  17. id: state.id,
  18. name: state.name,
  19. }
  20. updateGeneratedIds('TicketState', getIdFromGraphQLId(state.id!))
  21. return state
  22. }