saleor-dashboard/src/orders/views/OrderDetails/OrderDraftDetails/index.tsx

330 lines
10 KiB
TypeScript
Raw Normal View History

import { WindowTitle } from "@saleor/components/WindowTitle";
import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config";
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
import {
OrderDetailsQuery,
OrderDraftCancelMutation,
OrderDraftCancelMutationVariables,
OrderDraftFinalizeMutation,
OrderDraftFinalizeMutationVariables,
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
OrderDraftUpdateMutation,
OrderDraftUpdateMutationVariables,
OrderLineUpdateMutation,
OrderLineUpdateMutationVariables,
StockAvailability,
useChannelUsabilityDataQuery,
useCustomerAddressesQuery,
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
} from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import { CustomerEditData } from "@saleor/orders/components/OrderCustomer";
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
import { OrderCustomerAddressesEditDialogOutput } from "@saleor/orders/components/OrderCustomerAddressesEditDialog/types";
import {
CustomerChangeActionEnum,
OrderCustomerChangeData,
} from "@saleor/orders/components/OrderCustomerChangeDialog/form";
import OrderCustomerChangeDialog from "@saleor/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog";
import { getVariantSearchAddress } from "@saleor/orders/utils/data";
import { OrderDiscountProvider } from "@saleor/products/components/OrderDiscountProviders/OrderDiscountProvider";
import { OrderLineDiscountProvider } from "@saleor/products/components/OrderDiscountProviders/OrderLineDiscountProvider";
import useCustomerSearch from "@saleor/searches/useCustomerSearch";
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
import { useOrderVariantSearch } from "@saleor/searches/useOrderVariantSearch";
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
import { PartialMutationProviderOutput } from "@saleor/types";
import { mapEdgesToItems } from "@saleor/utils/maps";
import React from "react";
import { useIntl } from "react-intl";
import { customerUrl } from "../../../../customers/urls";
Exit dirty form (#1816) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Fixes after review * Add default value for useform prop opts so the app doesn't crash * Add missing category prop to getting initial data for category details form * Add exit dialog to everywhere WIP (#1600) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Add CommonUseFormResultWithHandlers type for later use and refactor handleFormSubmit util * Refactor login form not to use custom form since it doesn't need to * Add exit form dialog to order refund page * Add exit form dialog to order return page * Add exit form dialog to order order settings page * Add exit form dialog to product variant page * Add exit form dialog to product create page * Add exit form dialog to product update page * Add exit form dialog to product variant create page * Fix confirm leave prop passing in generic Form * Add util function to handle for submit to extract errors * Add confirmLeave prop to generic forms * Move handleChange for custom forms to useForm * Add exit dialog to more forms * Add extract mutation errors util function * Add extracting errors to submit functions that use metadata create handler * Fix typo * Add missing category prop to getting initial data for category details form * Fix types * wip * wip * wip * wip * Fix types & refactor * Fix types & refactor * Fix typescript * Fix unmatching tag * Fixes * Add handling of multiple forms at once to exit dirty form provider * Change all usages of ExitFormDialogContext to designated hook * wip * wip * wip * Fix types wip * Fix types * Remove console logs * Add isSubmitting prop to exit form dialog in order to avoid enabling exit dialog while submit is still in progresS * Replace handleSubmit global util with a hook to use exit form dialog props inside * Move useHandleSubmit to general hooks dir, update imports * Small fixes * Update snapshots * Fix types * Small fixes due to extensive rebase * Update package lock * Fixes after rebase * Remove exit form from customer address dialog * Fix types and update messages * Fix types * Change imports names * Refactor * Remove unnecessary console.log * Update types, snapshots. etc after rebase
2022-02-01 09:58:06 +00:00
import {
extractMutationErrors,
getStringOrPlaceholder,
Exit dirty form (#1816) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Fixes after review * Add default value for useform prop opts so the app doesn't crash * Add missing category prop to getting initial data for category details form * Add exit dialog to everywhere WIP (#1600) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Add CommonUseFormResultWithHandlers type for later use and refactor handleFormSubmit util * Refactor login form not to use custom form since it doesn't need to * Add exit form dialog to order refund page * Add exit form dialog to order return page * Add exit form dialog to order order settings page * Add exit form dialog to product variant page * Add exit form dialog to product create page * Add exit form dialog to product update page * Add exit form dialog to product variant create page * Fix confirm leave prop passing in generic Form * Add util function to handle for submit to extract errors * Add confirmLeave prop to generic forms * Move handleChange for custom forms to useForm * Add exit dialog to more forms * Add extract mutation errors util function * Add extracting errors to submit functions that use metadata create handler * Fix typo * Add missing category prop to getting initial data for category details form * Fix types * wip * wip * wip * wip * Fix types & refactor * Fix types & refactor * Fix typescript * Fix unmatching tag * Fixes * Add handling of multiple forms at once to exit dirty form provider * Change all usages of ExitFormDialogContext to designated hook * wip * wip * wip * Fix types wip * Fix types * Remove console logs * Add isSubmitting prop to exit form dialog in order to avoid enabling exit dialog while submit is still in progresS * Replace handleSubmit global util with a hook to use exit form dialog props inside * Move useHandleSubmit to general hooks dir, update imports * Small fixes * Update snapshots * Fix types * Small fixes due to extensive rebase * Update package lock * Fixes after rebase * Remove exit form from customer address dialog * Fix types and update messages * Fix types * Change imports names * Refactor * Remove unnecessary console.log * Update types, snapshots. etc after rebase
2022-02-01 09:58:06 +00:00
} from "../../../../misc";
import { productUrl } from "../../../../products/urls";
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
import OrderAddressFields from "../../../components/OrderAddressFields/OrderAddressFields";
import OrderDraftCancelDialog from "../../../components/OrderDraftCancelDialog/OrderDraftCancelDialog";
import OrderDraftPage from "../../../components/OrderDraftPage";
import OrderProductAddDialog from "../../../components/OrderProductAddDialog";
import OrderShippingMethodEditDialog from "../../../components/OrderShippingMethodEditDialog";
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
import {
orderDraftListUrl,
OrderUrlDialog,
OrderUrlQueryParams,
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
} from "../../../urls";
interface OrderDraftDetailsProps {
id: string;
params: OrderUrlQueryParams;
loading: any;
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
data: OrderDetailsQuery;
orderAddNote: any;
orderLineUpdate: PartialMutationProviderOutput<
OrderLineUpdateMutation,
OrderLineUpdateMutationVariables
>;
orderLineDelete: any;
orderShippingMethodUpdate: any;
orderLinesAdd: any;
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
orderDraftUpdate: PartialMutationProviderOutput<
Use graphql-codegen (#1874) * Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
2022-03-09 08:56:55 +00:00
OrderDraftUpdateMutation,
OrderDraftUpdateMutationVariables
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
>;
orderDraftCancel: PartialMutationProviderOutput<
OrderDraftCancelMutation,
OrderDraftCancelMutationVariables
>;
orderDraftFinalize: PartialMutationProviderOutput<
OrderDraftFinalizeMutation,
OrderDraftFinalizeMutationVariables
>;
openModal: (action: OrderUrlDialog, newParams?: OrderUrlQueryParams) => void;
closeModal: any;
}
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
export const isAnyAddressEditModalOpen = (uri: string | undefined): boolean =>
[
"edit-customer-addresses",
"edit-shipping-address",
"edit-billing-address",
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
].includes(uri);
export const OrderDraftDetails: React.FC<OrderDraftDetailsProps> = ({
id,
params,
loading,
data,
orderAddNote,
orderLineUpdate,
orderLineDelete,
orderShippingMethodUpdate,
orderLinesAdd,
orderDraftUpdate,
orderDraftCancel,
orderDraftFinalize,
openModal,
closeModal,
}) => {
const order = data.order;
const navigate = useNavigator();
const { data: channelUsabilityData } = useChannelUsabilityDataQuery({
variables: {
channel: order.channel.slug,
},
});
const {
loadMore,
search: variantSearch,
result: variantSearchOpts,
} = useOrderVariantSearch({
variables: {
...DEFAULT_INITIAL_SEARCH_DATA,
channel: order.channel.slug,
address: getVariantSearchAddress(order),
isPublished: true,
stockAvailability: StockAvailability.IN_STOCK,
},
});
const {
loadMore: loadMoreCustomers,
search: searchUsers,
result: users,
} = useCustomerSearch({
variables: DEFAULT_INITIAL_SEARCH_DATA,
});
const {
data: customerAddresses,
loading: customerAddressesLoading,
} = useCustomerAddressesQuery({
variables: {
id: order?.user?.id,
},
skip: !order?.user?.id || !isAnyAddressEditModalOpen(params.action),
});
const intl = useIntl();
const handleCustomerChange = async ({
user,
userEmail,
prevUser,
prevUserEmail,
}: CustomerEditData) => {
const sameUser = user && user === prevUser;
const sameUserEmail = userEmail && userEmail === prevUserEmail;
if (sameUser || sameUserEmail) {
return;
}
const result = await orderDraftUpdate.mutate({
id,
input: {
user,
userEmail,
},
});
if (result?.data?.draftOrderUpdate?.errors?.length) {
return;
}
const modalUri = prevUser ? "customer-change" : "edit-customer-addresses";
openModal(modalUri);
};
const handleCustomerChangeAction = (data: OrderCustomerChangeData) => {
if (data.changeActionOption === CustomerChangeActionEnum.CHANGE_ADDRESS) {
openModal("edit-customer-addresses");
} else {
closeModal();
}
};
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
const handleCustomerChangeAddresses = async (
data: Partial<OrderCustomerAddressesEditDialogOutput>,
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
): Promise<any> =>
orderDraftUpdate.mutate({
id,
input: data,
});
const handleOrderDraftCancel = async () => {
const errors = await extractMutationErrors(orderDraftCancel.mutate({ id }));
if (!errors.length) {
navigate(orderDraftListUrl());
}
return errors;
};
const errors = orderDraftFinalize.opts.data?.draftOrderComplete.errors || [];
return (
<>
<WindowTitle
title={intl.formatMessage(
{
id: "TLNf6K",
defaultMessage: "Draft Order #{orderNumber}",
description: "window title",
},
{
orderNumber: getStringOrPlaceholder(data?.order?.number),
},
)}
/>
<OrderDiscountProvider order={order}>
<OrderLineDiscountProvider order={order}>
<OrderDraftPage
disabled={loading}
errors={errors}
onNoteAdd={variables =>
Exit dirty form (#1816) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Fixes after review * Add default value for useform prop opts so the app doesn't crash * Add missing category prop to getting initial data for category details form * Add exit dialog to everywhere WIP (#1600) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Add CommonUseFormResultWithHandlers type for later use and refactor handleFormSubmit util * Refactor login form not to use custom form since it doesn't need to * Add exit form dialog to order refund page * Add exit form dialog to order return page * Add exit form dialog to order order settings page * Add exit form dialog to product variant page * Add exit form dialog to product create page * Add exit form dialog to product update page * Add exit form dialog to product variant create page * Fix confirm leave prop passing in generic Form * Add util function to handle for submit to extract errors * Add confirmLeave prop to generic forms * Move handleChange for custom forms to useForm * Add exit dialog to more forms * Add extract mutation errors util function * Add extracting errors to submit functions that use metadata create handler * Fix typo * Add missing category prop to getting initial data for category details form * Fix types * wip * wip * wip * wip * Fix types & refactor * Fix types & refactor * Fix typescript * Fix unmatching tag * Fixes * Add handling of multiple forms at once to exit dirty form provider * Change all usages of ExitFormDialogContext to designated hook * wip * wip * wip * Fix types wip * Fix types * Remove console logs * Add isSubmitting prop to exit form dialog in order to avoid enabling exit dialog while submit is still in progresS * Replace handleSubmit global util with a hook to use exit form dialog props inside * Move useHandleSubmit to general hooks dir, update imports * Small fixes * Update snapshots * Fix types * Small fixes due to extensive rebase * Update package lock * Fixes after rebase * Remove exit form from customer address dialog * Fix types and update messages * Fix types * Change imports names * Refactor * Remove unnecessary console.log * Update types, snapshots. etc after rebase
2022-02-01 09:58:06 +00:00
extractMutationErrors(
orderAddNote.mutate({
input: variables,
order: id,
}),
Exit dirty form (#1816) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Fixes after review * Add default value for useform prop opts so the app doesn't crash * Add missing category prop to getting initial data for category details form * Add exit dialog to everywhere WIP (#1600) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Add CommonUseFormResultWithHandlers type for later use and refactor handleFormSubmit util * Refactor login form not to use custom form since it doesn't need to * Add exit form dialog to order refund page * Add exit form dialog to order return page * Add exit form dialog to order order settings page * Add exit form dialog to product variant page * Add exit form dialog to product create page * Add exit form dialog to product update page * Add exit form dialog to product variant create page * Fix confirm leave prop passing in generic Form * Add util function to handle for submit to extract errors * Add confirmLeave prop to generic forms * Move handleChange for custom forms to useForm * Add exit dialog to more forms * Add extract mutation errors util function * Add extracting errors to submit functions that use metadata create handler * Fix typo * Add missing category prop to getting initial data for category details form * Fix types * wip * wip * wip * wip * Fix types & refactor * Fix types & refactor * Fix typescript * Fix unmatching tag * Fixes * Add handling of multiple forms at once to exit dirty form provider * Change all usages of ExitFormDialogContext to designated hook * wip * wip * wip * Fix types wip * Fix types * Remove console logs * Add isSubmitting prop to exit form dialog in order to avoid enabling exit dialog while submit is still in progresS * Replace handleSubmit global util with a hook to use exit form dialog props inside * Move useHandleSubmit to general hooks dir, update imports * Small fixes * Update snapshots * Fix types * Small fixes due to extensive rebase * Update package lock * Fixes after rebase * Remove exit form from customer address dialog * Fix types and update messages * Fix types * Change imports names * Refactor * Remove unnecessary console.log * Update types, snapshots. etc after rebase
2022-02-01 09:58:06 +00:00
)
}
users={mapEdgesToItems(users?.data?.search)}
2021-04-02 04:28:28 +00:00
hasMore={users?.data?.search?.pageInfo?.hasNextPage || false}
onFetchMore={loadMoreCustomers}
fetchUsers={searchUsers}
loading={users.loading}
usersLoading={users.loading}
onCustomerEdit={handleCustomerChange}
onDraftFinalize={() => orderDraftFinalize.mutate({ id })}
onDraftRemove={() => openModal("cancel")}
onOrderLineAdd={() => openModal("add-order-line")}
order={order}
channelUsabilityData={channelUsabilityData}
onProductClick={id => () =>
navigate(productUrl(encodeURIComponent(id)))}
onBillingAddressEdit={() => openModal("edit-billing-address")}
onShippingAddressEdit={() => openModal("edit-shipping-address")}
onShippingMethodEdit={() => openModal("edit-shipping")}
onOrderLineRemove={id => orderLineDelete.mutate({ id })}
onOrderLineChange={(id, data) =>
orderLineUpdate.mutate({
id,
input: data,
})
}
saveButtonBarState="default"
onProfileView={() => navigate(customerUrl(order.user.id))}
/>
</OrderLineDiscountProvider>
</OrderDiscountProvider>
<OrderDraftCancelDialog
confirmButtonState={orderDraftCancel.opts.status}
errors={orderDraftCancel.opts.data?.draftOrderDelete.errors || []}
onClose={closeModal}
onConfirm={handleOrderDraftCancel}
open={params.action === "cancel"}
orderNumber={getStringOrPlaceholder(order?.number)}
/>
<OrderShippingMethodEditDialog
confirmButtonState={orderShippingMethodUpdate.opts.status}
errors={
orderShippingMethodUpdate.opts.data?.orderUpdateShipping.errors || []
}
open={params.action === "edit-shipping"}
shippingMethod={order?.shippingMethod?.id}
shippingMethods={order?.shippingMethods}
onClose={closeModal}
onSubmit={variables =>
orderShippingMethodUpdate.mutate({
id,
input: {
shippingMethod: variables.shippingMethod,
},
})
}
/>
<OrderProductAddDialog
confirmButtonState={orderLinesAdd.opts.status}
errors={orderLinesAdd.opts.data?.orderLinesCreate.errors || []}
loading={variantSearchOpts.loading}
open={params.action === "add-order-line"}
hasMore={variantSearchOpts.data?.search.pageInfo.hasNextPage}
products={mapEdgesToItems(variantSearchOpts?.data?.search)}
selectedChannelId={order?.channel?.id}
onClose={closeModal}
onFetch={variantSearch}
onFetchMore={loadMore}
onSubmit={variants =>
Exit dirty form (#1816) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Fixes after review * Add default value for useform prop opts so the app doesn't crash * Add missing category prop to getting initial data for category details form * Add exit dialog to everywhere WIP (#1600) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Add CommonUseFormResultWithHandlers type for later use and refactor handleFormSubmit util * Refactor login form not to use custom form since it doesn't need to * Add exit form dialog to order refund page * Add exit form dialog to order return page * Add exit form dialog to order order settings page * Add exit form dialog to product variant page * Add exit form dialog to product create page * Add exit form dialog to product update page * Add exit form dialog to product variant create page * Fix confirm leave prop passing in generic Form * Add util function to handle for submit to extract errors * Add confirmLeave prop to generic forms * Move handleChange for custom forms to useForm * Add exit dialog to more forms * Add extract mutation errors util function * Add extracting errors to submit functions that use metadata create handler * Fix typo * Add missing category prop to getting initial data for category details form * Fix types * wip * wip * wip * wip * Fix types & refactor * Fix types & refactor * Fix typescript * Fix unmatching tag * Fixes * Add handling of multiple forms at once to exit dirty form provider * Change all usages of ExitFormDialogContext to designated hook * wip * wip * wip * Fix types wip * Fix types * Remove console logs * Add isSubmitting prop to exit form dialog in order to avoid enabling exit dialog while submit is still in progresS * Replace handleSubmit global util with a hook to use exit form dialog props inside * Move useHandleSubmit to general hooks dir, update imports * Small fixes * Update snapshots * Fix types * Small fixes due to extensive rebase * Update package lock * Fixes after rebase * Remove exit form from customer address dialog * Fix types and update messages * Fix types * Change imports names * Refactor * Remove unnecessary console.log * Update types, snapshots. etc after rebase
2022-02-01 09:58:06 +00:00
extractMutationErrors(
orderLinesAdd.mutate({
id,
input: variants.map(variant => ({
quantity: 1,
variantId: variant.id,
})),
}),
Exit dirty form (#1816) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Fixes after review * Add default value for useform prop opts so the app doesn't crash * Add missing category prop to getting initial data for category details form * Add exit dialog to everywhere WIP (#1600) * Add Exit form prompt component and change some minor styles in other components to match * Add Exit form prompt provider * Adjust generic form and useform hook to allow using exit form prompt provider * Add exit form prompt provider to index * wip * Fix types * Fix styling * Fix types * Revert warehouse details refactor * Add handling of edge cases to exit prompt * Refactor, add comments, fix some types * Refactor after exit form dialog name change * fix types * Add CommonUseFormResultWithHandlers type for later use and refactor handleFormSubmit util * Refactor login form not to use custom form since it doesn't need to * Add exit form dialog to order refund page * Add exit form dialog to order return page * Add exit form dialog to order order settings page * Add exit form dialog to product variant page * Add exit form dialog to product create page * Add exit form dialog to product update page * Add exit form dialog to product variant create page * Fix confirm leave prop passing in generic Form * Add util function to handle for submit to extract errors * Add confirmLeave prop to generic forms * Move handleChange for custom forms to useForm * Add exit dialog to more forms * Add extract mutation errors util function * Add extracting errors to submit functions that use metadata create handler * Fix typo * Add missing category prop to getting initial data for category details form * Fix types * wip * wip * wip * wip * Fix types & refactor * Fix types & refactor * Fix typescript * Fix unmatching tag * Fixes * Add handling of multiple forms at once to exit dirty form provider * Change all usages of ExitFormDialogContext to designated hook * wip * wip * wip * Fix types wip * Fix types * Remove console logs * Add isSubmitting prop to exit form dialog in order to avoid enabling exit dialog while submit is still in progresS * Replace handleSubmit global util with a hook to use exit form dialog props inside * Move useHandleSubmit to general hooks dir, update imports * Small fixes * Update snapshots * Fix types * Small fixes due to extensive rebase * Update package lock * Fixes after rebase * Remove exit form from customer address dialog * Fix types and update messages * Fix types * Change imports names * Refactor * Remove unnecessary console.log * Update types, snapshots. etc after rebase
2022-02-01 09:58:06 +00:00
)
}
/>
<OrderCustomerChangeDialog
open={params.action === "customer-change"}
onClose={closeModal}
onConfirm={handleCustomerChangeAction}
/>
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
<OrderAddressFields
action={params?.action}
orderShippingAddress={order?.shippingAddress}
orderBillingAddress={order?.billingAddress}
customerAddressesLoading={customerAddressesLoading}
isDraft
countries={data?.shop?.countries}
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
customer={customerAddresses?.user}
onClose={closeModal}
Refactor changing address in order details directly (#1697) (#1818) * Refactor changing address in order details directly (#1697) * wip change address edit buttons behaviour in order draft * wip modify dialog view when customer is not changed * wip remove old address edit modal * wip rm old address modal storybook * wip async search state change * wip disable edit in draft when no customer is selected * wip fix submitting issues * wip allow single address mutation * wip fix billing change & manual address change * wip fix covered country dropdown * wip add address clone checkbox * wip normal order details & unconfirmed views * wip messages minor fixes * wip clone address checkbox on new address input option * Storybook update * cleanup * billing same as shipping fixes * improve stories titles & move to component folder * improve continueToAddressSearchState readibility * improve dialog title/description message descriptors * change .then() to await * Remove redundant onClick arrow function Co-authored-by: Dominik Żegleń <flesz3@o2.pl> * Improve OrderAddressFields component * move shipping & billing address edit props outside file * Update snapshots * fix mutation output types in order views * Fix confirm button state type * fix skipping query when modal is refreshed * fix cancel button to match designs * update dialog headers * fix customer address choice card styling for blue theme * change hidecard to showcard * export types to local file * improve isAnyAddressEditModalOpen function * fix cut hover effect on inputs * fix submitting modal when modal is closed with x button * fix validation & initial form data * update messages * Update partial mutation return type * Add vertical spacer component * Revert CardSpacer changes * Change some of Form & Card spacers to Vertical Spacers * Fix makeStyles import in VerticalSpacer * Fix border color for AddressCards * Add type to addressFieldsCommonProps object * Change stories subtitles to lowercase * Fix country choices type * Fix setState react type * Improve address change handlers * Update snapshots * Fix default country not showing up in address edit single autocomplete field Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com> * Fix linter issue Co-authored-by: Dominik Żegleń <flesz3@o2.pl> Co-authored-by: Magdalena Markusik <magdalena.markusik@mirumee.com>
2022-02-02 11:22:39 +00:00
onConfirm={handleCustomerChangeAddresses}
confirmButtonState={orderDraftUpdate.opts.status}
errors={orderDraftUpdate.opts.data?.draftOrderUpdate.errors}
/>
</>
);
};
export default OrderDraftDetails;