-
Notifications
You must be signed in to change notification settings - Fork 46
Patch of Navigation and Dependent Fields Changes #3246
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
base: master
Are you sure you want to change the base?
Changes from all commits
ce1e7a5
85641f3
843271a
fad6773
5e0a345
ddfe94c
856733b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -66,16 +66,6 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const [localeModule, setLocaleModule] = useState(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const [changeLoader, setChangeLoader] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (currentStep === parentState?.currentTemplate?.length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const event = new CustomEvent("lastButtonDisabled", { detail: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
window.dispatchEvent(event); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const event = new CustomEvent("lastButtonDisabled", { detail: false }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
window.dispatchEvent(event); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [currentStep, parentState]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const handleResetStep = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -100,7 +90,7 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { isLoading: isLoadingAppConfigMdmsData, data: AppConfigMdmsData } = Digit.Hooks.useCustomMDMS( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Digit.ULBService.getCurrentTenantId(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MODULE_CONSTANTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[{ name: fieldTypeMaster, limit: 100 }], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[{ name: fieldTypeMaster, limit: 1000 }], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cacheTime: Infinity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
staleTime: Infinity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -136,7 +126,7 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { isLoading: isCacheLoading, data: cacheData, refetch: refetchCache, revalidate } = Digit.Hooks.useCustomAPIHook(reqCriteriaForm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { isLoading: isCacheLoading, data: cacheData, refetch: refetchCache } = Digit.Hooks.useCustomAPIHook(reqCriteriaForm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { mutate: updateMutate } = Digit.Hooks.campaign.useUpdateAppConfig(tenantId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -167,6 +157,7 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
formId && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AppConfigMdmsData?.[fieldTypeMaster]?.length > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const fieldTypeMasterData = AppConfigMdmsData?.[fieldTypeMaster] || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const temp = restructure(formData?.data?.pages, fieldTypeMasterData, formData?.data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parentDispatch({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -187,19 +178,86 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [parentState?.currentTemplate]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const currentTabPages = React.useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const activeParent = numberTabs.find((j) => j.active)?.parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (parentState?.currentTemplate || []) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.filter((i) => i.parent === activeParent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.sort((a, b) => Number(a.order) - Number(b.order)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [parentState?.currentTemplate, numberTabs]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const last = currentTabPages.length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
? Number(currentTabPages[currentTabPages.length - 1].order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
: null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const isLast = last != null && Math.abs(Number(currentStep) - last) < 1e-6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
window.dispatchEvent(new CustomEvent("lastButtonDisabled", { detail: isLast })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [currentStep, currentTabPages]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+188
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Global event dispatch is fine; ensure consumers tolerate rapid changes. No blocker. Document the event name in a constants file to prevent drift across modules. 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Build the ordered list of valid steps once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 👉 Replace p.step / p.order / p.name with whatever your source-of-truth field is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const availableSteps = React.useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const raw = (parentState?.steps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| parentState?.stepOrder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| (parentState?.currentTemplate || []).map((p) => p?.step || p?.order || p?.name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return (raw || []) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.map((x) => parseFloat(String(x))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.filter((n) => Number.isFinite(n)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.sort((a, b) => a - b); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [parentState]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+199
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. availableSteps is built from ALL pages, but navigation/stepper are tab‑scoped → cross‑tab drift. This can advance currentStep to a page in a different tab without switching the tab, yielding blank content. Build availableSteps from currentTabPages instead. - const availableSteps = React.useMemo(() => {
- const raw = (parentState?.steps
- || parentState?.stepOrder
- || (parentState?.currentTemplate || []).map((p) => p?.step || p?.order || p?.name)
- );
- return (raw || [])
- .map((x) => parseFloat(String(x)))
- .filter((n) => Number.isFinite(n))
- .sort((a, b) => a - b);
- }, [parentState]);
+ const availableSteps = React.useMemo(() => {
+ return (currentTabPages || [])
+ .map((p) => parseFloat(String(p?.step ?? p?.order ?? p?.name)))
+ .filter((n) => Number.isFinite(n))
+ .sort((a, b) => a - b);
+ }, [currentTabPages]); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const round1 = (n) => Number(n.toFixed(1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const nextStepFrom = (current) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const cur = Number(current); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Prefer the next known step from the canonical list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (availableSteps.length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const next = availableSteps.find((s) => s > cur + 1e-9); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (next != null) return round1(next); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Fallbacks if no canonical "next" exists: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// - if we're on an integer, try the nearest .1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// - otherwise jump to next integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const frac10 = Math.round((cur - Math.floor(cur)) * 10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (frac10 === 0) return round1(cur + 0.1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return Math.floor(cur) + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+213
to
+231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Decimal stepping fallback assumes 1‑decimal granularity. Confirm policy. If orders like 4.10/4.11 exist, rounding to 1 decimal alters semantics. Consider removing the decimal fallback once availableSteps is correctly tab‑scoped (it should always be non‑empty). - const round1 = (n) => Number(n.toFixed(1));
+ const round1 = (n) => n; // not used if availableSteps is always populated If decimals >1 digit are possible, keep exact numbers and skip rounding. 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const prevStepFrom = (current) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const cur = Number(current); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let prev = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for (const s of availableSteps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (s < cur - 1e-9) prev = s; else break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return prev != null ? round1(prev) : cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setStepper( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(parentState?.currentTemplate || []) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?.filter((i) => i.parent === numberTabs.find((j) => j.active)?.parent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.sort((a, b) => a.order - b.order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?.map((k, j, t) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: k.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isLast: j === t.length - 1 ? true : false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isFirst: j === 0 ? true : false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
active: j === currentStep - 1 ? true : false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
currentTabPages.map((k, j, t) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: k.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isLast: j === t.length - 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
isFirst: j === 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// active by exact order match (works for 4.1, 4.2, …) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
active: Number(k.order) === Number(currentStep), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [parentState?.currentTemplate, numberTabs, currentStep]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [currentTabPages, currentStep]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const mainPagesCount = React.useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const ints = new Set(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for (const p of currentTabPages) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const n = parseFloat(String(p?.order || p?.step || p?.name)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (Number.isFinite(n)) ints.add(Math.floor(n)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ints.size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [currentTabPages]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (variant === "app" && parentState?.currentTemplate?.length > 0 && currentStep && numberTabs?.length > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -210,11 +268,13 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [parentState?.currentTemplate, currentStep, numberTabs]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (isCacheLoading || isLoadingAppConfigMdmsData || !parentState?.currentTemplate || parentState?.currentTemplate?.length === 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return <Loader page={true} variant={"PageLoader"} />; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const submit = async (screenData, finalSubmit, tabChange) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parentDispatch({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
key: "SETBACK", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data: screenData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -233,15 +293,15 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const reverseFormat = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cacheData && cacheData?.filteredCache?.data?.data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
? { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+296
to
+304
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chainPossible shape mismatch when spreading actualTemplate.actualTemplate. parentState.actualTemplate is set from - ...parentState?.actualTemplate?.actualTemplate,
+ ...(parentState?.actualTemplate?.actualTemplate || parentState?.actualTemplate),
version: parentState?.actualTemplate?.version + 1,
pages: reverseData, Please confirm the intended shape for masterName updates. 🏁 Script executed: #!/bin/bash
# Search for occurrences of actualTemplate in the target file
rg -n "actualTemplate" -C3 -- health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationRedesign/AppConfigurationParentLayer.js
# Search for definition/declaration of parentState in the same file
rg -n "parentState" -C3 -- health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/appConfigurationRedesign/AppConfigurationParentLayer.js Length of output: 9878 Guard against undefined nested actualTemplate when spreading - ...parentState?.actualTemplate?.actualTemplate,
+ ...(parentState?.actualTemplate?.actualTemplate || parentState?.actualTemplate),
version: parentState.actualTemplate.version + 1,
pages: reverseData, Confirm the intended structure for
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const updatedFormData = { ...formData, data: reverseFormat }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -340,15 +400,15 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const reverseFormat = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cacheData && cacheData?.filteredCache?.data?.data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
? { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...parentState?.actualTemplate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: parentState?.actualTemplate?.version + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pages: reverseData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+403
to
+411
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chainRepeat of shape concern for tabChange path. Mirror the safe spread to keep structures consistent. - ...parentState?.actualTemplate?.actualTemplate,
+ ...(parentState?.actualTemplate?.actualTemplate || parentState?.actualTemplate),
version: parentState?.actualTemplate?.version + 1,
pages: reverseData, 🏁 Script executed: #!/bin/bash
set -e
# Locate the file
file=$(fd -g 'AppConfigurationParentLayer.js' -t f)
echo "Found file: $file"
# Print lines 380–420 for context
echo "---- snippet lines 380–420 ----"
sed -n '380,420p' "$file"
# Find all occurrences of actualTemplate to understand its usage
echo "---- occurrences of actualTemplate ----"
rg -n -C3 "actualTemplate" "$file" Length of output: 5030 🏁 Script executed: #!/bin/bash
set -e
file=$(fd -g 'AppConfigurationParentLayer.js' -t f)
echo "---- useReducer declaration/context ----"
rg -n -C3 "useReducer" "$file"
echo "---- cacheData usages ----"
rg -n -C3 "cacheData" "$file" Length of output: 4964 🏁 Script executed: #!/bin/bash
set -e
file=$(fd -g 'AppConfigurationParentLayer.js' -t f)
echo "---- dispatcher definition ----"
rg -n -C5 "function dispatcher" "$file" || rg -n -C5 "const dispatcher" "$file" Length of output: 464 Fallback to outer actualTemplate when nested one is missing ...parentState?.actualTemplate?.actualTemplate, with ...(parentState?.actualTemplate?.actualTemplate || parentState?.actualTemplate), to ensure metadata isn’t dropped when 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const updatedFormData = { ...formData, data: reverseFormat }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -392,7 +452,6 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setShowToast({ key: "success", label: "APP_CONFIGURATION_SUCCESS" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setChangeLoader(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
revalidateForm(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
revalidate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -426,21 +485,22 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep((prev) => prev + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep((prev) => nextStepFrom(prev)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const back = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (stepper?.find((i) => i.active)?.isFirst && isPreviousTabAvailable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tabStateDispatch({ key: "PREVIOUS_TAB" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else if (stepper?.find((i) => i.active)?.isFirst && !isPreviousTabAvailable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setShowToast({ key: "error", label: "CANNOT_GO_BACK" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep((prev) => prev - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const activeStep = stepper?.find((i) => i.active); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (activeStep?.isFirst && isPreviousTabAvailable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tabStateDispatch({ key: "PREVIOUS_TAB" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep(availableSteps[0] || 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else if (activeStep?.isFirst && !isPreviousTabAvailable) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setShowToast({ key: "error", label: "CANNOT_GO_BACK" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setCurrentStep((prev) => prevStepFrom(prev)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+493
to
+503
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Back navigation jumps to the global first step, not previous tab’s first page. Compute the previous tab’s first step and navigate there. - if (activeStep?.isFirst && isPreviousTabAvailable) {
- tabStateDispatch({ key: "PREVIOUS_TAB" });
- setCurrentStep(availableSteps[0] || 1);
- return;
- } else if (activeStep?.isFirst && !isPreviousTabAvailable) {
+ if (activeStep?.isFirst && isPreviousTabAvailable) {
+ const activeIdx = numberTabs.findIndex((t) => t.active);
+ const prevParent = numberTabs[activeIdx - 1]?.parent;
+ const prevTabPages = (parentState?.currentTemplate || [])
+ .filter((p) => p?.parent === prevParent)
+ .sort((a, b) => Number(a.order) - Number(b.order));
+ tabStateDispatch({ key: "PREVIOUS_TAB" });
+ setCurrentStep(Number(prevTabPages?.[0]?.order) || 1);
+ return;
+ } else if (activeStep?.isFirst && !isPreviousTabAvailable) {
setShowToast({ key: "error", label: "CANNOT_GO_BACK" });
} else {
setCurrentStep((prev) => prevStepFrom(prev));
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (changeLoader) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return <Loader className="loader-center" page={true} variant={"Overlayloader"} loaderText={t("HCM_CHANGING_MODULE")} />; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -479,7 +539,8 @@ const AppConfigurationParentRedesign = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parentDispatch={parentDispatch} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AppConfigMdmsData={AppConfigMdmsData} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
localeModule={localeModule} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pageTag={`${t("CMN_PAGE")} ${currentStep} / ${stepper?.length}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parentState={parentState} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pageTag={`${t("CMN_PAGE")} ${currentStep} / ${mainPagesCount}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -280,14 +280,39 @@ const reducer = (state = initialState, action, updateLocalization) => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
case "PATCH_PAGE_CONDITIONAL_NAV": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { pageName, data } = action; // data is the array from onConditionalNavigateChange | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const patchArray = (arr) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!Array.isArray(arr) || arr.length === 0) return arr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// If pageName is provided, try to patch by name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pageName) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const idx = arr.findIndex((p) => p?.name === pageName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (idx !== -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return arr.map((p, i) => (i === idx ? { ...p, conditionalNavigateTo: data } : p)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Fallback: patch the first page (your “current page is first” invariant) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return arr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...state, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
screenConfig: patchArray(state.screenConfig), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
screenData: patchArray(state.screenData), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+283
to
+306
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fallback logic doesn't match the comment. The
If
- // Fallback: patch the first page (your "current page is first" invariant)
- return arr;
+ // Fallback: patch the first page if no pageName provided
+ return arr.map((p, i) => (i === 0 ? { ...p, conditionalNavigateTo: data } : p)); Additionally, consider validating that 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return state; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const MODULE_CONSTANTS = "HCM-ADMIN-CONSOLE"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
function AppConfigurationWrapper({ screenConfig, localeModule, pageTag }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
function AppConfigurationWrapper({ screenConfig, localeModule, pageTag , parentState}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const useT = useCustomT(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const queryClient = useQueryClient(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { locState, addMissingKey, updateLocalization, onSubmit, back, showBack, parentDispatch } = useAppLocalisationContext(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const [state, dispatch] = useReducer((state, action) => reducer(state, action, updateLocalization), initialState); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -298,7 +323,7 @@ function AppConfigurationWrapper({ screenConfig, localeModule, pageTag }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const [popupData, setPopupData] = useState(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const [addFieldData, setAddFieldData] = useState(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const addFieldDataLabel = useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return addFieldData?.label ? useCustomT(addFieldData?.label) : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return addFieldData?.label ? useT(addFieldData?.label) : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [addFieldData]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const searchParams = new URLSearchParams(location.search); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const fieldMasterName = searchParams.get("fieldType"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -554,7 +579,7 @@ function AppConfigurationWrapper({ screenConfig, localeModule, pageTag }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<AppConfigContext.Provider value={{ state, dispatch, openAddFieldPopup }}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{loading && <Loader page={true} variant={"OverlayLoader"} loaderText={t("SAVING_CONFIG_IN_SERVER")} />} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<AppPreview data={state?.screenData?.[0]} selectedField={state?.drawerField} t={useCustomT} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<AppPreview data={state?.screenData?.[0]} selectedField={state?.drawerField} t={useT} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div className="appConfig-flex-action"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
className="app-configure-action-button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -637,7 +662,7 @@ function AppConfigurationWrapper({ screenConfig, localeModule, pageTag }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<DndProvider backend={HTML5Backend}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<AppFieldScreenWrapper /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<AppFieldScreenWrapper parentState={parentState}/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</DndProvider> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</SidePanel> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -727,7 +752,7 @@ function AppConfigurationWrapper({ screenConfig, localeModule, pageTag }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
required={true} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type={"text"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label={`${t("ADD_FIELD_LABEL")}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value={addFieldData?.label ? useCustomT(addFieldData?.label) : ""} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value={addFieldData?.label ? useT(addFieldData?.label) : ""} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config={{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
step: "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
currentTabPages derivation: safe, but add a fallback active parent to avoid empty lists.
If no tab is marked active, fall back to the first parent to stabilize UI on initial renders.
📝 Committable suggestion
🤖 Prompt for AI Agents