Implement send invoice email mutation
This commit is contained in:
parent
80ace6e435
commit
a612b2dfb0
4 changed files with 148 additions and 57 deletions
|
@ -3,6 +3,7 @@ import React from "react";
|
|||
import { getMutationProviderData } from "../../misc";
|
||||
import { PartialMutationProviderOutput } from "../../types";
|
||||
import {
|
||||
TypedInvoiceEmailSendMutation,
|
||||
TypedInvoiceRequestMutation,
|
||||
TypedOrderAddNoteMutation,
|
||||
TypedOrderCancelMutation,
|
||||
|
@ -21,6 +22,10 @@ import {
|
|||
TypedOrderUpdateMutation,
|
||||
TypedOrderVoidMutation
|
||||
} from "../mutations";
|
||||
import {
|
||||
InvoiceEmailSend,
|
||||
InvoiceEmailSendVariables
|
||||
} from "../types/InvoiceEmailSend";
|
||||
import {
|
||||
InvoiceRequest,
|
||||
InvoiceRequestVariables
|
||||
|
@ -137,6 +142,10 @@ interface OrderOperationsProps {
|
|||
InvoiceRequest,
|
||||
InvoiceRequestVariables
|
||||
>;
|
||||
orderInvoiceSend: PartialMutationProviderOutput<
|
||||
InvoiceEmailSend,
|
||||
InvoiceEmailSendVariables
|
||||
>;
|
||||
}) => React.ReactNode;
|
||||
onOrderFulfillmentCancel: (data: OrderFulfillmentCancel) => void;
|
||||
onOrderFulfillmentUpdate: (data: OrderFulfillmentUpdateTracking) => void;
|
||||
|
@ -155,6 +164,7 @@ interface OrderOperationsProps {
|
|||
onOrderLinesAdd: (data: OrderLinesAdd) => void;
|
||||
onOrderLineUpdate: (data: OrderLineUpdate) => void;
|
||||
onInvoiceRequest: (data: InvoiceRequest) => void;
|
||||
onInvoiceSend: (data: InvoiceEmailSend) => void;
|
||||
}
|
||||
|
||||
const OrderOperations: React.FC<OrderOperationsProps> = ({
|
||||
|
@ -175,7 +185,8 @@ const OrderOperations: React.FC<OrderOperationsProps> = ({
|
|||
onOrderFulfillmentCancel,
|
||||
onOrderFulfillmentUpdate,
|
||||
onOrderMarkAsPaid,
|
||||
onInvoiceRequest
|
||||
onInvoiceRequest,
|
||||
onInvoiceSend
|
||||
}) => (
|
||||
<TypedOrderVoidMutation onCompleted={onOrderVoid}>
|
||||
{(...orderVoid) => (
|
||||
|
@ -252,61 +263,76 @@ const OrderOperations: React.FC<OrderOperationsProps> = ({
|
|||
>
|
||||
{(
|
||||
...invoiceRequest
|
||||
) =>
|
||||
children({
|
||||
orderAddNote: getMutationProviderData(
|
||||
...addNote
|
||||
),
|
||||
orderCancel: getMutationProviderData(
|
||||
...orderCancel
|
||||
),
|
||||
orderDraftCancel: getMutationProviderData(
|
||||
...cancelDraft
|
||||
),
|
||||
orderDraftFinalize: getMutationProviderData(
|
||||
...finalizeDraft
|
||||
),
|
||||
orderDraftUpdate: getMutationProviderData(
|
||||
...updateDraft
|
||||
),
|
||||
orderFulfillmentCancel: getMutationProviderData(
|
||||
...cancelFulfillment
|
||||
),
|
||||
orderFulfillmentUpdateTracking: getMutationProviderData(
|
||||
...updateTrackingNumber
|
||||
),
|
||||
orderInvoiceRequest: getMutationProviderData(
|
||||
...invoiceRequest
|
||||
),
|
||||
orderLineDelete: getMutationProviderData(
|
||||
...deleteOrderLine
|
||||
),
|
||||
orderLineUpdate: getMutationProviderData(
|
||||
...updateOrderLine
|
||||
),
|
||||
orderLinesAdd: getMutationProviderData(
|
||||
...addOrderLine
|
||||
),
|
||||
orderPaymentCapture: getMutationProviderData(
|
||||
...paymentCapture
|
||||
),
|
||||
orderPaymentMarkAsPaid: getMutationProviderData(
|
||||
...markAsPaid
|
||||
),
|
||||
orderPaymentRefund: getMutationProviderData(
|
||||
...paymentRefund
|
||||
),
|
||||
orderShippingMethodUpdate: getMutationProviderData(
|
||||
...updateShippingMethod
|
||||
),
|
||||
orderUpdate: getMutationProviderData(
|
||||
...update
|
||||
),
|
||||
orderVoid: getMutationProviderData(
|
||||
...orderVoid
|
||||
)
|
||||
})
|
||||
}
|
||||
) => (
|
||||
<TypedInvoiceEmailSendMutation
|
||||
onCompleted={
|
||||
onInvoiceSend
|
||||
}
|
||||
>
|
||||
{(
|
||||
...invoiceEmailSend
|
||||
) =>
|
||||
children(
|
||||
{
|
||||
orderAddNote: getMutationProviderData(
|
||||
...addNote
|
||||
),
|
||||
orderCancel: getMutationProviderData(
|
||||
...orderCancel
|
||||
),
|
||||
orderDraftCancel: getMutationProviderData(
|
||||
...cancelDraft
|
||||
),
|
||||
orderDraftFinalize: getMutationProviderData(
|
||||
...finalizeDraft
|
||||
),
|
||||
orderDraftUpdate: getMutationProviderData(
|
||||
...updateDraft
|
||||
),
|
||||
orderFulfillmentCancel: getMutationProviderData(
|
||||
...cancelFulfillment
|
||||
),
|
||||
orderFulfillmentUpdateTracking: getMutationProviderData(
|
||||
...updateTrackingNumber
|
||||
),
|
||||
orderInvoiceRequest: getMutationProviderData(
|
||||
...invoiceRequest
|
||||
),
|
||||
orderInvoiceSend: getMutationProviderData(
|
||||
...invoiceEmailSend
|
||||
),
|
||||
orderLineDelete: getMutationProviderData(
|
||||
...deleteOrderLine
|
||||
),
|
||||
orderLineUpdate: getMutationProviderData(
|
||||
...updateOrderLine
|
||||
),
|
||||
orderLinesAdd: getMutationProviderData(
|
||||
...addOrderLine
|
||||
),
|
||||
orderPaymentCapture: getMutationProviderData(
|
||||
...paymentCapture
|
||||
),
|
||||
orderPaymentMarkAsPaid: getMutationProviderData(
|
||||
...markAsPaid
|
||||
),
|
||||
orderPaymentRefund: getMutationProviderData(
|
||||
...paymentRefund
|
||||
),
|
||||
orderShippingMethodUpdate: getMutationProviderData(
|
||||
...updateShippingMethod
|
||||
),
|
||||
orderUpdate: getMutationProviderData(
|
||||
...update
|
||||
),
|
||||
orderVoid: getMutationProviderData(
|
||||
...orderVoid
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
</TypedInvoiceEmailSendMutation>
|
||||
)}
|
||||
</TypedInvoiceRequestMutation>
|
||||
)}
|
||||
</TypedOrderMarkAsPaidMutation>
|
||||
|
|
|
@ -12,6 +12,10 @@ import gql from "graphql-tag";
|
|||
|
||||
import { TypedMutation } from "../mutations";
|
||||
import { FulfillOrder, FulfillOrderVariables } from "./types/FulfillOrder";
|
||||
import {
|
||||
InvoiceEmailSend,
|
||||
InvoiceEmailSendVariables
|
||||
} from "./types/InvoiceEmailSend";
|
||||
import {
|
||||
InvoiceRequest,
|
||||
InvoiceRequestVariables
|
||||
|
@ -474,3 +478,22 @@ export const TypedInvoiceRequestMutation = TypedMutation<
|
|||
InvoiceRequest,
|
||||
InvoiceRequestVariables
|
||||
>(invoiceRequestMutation);
|
||||
|
||||
const invoiceEmailSendMutation = gql`
|
||||
${invoiceErrorFragment}
|
||||
${fragmentInvoice}
|
||||
mutation InvoiceEmailSend($id: ID!) {
|
||||
sendInvoiceEmail(id: $id) {
|
||||
errors: invoiceErrors {
|
||||
...InvoiceErrorFragment
|
||||
}
|
||||
invoice {
|
||||
...InvoiceFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const TypedInvoiceEmailSendMutation = TypedMutation<
|
||||
InvoiceEmailSend,
|
||||
InvoiceEmailSendVariables
|
||||
>(invoiceEmailSendMutation);
|
||||
|
|
38
src/orders/types/InvoiceEmailSend.ts
Normal file
38
src/orders/types/InvoiceEmailSend.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { InvoiceErrorCode, JobStatusEnum } from "./../../types/globalTypes";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL mutation operation: InvoiceEmailSend
|
||||
// ====================================================
|
||||
|
||||
export interface InvoiceEmailSend_sendInvoiceEmail_errors {
|
||||
__typename: "InvoiceError";
|
||||
code: InvoiceErrorCode;
|
||||
field: string | null;
|
||||
}
|
||||
|
||||
export interface InvoiceEmailSend_sendInvoiceEmail_invoice {
|
||||
__typename: "Invoice";
|
||||
id: string;
|
||||
number: string | null;
|
||||
createdAt: any;
|
||||
url: string | null;
|
||||
status: JobStatusEnum;
|
||||
}
|
||||
|
||||
export interface InvoiceEmailSend_sendInvoiceEmail {
|
||||
__typename: "SendInvoiceEmail";
|
||||
errors: InvoiceEmailSend_sendInvoiceEmail_errors[];
|
||||
invoice: InvoiceEmailSend_sendInvoiceEmail_invoice | null;
|
||||
}
|
||||
|
||||
export interface InvoiceEmailSend {
|
||||
sendInvoiceEmail: InvoiceEmailSend_sendInvoiceEmail | null;
|
||||
}
|
||||
|
||||
export interface InvoiceEmailSendVariables {
|
||||
id: string;
|
||||
}
|
|
@ -149,6 +149,7 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
|||
onDraftCancel={orderMessages.handleDraftCancel}
|
||||
onOrderMarkAsPaid={orderMessages.handleOrderMarkAsPaid}
|
||||
onInvoiceRequest={() => null}
|
||||
onInvoiceSend={() => null}
|
||||
>
|
||||
{({
|
||||
orderAddNote,
|
||||
|
@ -168,6 +169,7 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
|||
orderDraftFinalize,
|
||||
orderPaymentMarkAsPaid,
|
||||
orderInvoiceRequest,
|
||||
orderInvoiceSend,
|
||||
}) => (
|
||||
<>
|
||||
{order?.status !== OrderStatus.DRAFT ? (
|
||||
|
@ -240,7 +242,9 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
|||
orderId: id,
|
||||
})
|
||||
}
|
||||
onSendInvoice={() => null}
|
||||
onSendInvoice={(invoice) =>
|
||||
orderInvoiceSend.mutate({ id: invoice.id })
|
||||
}
|
||||
/>
|
||||
<OrderCannotCancelOrderDialog
|
||||
onClose={closeModal}
|
||||
|
|
Loading…
Reference in a new issue