Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delivery type disable fix, product sku name change #939

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const deliveryConfig = [
conditionConfig: [
{
deliveryType: "DIRECT",
disableDeliveryType: true,
attributeConfig: [
{
key: 1,
Expand Down Expand Up @@ -78,6 +79,7 @@ export const deliveryConfig = [
],
},
{
disableDeliveryType: true,
deliveryType: "DIRECT",
attributeConfig: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function AddProduct() {
tenantId: tenantId,
productId: i?.id,
variation: target?.variant,
sku: target?.variant,
sku: `${target?.name} - ${target?.variant}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated SKU generation logic enhances product identification by including both name and variant. Consider adding null checks for target?.name and target?.variant to ensure robustness against potential undefined values.

- sku: `${target?.name} - ${target?.variant}`,
+ sku: `${target?.name || 'defaultName'} - ${target?.variant || 'defaultVariant'}`,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sku: `${target?.name} - ${target?.variant}`,
sku: `${target?.name || 'defaultName'} - ${target?.variant || 'defaultVariant'}`,

};
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,12 @@ const AddDeliveryRule = ({ targetedData, deliveryRules, setDeliveryRules, index,
optionsKey="code"
onSelect={(value) => updateDeliveryType(value)}
t={t}
disabled={
filteredDeliveryConfig?.deliveryConfig?.find((i, n) => n === targetedData?.deliveryIndex - 1)?.conditionConfig?.[delivery?.ruleKey - 1]
?.disableDeliveryType
? true
: false
}
Comment on lines +670 to +675
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional disabling of UI components based on delivery configuration is implemented correctly. Consider simplifying the ternary operation for clarity.

- disabled={
-   filteredDeliveryConfig?.deliveryConfig?.find((i, n) => n === targetedData?.deliveryIndex - 1)?.conditionConfig?.[delivery?.ruleKey - 1]
-     ?.disableDeliveryType
-     ? true
-     : false
- }
+ disabled={!!filteredDeliveryConfig?.deliveryConfig?.find((i, n) => n === targetedData?.deliveryIndex - 1)?.conditionConfig?.[delivery?.ruleKey - 1]?.disableDeliveryType}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
disabled={
filteredDeliveryConfig?.deliveryConfig?.find((i, n) => n === targetedData?.deliveryIndex - 1)?.conditionConfig?.[delivery?.ruleKey - 1]
?.disableDeliveryType
? true
: false
}
disabled={!!filteredDeliveryConfig?.deliveryConfig?.find((i, n) => n === targetedData?.deliveryIndex - 1)?.conditionConfig?.[delivery?.ruleKey - 1]?.disableDeliveryType}
Tools
Biome

[error] 671-674: Unnecessary use of boolean literals in conditional expression. (lint/complexity/noUselessTernary)

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

/>
</LabelFieldPair>
)}
Expand Down
Loading