-
Notifications
You must be signed in to change notification settings - Fork 20
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
changed template name #2032
changed template name #2032
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (1)Pattern Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🔭 Outside diff range comments (3)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (3)
Line range hint
432-486
: Enhance boundary validation error messages.The current validation logic for boundary data could be more specific about which validation failed. Consider aggregating similar errors and providing more context.
Apply this diff to improve error messages:
const validateMultipleTargets = (workbook) => { let isValid = true; const targetError = []; + const errorsByType = { + missing: [], + range: [], + type: [] + }; for (let i = 0; i < workbook.SheetNames.length; i++) { // ... existing validation logic ... if (value === undefined || value === null) { - targetError.push( + errorsByType.missing.push( `${t("HCM_DATA_AT_ROW")} ${jsonData.indexOf(row) + 2} ${t("HCM_IN_COLUMN")} "${headersToValidate[j]}" ${t( "HCM_DATA_SHOULD_NOT_BE_EMPTY" )} at ${sheetName}` ); } else if (value >= 100000000) { - targetError.push( + errorsByType.range.push( `${t("HCM_DATA_AT_ROW")} ${jsonData.indexOf(row) + 2} ${t("HCM_IN_COLUMN")} "${headersToValidate[j]}" ${t( "HCM_DATA_SHOULD_BE_LESS_THAN_MAXIMUM" )} at ${sheetName}` ); } // ... rest of the validation ... } + // Aggregate errors by type + if (errorsByType.missing.length > 0) { + targetError.push(t("HCM_MISSING_VALUES_HEADER")); + targetError.push(...errorsByType.missing); + } + if (errorsByType.range.length > 0) { + targetError.push(t("HCM_INVALID_RANGES_HEADER")); + targetError.push(...errorsByType.range); + }🧰 Tools
🪛 Biome (1.9.4)
[error] 1036-1036: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Line range hint
31-52
: Optimize state management using reducer pattern.The component manages multiple related states for errors, validation, and upload status. Consider using useReducer for better state management.
Example implementation:
const initialState = { uploadState: { isError: false, isSuccess: false, isValidation: false, apiError: null, }, downloadState: { downloadError: false, downloadedTemplates: { boundary: false, facilityWithBoundary: false, user: false, } }, errorsType: {}, }; const uploadReducer = (state, action) => { switch (action.type) { case 'SET_UPLOAD_ERROR': return { ...state, uploadState: { ...state.uploadState, isError: true, apiError: action.payload } }; case 'SET_UPLOAD_SUCCESS': return { ...state, uploadState: { ...state.uploadState, isSuccess: true, isError: false } }; // ... other cases } };🧰 Tools
🪛 Biome (1.9.4)
[error] 1036-1036: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Line range hint
1016-1042
: Enhance download progress feedback.The template download functionality could benefit from better visual feedback during the download process.
Apply this diff to add download progress indication:
const downloadTemplate = async () => { + const [downloadProgress, setDownloadProgress] = useState(false); + await mutation.mutate( { params: { tenantId: tenantId, type: type, hierarchyType: params?.hierarchyType, campaignId: id, }, }, { onSuccess: async (result) => { + setDownloadProgress(true); if (result?.GeneratedResource?.[0]?.status === "failed") { setDownloadError(true); setShowToast({ key: "error", label: t("ERROR_WHILE_DOWNLOADING") }); + setDownloadProgress(false); return; } // ... rest of the success handling + setDownloadProgress(false); }, onError: (error, result) => { // ... error handling + setDownloadProgress(false); }, } ); }; +// Add loading indicator in the UI +{downloadProgress && <LoaderWithGap text={"DOWNLOADING_TEMPLATE"} />}🧰 Tools
🪛 Biome (1.9.4)
[error] 1036-1036: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (1)
Pattern **/*.js
: check
Summary by CodeRabbit
New Features
Bug Fixes