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

HCMPRE 154 #1186

Merged
merged 4 commits into from
Jul 30, 2024
Merged

HCMPRE 154 #1186

merged 4 commits into from
Jul 30, 2024

Conversation

nabeelmd-eGov
Copy link
Contributor

  • date validation fix
  • Update date logic

Copy link
Contributor

coderabbitai bot commented Jul 30, 2024

Warning

Rate limit exceeded

@nabeelmd-eGov has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 49 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 2d94404 and 571b8e7.

Walkthrough

Walkthrough

The recent updates enhance the micro UI framework by improving date validation and handling logic, alongside version upgrades for the CSS library. Key modifications include the introduction of a new validation helper function for date entries, refined error handling, and adjustments to the date processing to ensure better compatibility. These changes aim to elevate the reliability and user experience of date-related features within the application.

Changes

File Change Summary
.../index.html Updated @egovernments/digit-ui-css version from 1.8.2-beta.6 to 1.8.2-beta.7 and 1.8.2-beta.9 in different locations.
.../UpdateDatesWithBoundaries.js Introduced checkValid function for date validation, restructured onSubmit with error handling based on DateWithBoundary.
.../BoundaryWithDate.js Enhanced date handling with checks for undefined values and simplified validation logic.
.../DateWithBoundary.js Fixed case label typo from "CYCYLE_END_DATE" to "CYCLE_END_DATE" in the switch statement.
.../DateAndCycleUpdate.js Improved date conversion, error handling, and validation logic; corrected cycle end date case.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Form
    participant DateValidation
    participant Backend

    User->>Form: Submit Date
    Form->>DateValidation: Validate Dates
    DateValidation-->>Form: Validation Result
    alt Valid
        Form->>Backend: Send Data
        Backend-->>Form: Response
    else Invalid
        Form-->>User: Show Error Message
    end
Loading

🐰 In fields of code, I hop and play,
With dates and logic, I find my way.
A sprinkle of checks, a dash of care,
Making sure dates are right, oh so rare!
With each small change, the flow is bright,
Hopping along, everything feels just right! 🌼


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 Configuration 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.

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: 9

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c69f8b4 and 2d94404.

Files ignored due to path filters (3)
  • micro-ui/web/micro-ui-internals/example/package.json is excluded by !**/*.json
  • micro-ui/web/package.json is excluded by !**/*.json
  • micro-ui/web/workbench/package.json is excluded by !**/*.json
Files selected for processing (7)
  • micro-ui/web/micro-ui-internals/example/public/index.html (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/BoundaryWithDate.js (7 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/DateWithBoundary.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/DateAndCycleUpdate.js (9 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateDatesWithBoundaries.js (2 hunks)
  • micro-ui/web/public/index.html (1 hunks)
Files skipped from review due to trivial changes (2)
  • micro-ui/web/micro-ui-internals/example/public/index.html
  • micro-ui/web/public/index.html
Additional context used
Path-based instructions (4)
micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateDatesWithBoundaries.js (1)

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

Pattern **/*.js: check

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

[error] 150-150: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)


[error] 176-176: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

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

[error] 198-198: 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] 220-220: 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] 253-253: 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] 281-281: 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] 258-258: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)


[error] 285-285: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

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

31-33: LGTM!

The added check for undefined date values improves robustness.


50-52: LGTM!

The added check for undefined date values improves robustness.


63-63: LGTM!

The correction in the type dispatched for the cycle end date ensures proper state management.

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

65-65: LGTM!

The correction in the case label from "CYCYLE_END_DATE" to "CYCLE_END_DATE" ensures proper action recognition and processing.

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

33-33: Ensure type safety for date conversion.

The updated logic ensures that only valid date strings are processed. This enhances robustness against unexpected data types.


49-49: Corrected typo in action type.

The typo in the case label has been corrected from "CYCYLE_END_DATE" to "CYCLE_END_DATE", ensuring the correct action type is processed.


119-128: Prevent potential errors with conditional date setting.

The checks for the existence of startDate and endDate prevent potential errors when rendering components that depend on these values.


144-144: Clarify intent with undefined check.

The check for undefined dates clarifies the intent and ensures correct handling of cases where the date might be explicitly set to null or undefined.


163-163: Clarify intent with undefined check.

The check for undefined dates clarifies the intent and ensures correct handling of cases where the date might be explicitly set to null or undefined.

micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/index.scss (1)

553-555: Enhance responsiveness with width: unset.

The new CSS rule allows the element to inherit its width from its parent container, enhancing responsiveness.

