saleor-dashboard/src/fragments/orders.ts
Dominik Żegleń 2a52eb581c
Update apollo to v3 (#1837)
* Update apollo to v3

* Fix imports

* Add generated file to ignored

* Use proper import

* Tidy up code

* Remove unused packages

* Fix tests
2022-02-21 14:32:38 +01:00

338 lines
5.1 KiB
TypeScript

import { gql } from "@apollo/client";
import { fragmentAddress } from "./address";
import { metadataFragment } from "./metadata";
import { fragmentMoney } from "./products";
export const fragmentOrderEvent = gql`
fragment OrderEventFragment on OrderEvent {
id
amount
shippingCostsIncluded
date
email
emailType
invoiceNumber
discount {
valueType
value
reason
amount {
amount
currency
}
oldValueType
oldValue
oldAmount {
amount
currency
}
}
relatedOrder {
id
number
}
message
quantity
transactionReference
type
user {
id
email
firstName
lastName
}
app {
id
name
appUrl
}
lines {
quantity
itemName
discount {
valueType
value
reason
amount {
amount
currency
}
oldValueType
oldValue
oldAmount {
amount
currency
}
}
orderLine {
id
productName
variantName
}
}
}
`;
export const fragmentOrderLine = gql`
fragment OrderLineFragment on OrderLine {
id
isShippingRequired
variant {
id
quantityAvailable
preorder {
endDate
}
}
productName
productSku
quantity
quantityFulfilled
quantityToFulfill
unitDiscount {
amount
currency
}
unitDiscountValue
unitDiscountReason
unitDiscountType
undiscountedUnitPrice {
currency
gross {
amount
currency
}
net {
amount
currency
}
}
unitPrice {
gross {
amount
currency
}
net {
amount
currency
}
}
thumbnail {
url
}
}
`;
export const fragmentRefundOrderLine = gql`
fragment RefundOrderLineFragment on OrderLine {
id
productName
quantity
unitPrice {
gross {
...Money
}
}
thumbnail(size: 64) {
url
}
}
`;
export const fulfillmentFragment = gql`
${fragmentOrderLine}
fragment FulfillmentFragment on Fulfillment {
id
lines {
id
quantity
orderLine {
...OrderLineFragment
}
}
fulfillmentOrder
status
trackingNumber
warehouse {
id
name
}
}
`;
export const invoiceFragment = gql`
fragment InvoiceFragment on Invoice {
id
number
createdAt
url
status
}
`;
export const fragmentOrderDetails = gql`
${fragmentAddress}
${fragmentOrderEvent}
${fragmentOrderLine}
${fulfillmentFragment}
${invoiceFragment}
${metadataFragment}
${fragmentMoney}
fragment OrderDetailsFragment on Order {
id
token
...MetadataFragment
billingAddress {
...AddressFragment
}
giftCards {
events {
id
type
orderId
balance {
initialBalance {
...Money
}
currentBalance {
...Money
}
oldInitialBalance {
...Money
}
oldCurrentBalance {
...Money
}
}
}
}
isShippingRequired
canFinalize
created
customerNote
discounts {
id
type
calculationMode: valueType
value
reason
amount {
...Money
}
}
events {
...OrderEventFragment
}
fulfillments {
...FulfillmentFragment
}
lines {
...OrderLineFragment
}
number
isPaid
paymentStatus
shippingAddress {
...AddressFragment
}
deliveryMethod {
__typename
... on ShippingMethod {
id
}
... on Warehouse {
id
clickAndCollectOption
}
}
shippingMethod {
id
}
shippingMethodName
collectionPointName
shippingPrice {
gross {
amount
currency
}
}
status
subtotal {
gross {
...Money
}
net {
...Money
}
}
total {
gross {
...Money
}
net {
...Money
}
tax {
...Money
}
}
actions
totalAuthorized {
...Money
}
totalCaptured {
...Money
}
undiscountedTotal {
net {
...Money
}
gross {
...Money
}
}
user {
id
email
}
userEmail
shippingMethods {
id
name
price {
...Money
}
active
message
}
invoices {
...InvoiceFragment
}
channel {
isActive
id
name
currencyCode
slug
defaultCountry {
code
}
}
isPaid
}
`;
export const fragmentOrderSettings = gql`
fragment OrderSettingsFragment on OrderSettings {
automaticallyConfirmAllNewOrders
automaticallyFulfillNonShippableGiftCard
}
`;
export const fragmentShopOrderSettings = gql`
fragment ShopOrderSettingsFragment on Shop {
fulfillmentAutoApprove
fulfillmentAllowUnpaid
}
`;