59 lines
3.5 KiB
TypeScript
59 lines
3.5 KiB
TypeScript
import { Arg, Args, Ctx, Mutation, Query, Resolver } from 'type-graphql';
|
|
import _ from 'lodash';
|
|
|
|
import OrderModel from '@services/module-payments/functions/orders/order.model';
|
|
import { ApolloContext } from '@lib/seed/interfaces/context';
|
|
import { AccountTypeEnum } from '@src/accounts/account.components';
|
|
import { ProviderSchema } from '../../schemas/provider.schema';
|
|
import { EngineMiddleware } from '@lib/seed/graphql/MiddlewareV2';
|
|
import { updateBusinessOrderStatus } from './business.service';
|
|
import { ChangeStatusInput } from './business.input';
|
|
import { OrderBusinessStatusEnum } from '@services/module-payments/components/components.orders';
|
|
|
|
@Resolver(OrderModel)
|
|
export default class OrderBusinessEngineMutationResolver {
|
|
/*
|
|
██████╗ ██╗ ██╗███████╗██████╗ ██╗ ██╗
|
|
██╔═══██╗██║ ██║██╔════╝██╔══██╗╚██╗ ██╔╝
|
|
██║ ██║██║ ██║█████╗ ██████╔╝ ╚████╔╝
|
|
██║▄▄ ██║██║ ██║██╔══╝ ██╔══██╗ ╚██╔╝
|
|
╚██████╔╝╚██████╔╝███████╗██║ ██║ ██║
|
|
╚══▀▀═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝
|
|
*/
|
|
|
|
@Mutation(() => ProviderSchema)
|
|
@EngineMiddleware({
|
|
authorization: [AccountTypeEnum.organisationOwner, AccountTypeEnum.storeManager],
|
|
checkOrganisation: true,
|
|
})
|
|
async businessOrdersMarkAsShipped(
|
|
@Arg('id') id: string,
|
|
@Arg('input') input: ChangeStatusInput,
|
|
@Ctx() ctx: ApolloContext,
|
|
): Promise<ProviderSchema | undefined> {
|
|
return await updateBusinessOrderStatus(id, OrderBusinessStatusEnum.shipped, ctx);
|
|
}
|
|
|
|
@Mutation(() => ProviderSchema)
|
|
@EngineMiddleware({
|
|
authorization: [AccountTypeEnum.organisationOwner, AccountTypeEnum.storeManager],
|
|
checkOrganisation: true,
|
|
})
|
|
async businessOrdersMarkAsCompleted(
|
|
@Arg('id') id: string,
|
|
@Arg('input') input: ChangeStatusInput,
|
|
@Ctx() ctx: ApolloContext,
|
|
): Promise<ProviderSchema | undefined> {
|
|
return await updateBusinessOrderStatus(id, OrderBusinessStatusEnum.completed, ctx);
|
|
}
|
|
|
|
/*
|
|
███╗ ███╗██╗ ██╗████████╗ █████╗ ████████╗ ██████╗ ██████╗ ███████╗
|
|
████╗ ████║██║ ██║╚══██╔══╝██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝
|
|
██╔████╔██║██║ ██║ ██║ ███████║ ██║ ██║ ██║██████╔╝███████╗
|
|
██║╚██╔╝██║██║ ██║ ██║ ██╔══██║ ██║ ██║ ██║██╔══██╗╚════██║
|
|
██║ ╚═╝ ██║╚██████╔╝ ██║ ██║ ██║ ██║ ╚██████╔╝██║ ██║███████║
|
|
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
|
*/
|
|
}
|