Comment on lines +35 to +54
const checkValid = (data) => {
if (DateWithBoundary) {
const temp = data?.dateWithBoundary;
const allCycleDateValid = temp
.map((i) => i.additionalDetails.projectType.cycles.every((j) => j.startDate && j.endDate))
.every((k) => k === true);
const allDateValid = temp.every((i) => i.startDate && i.endDate);

if (allCycleDateValid && allDateValid) {
return true;
}
return false;
} else if (!DateWithBoundary) {
const cycleDateValid = data?.dateAndCycle?.additionalDetails?.projectType?.cycles?.every((item) => item?.startDate && item?.endDate);
if (data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate && cycleDateValid) {
return true;
}
return false;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the checkValid function.

The function can be simplified by reducing redundancy and improving readability.

const checkValid = (data) => {
  if (DateWithBoundary) {
    const temp = data?.dateWithBoundary;
    return temp.every((i) => i.startDate && i.endDate && i.additionalDetails.projectType.cycles.every((j) => j.startDate && j.endDate));
  } else {
    const cycleDateValid = data?.dateAndCycle?.additionalDetails?.projectType?.cycles?.every((item) => item?.startDate && item?.endDate);
    return data?.dateAndCycle?.startDate && data?.dateAndCycle?.endDate && cycleDateValid;
  }
};

Comment on lines 56 to 69
if (DateWithBoundary) {
if (!formData?.dateWithBoundary || !Array.isArray(formData?.dateWithBoundary) || formData?.dateWithBoundary?.length === 0) {
setShowToast({ isError: true, label: "SELECT_BOUNDARY_LEVEL_ERROR" });
return;
}
} else if (!DateWithBoundary) {
if (!formData?.dateAndCycle) {
setShowToast({ isError: true, label: "SELECT_DATE_CHANGE_MANDATORY_ERROR" });
return;
}
}
let isValid = checkValid(formData);
if (!isValid) {
setShowToast({ isError: true, label: "MANDATORY_FIELDS_MISSING" });
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability and optimize early returns in onSubmit.

The function can be improved by restructuring the conditional checks and optimizing early returns.

const onSubmit = async (formData) => {
  if (DateWithBoundary) {
    if (!formData?.dateWithBoundary || !Array.isArray(formData?.dateWithBoundary) || formData?.dateWithBoundary?.length === 0) {
      setShowToast({ isError: true, label: "SELECT_BOUNDARY_LEVEL_ERROR" });
      return;
    }
  } else {
    if (!formData?.dateAndCycle) {
      setShowToast({ isError: true, label: "SELECT_DATE_CHANGE_MANDATORY_ERROR" });
      return;
    }
  }

  const isValid = checkValid(formData);
  if (!isValid) {
    setShowToast({ isError: true, label: "MANDATORY_FIELDS_MISSING" });
    return;
  }

  setShowPopUp(formData);
};

Comment on lines +79 to +95
// updating the endDate by +1 sec and -1 sec so that backend logic for ancestor update work
const payload = formData?.dateWithBoundary?.map((item) => {
let itemEndDate = item?.endDate;
let endDate = new Date(item?.endDate);
let endSecond = endDate?.getSeconds();
if (endSecond < 59) {
return {
...item,
endDate: itemEndDate + 1000,
};
} else {
return {
...item,
endDate: itemEndDate - 1000,
};
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhance readability and consistency in onConfirm.

The function can be improved by restructuring the conditional checks and ensuring consistent date handling.

const onConfirm = async (formData) => {
  setShowPopUp(null);
  try {
    if (DateWithBoundary) {
      const payload = formData?.dateWithBoundary?.map((item) => {
        const endDate = new Date(item?.endDate);
        const endSecond = endDate?.getSeconds();
        return {
          ...item,
          endDate: endSecond < 59 ? item?.endDate + 1000 : item?.endDate - 1000,
        };
      });
      await Digit.Hooks.campaign.useProjectUpdateWithBoundary({ formData: payload });
      history.push(`/${window.contextPath}/employee/campaign/response?isSuccess=${true}`, {
        message: t("ES_CAMPAIGN_DATE_CHANGE_WITH_BOUNDARY_SUCCESS"),
        actionLabel: t("HCM_DATE_CHANGE_SUCCESS_RESPONSE_ACTION"),
        actionLink: `/${window.contextPath}/employee/campaign/my-campaign`,
      });
    } else {
      await Digit.CustomService.getResponse({
        url: "/health-project/v1/_update",
        body: { Projects: [formData?.dateAndCycle] },
      });
      history.push(`/${window.contextPath}/employee/campaign/response?isSuccess=${true}`, {
        message: t("ES_CAMPAIGN_DATE_CHANGE_SUCCESS"),
        actionLabel: t("HCM_DATE_CHANGE_SUCCESS_RESPONSE_ACTION"),
        actionLink: `/${window.contextPath}/employee/campaign/my-campaign`,
      });
    }
  } catch (error) {
    setShowToast({ isError: true, label: error?.response?.data?.Errors?.[0]?.message || error });
  }
};

withoutLabel={true}
type="date"
value={item?.startDate}
nonEditable={today >= item?.startDate ? true : false}
nonEditable={item?.startDate && item?.startDate?.length > 0 && today >= item?.startDate ? true : false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the nonEditable property check.

The use of boolean literals in the conditional expression is unnecessary. Simplify the code by directly assigning the result.

- nonEditable={item?.startDate && item?.startDate?.length > 0 && today >= item?.startDate ? true : false}
+ nonEditable={item?.startDate && item?.startDate?.length > 0 && today >= item?.startDate}
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
nonEditable={item?.startDate && item?.startDate?.length > 0 && today >= item?.startDate ? true : false}
nonEditable={item?.startDate && item?.startDate?.length > 0 && today >= item?.startDate}
Tools
Biome

[error] 253-253: 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)

populators={{
validation: {
min:
index > 0 && !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime())
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace isNaN with Number.isNaN.

The use of isNaN is unsafe as it attempts a type coercion. Use Number.isNaN instead.

- index > 0 && !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime())
+ index > 0 && !Number.isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime())
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
index > 0 && !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime())
index > 0 && !Number.isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index)?.endDate)?.getTime())
Tools
Biome

[error] 258-258: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

}
populators={{
validation: {
min: !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime())
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace isNaN with Number.isNaN.

The use of isNaN is unsafe as it attempts a type coercion. Use Number.isNaN instead.

- min: !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime())
+ min: !Number.isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime())
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
min: !isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime())
min: !Number.isNaN(new Date(cycleDates?.find((j) => j.cycleIndex == index + 1)?.startDate)?.getTime())
Tools
Biome

