useTicketAccountedTime.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { storeToRefs } from 'pinia'
  3. import { computed } from 'vue'
  4. import { useApplicationStore } from '#shared/stores/application.ts'
  5. export const useTicketAccountedTime = () => {
  6. const { config: applicationConfig } = storeToRefs(useApplicationStore())
  7. const timeAccountingConfig = computed(() => ({
  8. time_accounting_types: applicationConfig.value.time_accounting_types,
  9. time_accounting_unit: applicationConfig.value.time_accounting_unit,
  10. time_accounting_unit_custom:
  11. applicationConfig.value.time_accounting_unit_custom,
  12. }))
  13. const timeAccountingDisplayUnit = computed(() => {
  14. switch (timeAccountingConfig.value.time_accounting_unit) {
  15. case 'hour':
  16. return __('hour(s)')
  17. case 'quarter':
  18. return __('quarter-hour(s)')
  19. case 'minute':
  20. return __('minute(s)')
  21. case 'custom':
  22. return timeAccountingConfig.value.time_accounting_unit_custom
  23. default:
  24. return ''
  25. }
  26. })
  27. return { timeAccountingDisplayUnit, timeAccountingConfig }
  28. }