-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blocked customer controllers for create, destroy, list, and range…
… operations
- Loading branch information
1 parent
a021fac
commit 885effa
Showing
5 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { z } from "zod"; | ||
import { BlockDateZodSchema } from "~/functions/blocked/blocked.types"; | ||
import { _ } from "~/library/handler"; | ||
import { CustomerBlockedServiceCreate } from "../../services/blocked/create"; | ||
import { CustomerServiceUpdate } from "../../services/customer"; | ||
|
||
export type CustomerControllerCreateRequest = { | ||
query: z.infer<typeof CustomerBlockedControllerQuerySchema>; | ||
body: z.infer<typeof CustomerBlockedControllerCreateSchema>; | ||
}; | ||
|
||
export const CustomerBlockedControllerQuerySchema = BlockDateZodSchema.pick({ | ||
customerId: true, | ||
}).strip(); | ||
|
||
export const CustomerBlockedControllerCreateSchema = BlockDateZodSchema.omit({ | ||
customerId: true, | ||
}).strip(); | ||
|
||
export type CustomerBlockedControllerCreateResponse = Awaited< | ||
ReturnType<typeof CustomerServiceUpdate> | ||
>; | ||
|
||
export const CustomerBlockedControllerCreate = _( | ||
({ query, body }: CustomerControllerCreateRequest) => { | ||
const validateBody = CustomerBlockedControllerCreateSchema.parse(body); | ||
return CustomerBlockedServiceCreate({ ...query, ...validateBody }); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { z } from "zod"; | ||
import { _ } from "~/library/handler"; | ||
import { NumberOrStringType, StringOrObjectIdType } from "~/library/zod"; | ||
import { CustomerBlockedServiceDestroy } from "../../services/blocked/destroy"; | ||
import { CustomerServiceUpdate } from "../../services/customer"; | ||
|
||
export type CustomerBlockedControllerDestroyRequest = { | ||
query: z.infer<typeof CustomerBlockedControllerDestroySchema>; | ||
}; | ||
|
||
export const CustomerBlockedControllerDestroySchema = z.object({ | ||
customerId: NumberOrStringType, | ||
blockedId: StringOrObjectIdType, | ||
}); | ||
|
||
export type CustomerBlockedControllerCreateResponse = Awaited< | ||
ReturnType<typeof CustomerServiceUpdate> | ||
>; | ||
|
||
export const CustomerBlockedControllerCreate = _( | ||
({ query }: CustomerBlockedControllerDestroyRequest) => { | ||
const validateBody = CustomerBlockedControllerDestroySchema.parse(query); | ||
return CustomerBlockedServiceDestroy(query); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { z } from "zod"; | ||
import { CustomerLocationServiceGetAll } from "~/functions/customer/services/location"; | ||
import { _ } from "~/library/handler"; | ||
import { NumberOrStringType, StringOrObjectIdType } from "~/library/zod"; | ||
import { CustomerBlockedServiceList } from "../../services/blocked/list"; | ||
|
||
export type CustomerBlockedControllerListRequest = { | ||
query: z.infer<typeof CustomerBlockedControllerListSchema>; | ||
}; | ||
|
||
export const CustomerBlockedControllerListSchema = z.object({ | ||
customerId: NumberOrStringType, | ||
limit: NumberOrStringType, | ||
nextCursor: StringOrObjectIdType, | ||
}); | ||
|
||
export type CustomerBlockedControllerListResponse = Awaited< | ||
ReturnType<typeof CustomerLocationServiceGetAll> | ||
>; | ||
|
||
export const CustomerBlockedControllerList = _( | ||
({ query }: CustomerBlockedControllerListRequest) => { | ||
const validateData = CustomerBlockedControllerListSchema.parse(query); | ||
return CustomerBlockedServiceList(validateData); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { z } from "zod"; | ||
import { CustomerLocationServiceGetAll } from "~/functions/customer/services/location"; | ||
import { _ } from "~/library/handler"; | ||
import { NumberOrStringType, StringOrObjectIdType } from "~/library/zod"; | ||
import { CustomerBlockedServiceList } from "../../services/blocked/list"; | ||
|
||
export type CustomerBlockedControllerRangeRequest = { | ||
query: z.infer<typeof CustomerBlockedControllerRangeQuerySchema>; | ||
}; | ||
|
||
export const CustomerBlockedControllerRangeQuerySchema = z.object({ | ||
customerId: NumberOrStringType, | ||
limit: NumberOrStringType, | ||
nextCursor: StringOrObjectIdType, | ||
}); | ||
|
||
export type CustomerBlockedControllerRangeQueryResponse = Awaited< | ||
ReturnType<typeof CustomerLocationServiceGetAll> | ||
>; | ||
|
||
export const CustomerBlockedControllerRange = _( | ||
({ query }: CustomerBlockedControllerRangeRequest) => { | ||
const validateData = CustomerBlockedControllerRangeQuerySchema.parse(query); | ||
return CustomerBlockedServiceList(validateData); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters