Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Rename Ø to maybe
Patryk Zawadzki8064c19d291a
diff --git a/saleor/static/dashboard-next/misc.ts b/saleor/static/dashboard-next/misc.tsindex 179ec3690e..0005713f54 100644--- a/saleor/static/dashboard-next/misc.ts+++ b/saleor/static/dashboard-next/misc.ts@@ -145,7 +145,7 @@ export const translatedTaxRates = () => ({[TaxRateType.WATER]: i18n.t("Water")});-export function Ø<T>(exp: () => T, d?: T) {+export function maybe<T>(exp: () => T, d?: T) {try {return exp();} catch {diff --git a/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx b/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsxindex a6941f27cf..790b01bdda 100644--- a/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx@@ -9,7 +9,7 @@ import PageHeader from "../../../components/PageHeader";import Skeleton from "../../../components/Skeleton";import Toggle from "../../../components/Toggle";import i18n from "../../../i18n";-import { Ø } from "../../../misc";+import { maybe } from "../../../misc";import { OrderEvents, OrderStatus } from "../../../types/globalTypes";import OrderAddressEditDialog from "../OrderAddressEditDialog";import OrderCancelDialog from "../OrderCancelDialog";@@ -276,7 +276,7 @@ class OrderDetailsPageComponent extends React.Component<openedShippingMethodEditDialog} = this.state;const isDraft = order ? order.status === OrderStatus.DRAFT : false;- const unfulfilled = Ø(() => order.lines.edges, [])+ const unfulfilled = maybe(() => order.lines.edges, []).map(edge => edge.node).filter(line => line.quantityFulfilled < line.quantity);return (@@ -306,16 +306,16 @@ class OrderDetailsPageComponent extends React.Component<<div className={classes.root}><div><OrderSummary- authorized={Ø(() => order.totalAuthorized)}- paid={Ø(() => order.totalCaptured)}- paymentStatus={Ø(() => order.paymentStatus)}- lines={Ø(() => order.lines.edges.map(edge => edge.node))}- shippingMethodName={Ø(() => order.shippingMethodName)}- shippingPrice={Ø(() => order.shippingPrice)}- status={Ø(() => order.status)}- subtotal={Ø(() => order.subtotal.gross)}- tax={Ø(() => order.total.tax)}- total={Ø(() => order.total.gross)}+ authorized={maybe(() => order.totalAuthorized)}+ paid={maybe(() => order.totalCaptured)}+ paymentStatus={maybe(() => order.paymentStatus)}+ lines={maybe(() => order.lines.edges.map(edge => edge.node))}+ shippingMethodName={maybe(() => order.shippingMethodName)}+ shippingPrice={maybe(() => order.shippingPrice)}+ status={maybe(() => order.status)}+ subtotal={maybe(() => order.subtotal.gross)}+ tax={maybe(() => order.total.tax)}+ total={maybe(() => order.total.gross)}onCapture={this.togglePaymentCaptureDialog}onCreate={onCreate}onFulfill={this.toggleFulfillmentDialog}@@ -403,7 +403,7 @@ class OrderDetailsPageComponent extends React.Component<<><OrderFulfillmentid={fulfillment.id}- lines={Ø(() =>+ lines={maybe(() =>fulfillment.lines.edges.map(edge => edge.node))}status={fulfillment.status}@@ -447,14 +447,14 @@ class OrderDetailsPageComponent extends React.Component<) : (<OrderFulfillment />)}- <OrderHistory history={Ø(() => order.events)} user={user} />+ <OrderHistory history={maybe(() => order.events)} user={user} /></div><div><OrderCustomer- billingAddress={Ø(() => order.billingAddress)}- client={Ø(() => order.user)}+ billingAddress={maybe(() => order.billingAddress)}+ client={maybe(() => order.user)}editCustomer={isDraft}- shippingAddress={Ø(() => order.shippingAddress)}+ shippingAddress={maybe(() => order.shippingAddress)}onBillingAddressEdit={this.toggleBillingAddressEditDialog}onCustomerEditClick={this.toggleCustomerEditDialog}onCustomerEmailClick={onCustomerEmailClick}diff --git a/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx b/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsxindex fab077e823..0dee2a9758 100644--- a/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx@@ -14,7 +14,7 @@ import * as React from "react";import Form from "../../../components/Form";import i18n from "../../../i18n";-import { Ø } from "../../../misc";+import { maybe } from "../../../misc";export interface FormData {lines: number[];@@ -55,7 +55,7 @@ const OrderFulfillmentDialog = decorate<OrderFulfillmentDialogProps>(<Dialog open={open}><Forminitial={{- lines: Ø(+ lines: maybe(() =>products.map(product => product.quantity - product.quantityFulfilleddiff --git a/saleor/static/dashboard-next/orders/containers/OrderOperations.tsx b/saleor/static/dashboard-next/orders/containers/OrderOperations.tsxindex 3546a30466..54a52b36ba 100644--- a/saleor/static/dashboard-next/orders/containers/OrderOperations.tsx+++ b/saleor/static/dashboard-next/orders/containers/OrderOperations.tsx@@ -13,7 +13,7 @@ import {OrderRefundMutation,OrderRefundMutationVariables} from "../../gql-types";-import { Ø } from "../../misc";+import { maybe } from "../../misc";import OrderCreateFulfillmentProvider from "./OrderCreateFulfillment";import OrderPaymentCaptureProvider from "./OrderPaymentCapture";import OrderPaymentRefundProvider from "./OrderPaymentRefund";@@ -67,15 +67,15 @@ const OrderOperations: React.StatelessComponent<OrderOperationsProps> = ({{createFulfillment =>children({errors: [- ...Ø(+ ...maybe(() => createFulfillment.data.fulfillmentCreate.errors,[] as any),- ...Ø(+ ...maybe(() => paymentCapture.data.orderCapture.errors,[] as any),- ...Ø(() => paymentRefund.data.orderRefund.errors, [] as any)+ ...maybe(() => paymentRefund.data.orderRefund.errors, [] as any)],orderCreateFulfillment: {data: createFulfillment.data,diff --git a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx b/saleor/static/dashboard-next/orders/views/OrderDetails.tsxindex 4811ecd981..00dc30f5c8 100644--- a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx+++ b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx@@ -11,7 +11,7 @@ import {OrderRefundMutation} from "../../gql-types";import i18n from "../../i18n";-import { Ø } from "../../misc";+import { maybe } from "../../misc";import { productUrl } from "../../products";import OrderDetailsPage from "../components/OrderDetailsPage";import OrderOperations from "../containers/OrderOperations";@@ -57,7 +57,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({data: OrderCaptureMutation) => {if (- !Ø(+ !maybe(() => data.orderCapture.errors.length)) {@@ -73,7 +73,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({data: OrderRefundMutation) => {if (- !Ø(() => data.orderRefund.errors.length)+ !maybe(() => data.orderRefund.errors.length)) {pushMessage({text: i18n.t(@@ -87,7 +87,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({data: OrderCreateFulfillmentMutation) => {if (- !Ø(+ !maybe(() =>data.fulfillmentCreate.errors.length)@@ -117,7 +117,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({}) => (<OrderDetailsPagefetchVariants={search}- variants={Ø(() =>+ variants={maybe(() =>searchOpts.data.products.edges.map(edge => edge.node).map(product => ({@@ -146,7 +146,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({navigate(orderListUrl)}order={order}- shippingMethods={Ø(() =>+ shippingMethods={maybe(() =>([] as Array<{id: string;name: string;@@ -165,7 +165,7 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({orderCreateFulfillment.mutate({input: {...variables,- lines: Ø(+ lines: maybe(() => order.lines.edges,[])diff --git a/saleor/static/dashboard-next/orders/views/OrderList.tsx b/saleor/static/dashboard-next/orders/views/OrderList.tsxindex 2dd3753eae..fedc651fb1 100644--- a/saleor/static/dashboard-next/orders/views/OrderList.tsx+++ b/saleor/static/dashboard-next/orders/views/OrderList.tsx@@ -2,7 +2,7 @@ import * as React from "react";import { orderListUrl, orderUrl } from "..";import Navigator from "../../components/Navigator";-import { createPaginationData, createPaginationState, Ø } from "../../misc";+import { createPaginationData, createPaginationState, maybe } from "../../misc";import OrderListPage from "../components/OrderListPage/OrderListPage";import { TypedOrderListQuery } from "../queries";@@ -32,13 +32,13 @@ export const OrderList: React.StatelessComponent<OrderListProps> = ({navigate,paginationState,orderListUrl,- Ø(() => data.orders.pageInfo),+ maybe(() => data.orders.pageInfo),loading);return (<OrderListPagedisabled={loading}- orders={Ø(() => data.orders.edges.map(edge => edge.node))}+ orders={maybe(() => data.orders.edges.map(edge => edge.node))}pageInfo={pageInfo}onAdd={() => undefined}onNextPage={loadNextPage}