useEmailAccountForm.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { ShallowRef } from 'vue'
  3. import { shallowRef } from 'vue'
  4. import type { FormRef } from '#shared/components/Form/types.ts'
  5. import { useForm } from '#shared/components/Form/useForm.ts'
  6. import type { EmailAccountData } from '../types/email-account.ts'
  7. export const useEmailAccountForm = () => {
  8. const formEmailAccount: ShallowRef<FormRef | undefined> = shallowRef()
  9. const emailAccountSchema = [
  10. {
  11. isLayout: true,
  12. element: 'div',
  13. attrs: {
  14. class: 'grid grid-cols-1 gap-y-2.5 gap-x-3',
  15. },
  16. children: [
  17. {
  18. name: 'realname',
  19. label: __('Full Name'),
  20. type: 'text',
  21. props: {
  22. placeholder: __('Organization Support'),
  23. },
  24. required: true,
  25. },
  26. {
  27. name: 'email',
  28. label: __('Email Address'),
  29. type: 'email',
  30. props: {},
  31. validation: 'email',
  32. required: true,
  33. },
  34. {
  35. name: 'password',
  36. label: __('Password'),
  37. type: 'password',
  38. props: {},
  39. required: true,
  40. },
  41. ],
  42. },
  43. ]
  44. const { values, formSetErrors, updateFieldValues } =
  45. useForm<EmailAccountData>(formEmailAccount)
  46. return {
  47. formEmailAccount,
  48. emailAccountSchema,
  49. formEmailAccountValues: values,
  50. updateEmailAccountFieldValues: updateFieldValues,
  51. formEmailAccountSetErrors: formSetErrors,
  52. }
  53. }