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 { getMutationProviderData } from "../../misc";
|
||||||
import { PartialMutationProviderOutput } from "../../types";
|
import { PartialMutationProviderOutput } from "../../types";
|
||||||
import {
|
import {
|
||||||
|
TypedInvoiceEmailSendMutation,
|
||||||
TypedInvoiceRequestMutation,
|
TypedInvoiceRequestMutation,
|
||||||
TypedOrderAddNoteMutation,
|
TypedOrderAddNoteMutation,
|
||||||
TypedOrderCancelMutation,
|
TypedOrderCancelMutation,
|
||||||
|
@ -21,6 +22,10 @@ import {
|
||||||
TypedOrderUpdateMutation,
|
TypedOrderUpdateMutation,
|
||||||
TypedOrderVoidMutation
|
TypedOrderVoidMutation
|
||||||
} from "../mutations";
|
} from "../mutations";
|
||||||
|
import {
|
||||||
|
InvoiceEmailSend,
|
||||||
|
InvoiceEmailSendVariables
|
||||||
|
} from "../types/InvoiceEmailSend";
|
||||||
import {
|
import {
|
||||||
InvoiceRequest,
|
InvoiceRequest,
|
||||||
InvoiceRequestVariables
|
InvoiceRequestVariables
|
||||||
|
@ -137,6 +142,10 @@ interface OrderOperationsProps {
|
||||||
InvoiceRequest,
|
InvoiceRequest,
|
||||||
InvoiceRequestVariables
|
InvoiceRequestVariables
|
||||||
>;
|
>;
|
||||||
|
orderInvoiceSend: PartialMutationProviderOutput<
|
||||||
|
InvoiceEmailSend,
|
||||||
|
InvoiceEmailSendVariables
|
||||||
|
>;
|
||||||
}) => React.ReactNode;
|
}) => React.ReactNode;
|
||||||
onOrderFulfillmentCancel: (data: OrderFulfillmentCancel) => void;
|
onOrderFulfillmentCancel: (data: OrderFulfillmentCancel) => void;
|
||||||
onOrderFulfillmentUpdate: (data: OrderFulfillmentUpdateTracking) => void;
|
onOrderFulfillmentUpdate: (data: OrderFulfillmentUpdateTracking) => void;
|
||||||
|
@ -155,6 +164,7 @@ interface OrderOperationsProps {
|
||||||
onOrderLinesAdd: (data: OrderLinesAdd) => void;
|
onOrderLinesAdd: (data: OrderLinesAdd) => void;
|
||||||
onOrderLineUpdate: (data: OrderLineUpdate) => void;
|
onOrderLineUpdate: (data: OrderLineUpdate) => void;
|
||||||
onInvoiceRequest: (data: InvoiceRequest) => void;
|
onInvoiceRequest: (data: InvoiceRequest) => void;
|
||||||
|
onInvoiceSend: (data: InvoiceEmailSend) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OrderOperations: React.FC<OrderOperationsProps> = ({
|
const OrderOperations: React.FC<OrderOperationsProps> = ({
|
||||||
|
@ -175,7 +185,8 @@ const OrderOperations: React.FC<OrderOperationsProps> = ({
|
||||||
onOrderFulfillmentCancel,
|
onOrderFulfillmentCancel,
|
||||||
onOrderFulfillmentUpdate,
|
onOrderFulfillmentUpdate,
|
||||||
onOrderMarkAsPaid,
|
onOrderMarkAsPaid,
|
||||||
onInvoiceRequest
|
onInvoiceRequest,
|
||||||
|
onInvoiceSend
|
||||||
}) => (
|
}) => (
|
||||||
<TypedOrderVoidMutation onCompleted={onOrderVoid}>
|
<TypedOrderVoidMutation onCompleted={onOrderVoid}>
|
||||||
{(...orderVoid) => (
|
{(...orderVoid) => (
|
||||||
|
@ -252,61 +263,76 @@ const OrderOperations: React.FC<OrderOperationsProps> = ({
|
||||||
>
|
>
|
||||||
{(
|
{(
|
||||||
...invoiceRequest
|
...invoiceRequest
|
||||||
) =>
|
) => (
|
||||||
children({
|
<TypedInvoiceEmailSendMutation
|
||||||
orderAddNote: getMutationProviderData(
|
onCompleted={
|
||||||
...addNote
|
onInvoiceSend
|
||||||
),
|
}
|
||||||
orderCancel: getMutationProviderData(
|
>
|
||||||
...orderCancel
|
{(
|
||||||
),
|
...invoiceEmailSend
|
||||||
orderDraftCancel: getMutationProviderData(
|
) =>
|
||||||
...cancelDraft
|
children(
|
||||||
),
|
{
|
||||||
orderDraftFinalize: getMutationProviderData(
|
orderAddNote: getMutationProviderData(
|
||||||
...finalizeDraft
|
...addNote
|
||||||
),
|
),
|
||||||
orderDraftUpdate: getMutationProviderData(
|
orderCancel: getMutationProviderData(
|
||||||
...updateDraft
|
...orderCancel
|
||||||
),
|
),
|
||||||
orderFulfillmentCancel: getMutationProviderData(
|
orderDraftCancel: getMutationProviderData(
|
||||||
...cancelFulfillment
|
...cancelDraft
|
||||||
),
|
),
|
||||||
orderFulfillmentUpdateTracking: getMutationProviderData(
|
orderDraftFinalize: getMutationProviderData(
|
||||||
...updateTrackingNumber
|
...finalizeDraft
|
||||||
),
|
),
|
||||||
orderInvoiceRequest: getMutationProviderData(
|
orderDraftUpdate: getMutationProviderData(
|
||||||
...invoiceRequest
|
...updateDraft
|
||||||
),
|
),
|
||||||
orderLineDelete: getMutationProviderData(
|
orderFulfillmentCancel: getMutationProviderData(
|
||||||
...deleteOrderLine
|
...cancelFulfillment
|
||||||
),
|
),
|
||||||
orderLineUpdate: getMutationProviderData(
|
orderFulfillmentUpdateTracking: getMutationProviderData(
|
||||||
...updateOrderLine
|
...updateTrackingNumber
|
||||||
),
|
),
|
||||||
orderLinesAdd: getMutationProviderData(
|
orderInvoiceRequest: getMutationProviderData(
|
||||||
...addOrderLine
|
...invoiceRequest
|
||||||
),
|
),
|
||||||
orderPaymentCapture: getMutationProviderData(
|
orderInvoiceSend: getMutationProviderData(
|
||||||
...paymentCapture
|
...invoiceEmailSend
|
||||||
),
|
),
|
||||||
orderPaymentMarkAsPaid: getMutationProviderData(
|
orderLineDelete: getMutationProviderData(
|
||||||
...markAsPaid
|
...deleteOrderLine
|
||||||
),
|
),
|
||||||
orderPaymentRefund: getMutationProviderData(
|
orderLineUpdate: getMutationProviderData(
|
||||||
...paymentRefund
|
...updateOrderLine
|
||||||
),
|
),
|
||||||
orderShippingMethodUpdate: getMutationProviderData(
|
orderLinesAdd: getMutationProviderData(
|
||||||
...updateShippingMethod
|
...addOrderLine
|
||||||
),
|
),
|
||||||
orderUpdate: getMutationProviderData(
|
orderPaymentCapture: getMutationProviderData(
|
||||||
...update
|
...paymentCapture
|
||||||
),
|
),
|
||||||
orderVoid: getMutationProviderData(
|
orderPaymentMarkAsPaid: getMutationProviderData(
|
||||||
...orderVoid
|
...markAsPaid
|
||||||
)
|
),
|
||||||
})
|
orderPaymentRefund: getMutationProviderData(
|
||||||
}
|
...paymentRefund
|
||||||
|
),
|
||||||
|
orderShippingMethodUpdate: getMutationProviderData(
|
||||||
|
...updateShippingMethod
|
||||||
|
),
|
||||||
|
orderUpdate: getMutationProviderData(
|
||||||
|
...update
|
||||||
|
),
|
||||||
|
orderVoid: getMutationProviderData(
|
||||||
|
...orderVoid
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</TypedInvoiceEmailSendMutation>
|
||||||
|
)}
|
||||||
</TypedInvoiceRequestMutation>
|
</TypedInvoiceRequestMutation>
|
||||||
)}
|
)}
|
||||||
</TypedOrderMarkAsPaidMutation>
|
</TypedOrderMarkAsPaidMutation>
|
||||||
|
|
|
@ -12,6 +12,10 @@ import gql from "graphql-tag";
|
||||||
|
|
||||||
import { TypedMutation } from "../mutations";
|
import { TypedMutation } from "../mutations";
|
||||||
import { FulfillOrder, FulfillOrderVariables } from "./types/FulfillOrder";
|
import { FulfillOrder, FulfillOrderVariables } from "./types/FulfillOrder";
|
||||||
|
import {
|
||||||
|
InvoiceEmailSend,
|
||||||
|
InvoiceEmailSendVariables
|
||||||
|
} from "./types/InvoiceEmailSend";
|
||||||
import {
|
import {
|
||||||
InvoiceRequest,
|
InvoiceRequest,
|
||||||
InvoiceRequestVariables
|
InvoiceRequestVariables
|
||||||
|
@ -474,3 +478,22 @@ export const TypedInvoiceRequestMutation = TypedMutation<
|
||||||
InvoiceRequest,
|
InvoiceRequest,
|
||||||
InvoiceRequestVariables
|
InvoiceRequestVariables
|
||||||
>(invoiceRequestMutation);
|
>(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}
|
onDraftCancel={orderMessages.handleDraftCancel}
|
||||||
onOrderMarkAsPaid={orderMessages.handleOrderMarkAsPaid}
|
onOrderMarkAsPaid={orderMessages.handleOrderMarkAsPaid}
|
||||||
onInvoiceRequest={() => null}
|
onInvoiceRequest={() => null}
|
||||||
|
onInvoiceSend={() => null}
|
||||||
>
|
>
|
||||||
{({
|
{({
|
||||||
orderAddNote,
|
orderAddNote,
|
||||||
|
@ -168,6 +169,7 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
||||||
orderDraftFinalize,
|
orderDraftFinalize,
|
||||||
orderPaymentMarkAsPaid,
|
orderPaymentMarkAsPaid,
|
||||||
orderInvoiceRequest,
|
orderInvoiceRequest,
|
||||||
|
orderInvoiceSend,
|
||||||
}) => (
|
}) => (
|
||||||
<>
|
<>
|
||||||
{order?.status !== OrderStatus.DRAFT ? (
|
{order?.status !== OrderStatus.DRAFT ? (
|
||||||
|
@ -240,7 +242,9 @@ export const OrderDetails: React.FC<OrderDetailsProps> = ({ id, params }) => {
|
||||||
orderId: id,
|
orderId: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onSendInvoice={() => null}
|
onSendInvoice={(invoice) =>
|
||||||
|
orderInvoiceSend.mutate({ id: invoice.id })
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<OrderCannotCancelOrderDialog
|
<OrderCannotCancelOrderDialog
|
||||||
onClose={closeModal}
|
onClose={closeModal}
|
||||||
|
|
Loading…
Reference in a new issue