4
0

getFaultCodeDetail.ts 967 B

123456789101112131415161718192021222324252627
  1. 'use server'
  2. import { getLocale } from 'next-intl/server'
  3. import { PermissionAction, PermissionSubject } from '@/lib/permissions'
  4. import { withAuth } from '@/lib/with-auth'
  5. import { loadFaultCodePage } from '../Lib/page.server'
  6. import { faultCodeDetailSchema } from '../Schema/faultCodeSchema'
  7. /**
  8. * Everything the code sheet shows for one code: the meaning with its
  9. * description and causes, the jobs here where it was read, and what this
  10. * workshop reported about it. The code's own page asks for the shared fixes
  11. * too.
  12. */
  13. export async function getFaultCodeDetail(input: unknown) {
  14. return withAuth(
  15. async ({ organizationId }) => {
  16. const data = faultCodeDetailSchema.parse(input)
  17. return loadFaultCodePage(organizationId, data.code, data.vehicleId, await getLocale(), {
  18. fixes: data.fixes === true,
  19. })
  20. },
  21. {
  22. requiredPermissions: [{ action: PermissionAction.READ, subject: PermissionSubject.VEHICLES }],
  23. }
  24. )
  25. }