saleor-dashboard/src/orders/queries.ts

321 lines
5.5 KiB
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import gql from "graphql-tag";
2019-10-15 12:17:35 +00:00
import TopLevelSearch from "../containers/TopLevelSearch";
2019-06-19 14:40:52 +00:00
import { TypedQuery } from "../queries";
import { OrderDetails, OrderDetailsVariables } from "./types/OrderDetails";
import {
OrderDraftList,
OrderDraftListVariables
} from "./types/OrderDraftList";
import { OrderList, OrderListVariables } from "./types/OrderList";
import {
SearchOrderVariant as SearchOrderVariantType,
SearchOrderVariantVariables
} from "./types/SearchOrderVariant";
export const fragmentOrderEvent = gql`
fragment OrderEventFragment on OrderEvent {
id
amount
date
email
emailType
message
quantity
type
user {
id
email
}
}
`;
export const fragmentAddress = gql`
fragment AddressFragment on Address {
city
cityArea
companyName
country {
__typename
code
country
}
countryArea
firstName
id
lastName
phone
postalCode
streetAddress1
streetAddress2
}
`;
export const fragmentOrderLine = gql`
fragment OrderLineFragment on OrderLine {
id
isShippingRequired
productName
productSku
quantity
quantityFulfilled
unitPrice {
gross {
amount
currency
}
net {
amount
currency
}
}
thumbnail {
url
}
}
`;
export const fragmentOrderDetails = gql`
${fragmentAddress}
${fragmentOrderEvent}
${fragmentOrderLine}
fragment OrderDetailsFragment on Order {
id
billingAddress {
...AddressFragment
}
canFinalize
created
customerNote
events {
...OrderEventFragment
}
fulfillments {
id
lines {
id
quantity
orderLine {
...OrderLineFragment
}
}
fulfillmentOrder
status
trackingNumber
}
lines {
...OrderLineFragment
}
number
paymentStatus
shippingAddress {
...AddressFragment
}
shippingMethod {
id
}
shippingMethodName
shippingPrice {
gross {
amount
currency
}
}
status
subtotal {
gross {
amount
currency
}
}
total {
gross {
amount
currency
}
tax {
amount
currency
}
}
actions
totalAuthorized {
amount
currency
}
totalCaptured {
amount
currency
}
user {
id
email
}
userEmail
availableShippingMethods {
id
name
price {
amount
currency
}
}
}
`;
export const orderListQuery = gql`
${fragmentAddress}
query OrderList(
$first: Int
$after: String
$last: Int
$before: String
$filter: OrderFilterInput
) {
orders(
before: $before
after: $after
first: $first
last: $last
filter: $filter
) {
edges {
node {
__typename
billingAddress {
...AddressFragment
}
created
id
number
paymentStatus
status
total {
__typename
gross {
__typename
amount
currency
}
}
userEmail
}
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
`;
export const TypedOrderListQuery = TypedQuery<OrderList, OrderListVariables>(
orderListQuery
);
export const orderDraftListQuery = gql`
${fragmentAddress}
query OrderDraftList(
$first: Int
$after: String
$last: Int
$before: String
2019-09-11 14:28:42 +00:00
$filter: OrderDraftFilterInput
2019-06-19 14:40:52 +00:00
) {
2019-09-11 14:28:42 +00:00
draftOrders(
before: $before
after: $after
first: $first
last: $last
filter: $filter
) {
2019-06-19 14:40:52 +00:00
edges {
node {
__typename
billingAddress {
...AddressFragment
}
created
id
number
paymentStatus
status
total {
__typename
gross {
__typename
amount
currency
}
}
userEmail
}
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}
`;
export const TypedOrderDraftListQuery = TypedQuery<
OrderDraftList,
OrderDraftListVariables
>(orderDraftListQuery);
export const orderDetailsQuery = gql`
${fragmentOrderDetails}
query OrderDetails($id: ID!) {
order(id: $id) {
...OrderDetailsFragment
}
shop {
countries {
code
country
}
defaultWeightUnit
}
}
`;
export const TypedOrderDetailsQuery = TypedQuery<
OrderDetails,
OrderDetailsVariables
>(orderDetailsQuery);
export const searchOrderVariant = gql`
query SearchOrderVariant($first: Int!, $query: String!, $after: String) {
2019-10-15 12:17:35 +00:00
search: products(query: $query, first: $first, after: $after) {
2019-06-19 14:40:52 +00:00
edges {
node {
id
name
thumbnail {
url
}
variants {
id
name
sku
price {
amount
currency
}
}
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}
`;
2019-10-15 12:17:35 +00:00
export const SearchOrderVariant = TopLevelSearch<
2019-06-19 14:40:52 +00:00
SearchOrderVariantType,
SearchOrderVariantVariables
>(searchOrderVariant);