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

HLM-6270: Elimated Generate API & enhance download API, Date logic fixes #966

Merged
merged 4 commits into from
Jun 27, 2024

Conversation

nabeelmd-eGov
Copy link
Contributor

  • refactor
  • added title text
  • HLM-6270: Elimated Generate API & enhance download API, Date logic fixes

Copy link
Contributor

coderabbitai bot commented Jun 27, 2024

Walkthrough

Walkthrough

The changes across the campaign-manager module primarily involve removing and commenting out code related to retrieving facility, boundary, and user IDs, simplifying the logic by updating the mutation.mutate call to include campaignId. Additionally, date handling was improved by replacing Date.now() with Digit.Utils.pt.convertDateToEpoch() for more precise date management.

Changes

Files Change Summary
UploadData.js Removed code fetching data with useGenerateIdCampaign hook and updated mutation.mutate.
UICustomizations.js Replaced Date.now() with Digit.Utils.pt.convertDateToEpoch() for setting dates.
SetupCampaign.js Commented out code related to state and hooks for fetching facility, boundary, and user IDs.

In code we trust, where changes flow,
Simplified paths, and dates to show.
Campaigns rise with clearer skies,
The hooks once tangled, now cut ties.
Through epochs’ dawn, we stride along,
With campaignId, our work is strong. 🌟


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nabeelmd-eGov nabeelmd-eGov changed the title HLM 6270 HLM-6270: Elimated Generate API & enhance download API, Date logic fixes Jun 27, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (5)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (5)

Line range hint 102-102: Performance improvement suggestion: Avoid using the delete operator.

Using the delete operator can lead to performance degradation due to its impact on object property optimizations. Consider setting the property to undefined or restructuring the code to avoid the need for deletion.

- delete newSchema.unique;
+ newSchema.unique = undefined;

Line range hint 169-169: Performance improvement suggestion: Avoid using the delete operator.

Similar to the previous comment, consider setting the property to undefined instead of deleting it.

- delete newData.campaignType;
+ newData.campaignType = undefined;

Line range hint 337-344: Redundant else clause can be omitted.

The else clause is unnecessary here as previous branches break early. This can help reduce the complexity of the code.

- else {
-   return true;
- }

Line range hint 610-619: Variable declaration improvement: Declare var at the function root.

To avoid confusion and potential errors due to JavaScript's variable hoisting, declare all var variables at the top of the function.

+ var jsonData, headersToValidate;
  const validateMultipleTargets = (workbook) => {
    let isValid = true;
    ...
-   var jsonData = XLSX.utils.sheet_to_json(sheet, { blankrows: true });
-   var headersToValidate = XLSX.utils.sheet_to_json(sheet, {
      header: 1,
    })[0];

Line range hint 1082-1082: Add missing key properties for elements in iterables.

React requires key properties for elements in lists to maintain state consistency across re-renders. Ensure each element in these iterables has a unique key prop.

- <React.Fragment key={type}>
+ <React.Fragment key={`info-${type}`}>
  {errorsType[type] && (
    <React.Fragment>
-     {errorsType[type].split(",").map((error, index) => (
+     {errorsType[type].split(",").map((error, index) => (
+       <React.Fragment key={`error-${index}`}>
        {index > 0 && <br />}
        {error.trim()}
+       </React.Fragment>
      ))}
    </React.Fragment>
  )}
</React.Fragment>

Also applies to: 1095-1095, 1104-1104

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d382481 and 39e8ab6.

Files selected for processing (3)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (3 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js (3 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (4 hunks)
Files not reviewed due to errors (2)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js (no review received)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (no review received)
Additional context used
Path-based instructions (3)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js (1)

Pattern **/*.js: check

Learnings (1)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (2)
User: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#803
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js:300-341
Timestamp: 2024-06-06T06:12:01.804Z
Learning: If the `boundaryDataGeneration` function in `Upload.js` fails, it indicates that there is no data for that campaign, and this is an acceptable outcome. Retrying the operation is unnecessary as it would yield the same result.
User: siddhant-nawale-egov
PR: egovernments/DIGIT-Frontend#845
File: micro-ui/web/micro-ui-internals/packages/modules/hcm-microplanning/src/components/Upload.js:460-461
Timestamp: 2024-06-12T08:18:44.708Z
Learning: Error handling for Shapefile parsing in `Upload.js` is managed commonly and is handled elsewhere in the codebase, as clarified by the user.
Biome
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js

[error] 41-41: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 42-42: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 43-43: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 76-78: This property value named getCustomActionLabel is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named getCustomActionLabel

(lint/suspicious/noDuplicateObjectKeys)


[error] 132-132: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 133-133: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 134-134: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 167-169: This property value named getCustomActionLabel is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named getCustomActionLabel

(lint/suspicious/noDuplicateObjectKeys)


[error] 224-224: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 225-225: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 226-226: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 259-261: This property value named getCustomActionLabel is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named getCustomActionLabel

(lint/suspicious/noDuplicateObjectKeys)


[error] 314-314: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 315-315: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 316-316: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 317-317: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 350-352: This property value named getCustomActionLabel is later overwritten by an object member with the same name.

Overwritten with this value.

If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named getCustomActionLabel

(lint/suspicious/noDuplicateObjectKeys)


[error] 405-405: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 406-406: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 407-407: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js

[error] 102-102: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 152-152: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 169-169: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 337-344: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 451-453: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 610-619: This var should be declared at the root of the enclosing function.

The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.

(lint/correctness/noInnerDeclarations)


[error] 761-761: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 809-844: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 815-843: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 853-881: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 962-962: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 1112-1112: The comma operator is disallowed.

Its use is often confusing and obscures side effects.

(lint/style/noCommaOperator)


[error] 1082-1082: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)


[error] 1083-1083: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 1095-1103: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 1104-1114: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SetupCampaign.js

[error] 304-304: Unnecessary use of boolean literals in conditional expression.

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

(lint/complexity/noUselessTernary)


[error] 366-366: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 367-367: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 582-784: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 759-759: Avoid the delete operator which can impact performance.

(lint/performance/noDelete)


[error] 760-760: Avoid the delete operator which can impact performance.

(lint/performance/noDelete)


[error] 790-790: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 932-932: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 933-933: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 934-934: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 935-935: Unsafe usage of optional chaining.

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

(lint/correctness/noUnsafeOptionalChaining)


[error] 949-951: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 1039-1045: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 1042-1045: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)


[error] 1050-1053: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 1055-1055: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 1056-1056: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 1060-1069: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 1063-1069: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)


[error] 1066-1069: This else clause can be omitted because previous branches break early.

(lint/style/noUselessElse)

Additional comments not posted (1)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js (1)

917-930: Updated mutation call to include campaignId:

The mutation call has been updated to include the campaignId. This change aligns with the PR's objectives of enhancing the download API. Ensure all dependent functionalities are updated to handle this new parameter.

@jagankumar-egov jagankumar-egov merged commit 9686aaf into campaign Jun 27, 2024
2 of 4 checks passed
@jagankumar-egov jagankumar-egov deleted the HLM-6270 branch June 27, 2024 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants