1
- import { Prisma , RequestType } from '@prisma/client' ;
1
+ import { Provider , Cluster , RequestType } from '@prisma/client' ;
2
2
import { z } from 'zod' ;
3
3
import createApiHandler from '@/core/api-handler' ;
4
4
import prisma from '@/core/prisma' ;
5
5
import { PdfResponse , BadRequestResponse } from '@/core/responses' ;
6
6
import { generateEmouPdf , Product } from '@/helpers/pdfs/emou' ;
7
7
import { PermissionsEnum } from '@/types/permissions' ;
8
+ import { processNumber , processUpperEnumString , processBoolean } from '@/utils/zod' ;
8
9
import { getBillingIdWhere } from '../helpers' ;
9
10
10
11
const pathParamSchema = z . object ( {
@@ -13,6 +14,7 @@ const pathParamSchema = z.object({
13
14
14
15
const queryParamSchema = z . object ( {
15
16
licencePlate : z . string ( ) . optional ( ) ,
17
+ context : z . preprocess ( processUpperEnumString , z . union ( [ z . nativeEnum ( Provider ) , z . nativeEnum ( Cluster ) ] ) . optional ( ) ) ,
16
18
} ) ;
17
19
18
20
const apiHandler = createApiHandler ( {
@@ -22,9 +24,9 @@ const apiHandler = createApiHandler({
22
24
23
25
export const GET = apiHandler ( async ( { pathParams, queryParams, session } ) => {
24
26
const { idOrAccountCoding } = pathParams ;
25
- const { licencePlate } = queryParams ;
27
+ const { licencePlate, context } = queryParams ;
26
28
27
- const billingWhereId = getBillingIdWhere ( idOrAccountCoding ) ;
29
+ const billingWhereId = getBillingIdWhere ( idOrAccountCoding , context ) ;
28
30
const billing = await prisma . billing . findFirst ( {
29
31
where : { signed : true , approved : true , ...billingWhereId } ,
30
32
include : {
0 commit comments