diff --git a/.changeset/old-pianos-hope.md b/.changeset/old-pianos-hope.md
new file mode 100644
index 00000000000..acf3d6fb235
--- /dev/null
+++ b/.changeset/old-pianos-hope.md
@@ -0,0 +1,5 @@
+---
+"saleor-dashboard": patch
+---
+
+Flow settings in channel creation will now persist after channel is created
diff --git a/playwright/tests/channels.spec.ts b/playwright/tests/channels.spec.ts
index a29b6e46379..9065409e09e 100644
--- a/playwright/tests/channels.spec.ts
+++ b/playwright/tests/channels.spec.ts
@@ -3,7 +3,7 @@ import { ChannelPage } from "@pages/channelsPage";
import { ConfigurationPage } from "@pages/configurationPage";
import { expect, test } from "@playwright/test";
-test.use({ storageState: "./playwright/.auth/admin.json" });
+test.use({ storageState: "./playwright/.auth/admin.json", locale: "en" });
let configurationPage: ConfigurationPage;
let channelPage: ChannelPage;
@@ -25,6 +25,34 @@ test("TC: SALEOR_97 Create basic channel @e2e @channels", async () => {
await channelPage.expectSuccessBanner();
});
+test("TC: SALEOR_208 Create channel with all settings @e2e @channels", async () => {
+ const slugName = new Date().toISOString();
+ await configurationPage.gotoConfigurationView();
+ await configurationPage.openChannels();
+ await channelPage.clickCreateChannelButton();
+ await channelPage.typeChannelName();
+ await channelPage.typeSlugName(slugName);
+ await channelPage.selectCurrency("AFN - Afghanistan");
+ await channelPage.selectCountry("Afghanistan");
+ await channelPage.clickTransactionFlowCheckbox();
+ // Checking before save because checkboxes used to not work properly
+ await expect(channelPage.transactionFlowCheckbox).toBeChecked();
+ await channelPage.clickAllowUnpaidOrdersCheckbox();
+ await expect(channelPage.allowUnpaidOrdersCheckbox).toBeChecked();
+ await channelPage.clickAuthorizeInsteadOfChargingCheckbox();
+ await expect(channelPage.authorizeInsteadOfChargingCheckbox).toBeChecked();
+ await channelPage.clickSaveButton();
+ await channelPage.expectSuccessBanner();
+
+ // Checking again after save because state wasn't saved properly
+ await channelPage.page.waitForURL(
+ (url: URL) => !url.pathname.includes("add"),
+ );
+ await expect(channelPage.transactionFlowCheckbox).toBeChecked();
+ await expect(channelPage.authorizeInsteadOfChargingCheckbox).toBeChecked();
+ await expect(channelPage.allowUnpaidOrdersCheckbox).toBeChecked();
+});
+
test("TC: SALEOR_98 Edit channel - transaction flow, allow unpaid, authorize, prio high stock @e2e @channels", async () => {
await channelPage.gotoChannelDetails(CHANNELS.channelToBeEditedSettings.id);
await channelPage.clickTransactionFlowCheckbox();
diff --git a/src/channels/components/ChannelForm/AllowUnpaidOrders.tsx b/src/channels/components/ChannelForm/AllowUnpaidOrders.tsx
index fb0d3365f41..305499d7ea5 100644
--- a/src/channels/components/ChannelForm/AllowUnpaidOrders.tsx
+++ b/src/channels/components/ChannelForm/AllowUnpaidOrders.tsx
@@ -10,12 +10,14 @@ interface AllowUnpaidOrdersProps {
onChange: FormChange;
isChecked: boolean;
hasError: boolean;
+ disabled?: boolean;
}
export const AllowUnpaidOrders = ({
onChange,
isChecked,
hasError,
+ disabled,
}: AllowUnpaidOrdersProps) => (
onChange({ target: { name: "allowUnpaidOrders", value } })
}
+ disabled={disabled}
>
diff --git a/src/channels/components/ChannelForm/ChannelForm.tsx b/src/channels/components/ChannelForm/ChannelForm.tsx
index efa4abdaf63..bc1a1d9fe41 100644
--- a/src/channels/components/ChannelForm/ChannelForm.tsx
+++ b/src/channels/components/ChannelForm/ChannelForm.tsx
@@ -210,17 +210,19 @@ export const ChannelForm: React.FC = ({
/>
= ({
TransactionFlowStrategyEnum.AUTHORIZATION
}
hasError={!!formErrors.defaultTransactionFlowStrategy}
+ disabled={disabled}
/>
>
diff --git a/src/channels/components/ChannelForm/DefaultTransactionFlowStrategy.tsx b/src/channels/components/ChannelForm/DefaultTransactionFlowStrategy.tsx
index 5be30fbd996..c20318f1a78 100644
--- a/src/channels/components/ChannelForm/DefaultTransactionFlowStrategy.tsx
+++ b/src/channels/components/ChannelForm/DefaultTransactionFlowStrategy.tsx
@@ -11,12 +11,14 @@ interface AllowUnpaidOrdersProps {
onChange: FormChange;
isChecked: boolean;
hasError: boolean;
+ disabled?: boolean;
}
export const DefaultTransactionFlowStrategy = ({
onChange,
isChecked,
hasError,
+ disabled,
}: AllowUnpaidOrdersProps) => (
onChange({ target: { name: "defaultTransactionFlowStrategy", value } })
}
+ disabled={disabled}
>
diff --git a/src/channels/components/ChannelForm/MarkAsPaid.tsx b/src/channels/components/ChannelForm/MarkAsPaid.tsx
index 8c6175747f3..4e2ca23330d 100644
--- a/src/channels/components/ChannelForm/MarkAsPaid.tsx
+++ b/src/channels/components/ChannelForm/MarkAsPaid.tsx
@@ -7,21 +7,24 @@ import { FormattedMessage } from "react-intl";
import { messages } from "./messages";
interface MarkAsPaidProps {
- isDiabled: boolean;
+ hasError: boolean;
isChecked: boolean;
onCheckedChange: () => void;
+ disabled?: boolean;
}
export const MarkAsPaid = ({
- isDiabled,
+ hasError,
isChecked,
onCheckedChange,
+ disabled,
}: MarkAsPaidProps) => (
diff --git a/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx b/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx
index bd2a6563746..2b95827e0df 100644
--- a/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx
+++ b/src/channels/pages/ChannelDetailsPage/ChannelDetailsPage.tsx
@@ -208,9 +208,15 @@ const ChannelDetailsPage = function ({
);
const reorderWarehouse = createWarehouseReorderHandler(data, set);
const handleMarkAsPaidStrategyChange = () => {
+ if (!data.markAsPaidStrategy) {
+ set({
+ markAsPaidStrategy: MarkAsPaidStrategyEnum.TRANSACTION_FLOW,
+ });
+ return;
+ }
+
set({
markAsPaidStrategy:
- // Swap enum values
data.markAsPaidStrategy === MarkAsPaidStrategyEnum.PAYMENT_FLOW
? MarkAsPaidStrategyEnum.TRANSACTION_FLOW
: MarkAsPaidStrategyEnum.PAYMENT_FLOW,
@@ -218,6 +224,14 @@ const ChannelDetailsPage = function ({
};
const handleTransactionFlowStrategyChange = () => {
+ if (!data.defaultTransactionFlowStrategy) {
+ set({
+ defaultTransactionFlowStrategy:
+ TransactionFlowStrategyEnum.AUTHORIZATION,
+ });
+ return;
+ }
+
set({
defaultTransactionFlowStrategy:
data.defaultTransactionFlowStrategy ===
diff --git a/src/channels/views/ChannelCreate/ChannelCreate.tsx b/src/channels/views/ChannelCreate/ChannelCreate.tsx
index 30be6529b25..2f157f59e15 100644
--- a/src/channels/views/ChannelCreate/ChannelCreate.tsx
+++ b/src/channels/views/ChannelCreate/ChannelCreate.tsx
@@ -66,28 +66,32 @@ export const ChannelCreateView = () => {
});
const handleSubmit = async ({
- shippingZonesIdsToAdd,
- warehousesIdsToAdd,
- warehousesToDisplay,
- currencyCode,
allocationStrategy,
- name,
- slug,
+ allowUnpaidOrders,
+ currencyCode,
defaultCountry,
- markAsPaidStrategy,
+ defaultTransactionFlowStrategy,
deleteExpiredOrdersAfter,
- allowUnpaidOrders,
+ markAsPaidStrategy,
+ name,
+ shippingZonesIdsToAdd,
+ slug,
+ warehousesIdsToAdd,
+ warehousesToDisplay,
}: FormData) => {
const input: ChannelCreateInput = {
- defaultCountry,
name,
slug,
+ defaultCountry,
currencyCode: currencyCode.toUpperCase(),
addShippingZones: shippingZonesIdsToAdd,
addWarehouses: warehousesIdsToAdd,
stockSettings: {
allocationStrategy,
},
+ paymentSettings: {
+ defaultTransactionFlowStrategy,
+ },
orderSettings: {
markAsPaidStrategy,
deleteExpiredOrdersAfter,
diff --git a/src/channels/views/ChannelDetails/ChannelDetails.tsx b/src/channels/views/ChannelDetails/ChannelDetails.tsx
index f31775e4132..f8fb8fc3ee4 100644
--- a/src/channels/views/ChannelDetails/ChannelDetails.tsx
+++ b/src/channels/views/ChannelDetails/ChannelDetails.tsx
@@ -106,19 +106,19 @@ export const ChannelDetails: React.FC = ({
});
const handleSubmit = async ({
+ allocationStrategy,
+ allowUnpaidOrders,
+ defaultCountry,
+ defaultTransactionFlowStrategy,
+ deleteExpiredOrdersAfter,
+ markAsPaidStrategy,
name,
- slug,
- shippingZonesIdsToRemove,
shippingZonesIdsToAdd,
- warehousesIdsToRemove,
+ shippingZonesIdsToRemove,
+ slug,
warehousesIdsToAdd,
+ warehousesIdsToRemove,
warehousesToDisplay,
- defaultCountry,
- allocationStrategy,
- markAsPaidStrategy,
- deleteExpiredOrdersAfter,
- allowUnpaidOrders,
- defaultTransactionFlowStrategy,
}: FormData) => {
const updateChannelMutation = updateChannel({
variables: {