[error] 285-285: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

Comment on lines +194 to +198
required={true}
withoutLabel={true}
type="date"
value={startDate}
nonEditable={today >= startDate ? true : false}
nonEditable={startDate && startDate?.length > 0 && today >= startDate ? true : false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the nonEditable property check.

The use of boolean literals in the conditional expression is unnecessary. Simplify the code by directly assigning the result.

- nonEditable={startDate && startDate?.length > 0 && today >= startDate ? true : false}
+ nonEditable={startDate && startDate?.length > 0 && today >= startDate}
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
required={true}
withoutLabel={true}
type="date"
value={startDate}
nonEditable={today >= startDate ? true : false}
nonEditable={startDate && startDate?.length > 0 && today >= startDate ? true : false}
required={true}
withoutLabel={true}
type="date"
value={startDate}
nonEditable={startDate && startDate?.length > 0 && today >= startDate}
Tools
Biome

[error] 198-198: 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)

withoutLabel={true}
type="date"
value={endDate}
nonEditable={today >= endDate ? true : false}
nonEditable={endDate && endDate?.length > 0 && today >= endDate ? true : false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the nonEditable property check.

The use of boolean literals in the conditional expression is unnecessary. Simplify the code by directly assigning the result.

- nonEditable={endDate && endDate?.length > 0 && today >= endDate ? true : false}
+ nonEditable={endDate && endDate?.length > 0 && today >= endDate}
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
nonEditable={endDate && endDate?.length > 0 && today >= endDate ? true : false}
nonEditable={endDate && endDate?.length > 0 && today >= endDate}
Tools
Biome

[error] 220-220: 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)

withoutLabel={true}
type="date"
value={item?.endDate}
nonEditable={today >= item?.endDate ? true : false}
nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate ? true : false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the nonEditable property check.

The use of boolean literals in the conditional expression is unnecessary. Simplify the code by directly assigning the result.

- nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate ? true : false}
+ nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate}
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
nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate ? true : false}
nonEditable={item?.endDate && item?.endDate?.length > 0 && today >= item?.endDate}
Tools
Biome

[error] 281-281: 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)

@jagankumar-egov jagankumar-egov merged commit de09876 into campaign Jul 30, 2024
2 of 4 checks passed
@jagankumar-egov jagankumar-egov deleted the HCMPRE-154 branch July 30, 2024 09:39
Bhavya-egov pushed a commit that referenced this pull request Aug 12, 2024
* date validation fix

* Update date logic

* FIX

---------

Co-authored-by: nabeelmd-eGov <[email protected]>
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