Refactor ClerkService and OrderSchema for improved type safety; update RefundTicketSchema to include new refund request and processing mutations. Clean up import statements and enhance descriptions for better clarity. Update subproject commit reference in epess-database.
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { OrderStatus } from '@prisma/client'
|
||||
@@ -90,8 +85,7 @@ export class OrderSchema extends PothosSchema {
|
||||
this.builder.queryFields((t) => ({
|
||||
orders: t.prismaField({
|
||||
type: [this.order()],
|
||||
description:
|
||||
'Retrieve a list of orders with optional filtering, ordering, and pagination.',
|
||||
description: 'Retrieve a list of orders with optional filtering, ordering, and pagination.',
|
||||
args: this.builder.generator.findManyArgs('Order'),
|
||||
resolve: async (query, _root, args, _ctx, _info) => {
|
||||
return await this.prisma.order.findMany({
|
||||
@@ -160,10 +154,7 @@ export class OrderSchema extends PothosSchema {
|
||||
const order = await this.prisma.order.findUnique({
|
||||
where: { id: schedule.orderId },
|
||||
})
|
||||
if (
|
||||
order?.status === OrderStatus.PAID ||
|
||||
order?.status === OrderStatus.PENDING
|
||||
) {
|
||||
if (order?.status === OrderStatus.PAID || order?.status === OrderStatus.PENDING) {
|
||||
throw new Error('Schedule already has an order')
|
||||
}
|
||||
}
|
||||
@@ -213,17 +204,9 @@ export class OrderSchema extends PothosSchema {
|
||||
description: service.name,
|
||||
buyerName: ctx.http.me?.name ?? '',
|
||||
buyerEmail: ctx.http.me?.email ?? '',
|
||||
returnUrl: `${process.env.PAYOS_RETURN_URL}`.replace(
|
||||
'<serviceId>',
|
||||
service.id,
|
||||
),
|
||||
cancelUrl: `${process.env.PAYOS_RETURN_URL}`.replace(
|
||||
'<serviceId>',
|
||||
service.id,
|
||||
),
|
||||
expiredAt: DateTimeUtils.now()
|
||||
.plus({ minutes: 15 })
|
||||
.toUnixInteger(),
|
||||
returnUrl: `${process.env.PAYOS_RETURN_URL}`.replace('<serviceId>', service.id),
|
||||
cancelUrl: `${process.env.PAYOS_RETURN_URL}`.replace('<serviceId>', service.id),
|
||||
expiredAt: DateTimeUtils.now().plus({ minutes: 15 }).toUnixInteger(),
|
||||
})
|
||||
// update order payment id
|
||||
await this.prisma.order.update({
|
||||
@@ -269,10 +252,7 @@ export class OrderSchema extends PothosSchema {
|
||||
description: 'Update an existing order.',
|
||||
args: {
|
||||
data: t.arg({
|
||||
type: this.builder.generator.getUpdateInput('Order', [
|
||||
'status',
|
||||
'total',
|
||||
]),
|
||||
type: this.builder.generator.getUpdateInput('Order', ['status', 'total']),
|
||||
required: true,
|
||||
}),
|
||||
where: t.arg({
|
||||
|
||||
Reference in New Issue
Block a user