[GH-ISSUE #766] Improve rendering logic for buttons in NotFound Page #226

Closed
opened 2026-02-26 18:46:00 +03:00 by kerem · 2 comments
Owner

Originally created by @plxity on GitHub (Dec 16, 2023).
Original GitHub issue: https://github.com/documenso/documenso/issues/766

Improvement Description

Currently, we are checking sessions multiple times to see which component to render. We can leverage the ternary operator to do that. It would make the code cleaner

Current Implementation

      {session && (
        <Button className="w-32" asChild>
          <Link href="/documents">Documents</Link>
        </Button>
      )}

      {!session && (
        <Button className="w-32" asChild>
          <Link href="/signin">Sign In</Link>
        </Button>
      )}

Rationale

This improvement will make the code cleaner

Proposed Solution

Using a ternary operator to render the button based on the conditions.

Proposed Solution

      {session ? (
        <Button className="w-32" asChild>
          <Link href="/documents">Documents</Link>
        </Button>
      ) : (
        <Button className="w-32" asChild>
          <Link href="/signin">Sign In</Link>
        </Button>
      )}

Alternatives (optional)

No response

Additional Context

No response

Please check the boxes that apply to this improvement suggestion.

  • I have searched the existing issues and improvement suggestions to avoid duplication.
  • I have provided a clear description of the improvement being suggested.
  • I have explained the rationale behind this improvement.
  • I have included any relevant technical details or design suggestions.
  • I understand that this is a suggestion and that there is no guarantee of implementation.
Originally created by @plxity on GitHub (Dec 16, 2023). Original GitHub issue: https://github.com/documenso/documenso/issues/766 ### Improvement Description Currently, we are checking `sessions` multiple times to see which component to render. We can leverage the ternary operator to do that. It would make the code cleaner Current Implementation ```js {session && ( <Button className="w-32" asChild> <Link href="/documents">Documents</Link> </Button> )} {!session && ( <Button className="w-32" asChild> <Link href="/signin">Sign In</Link> </Button> )} ``` ### Rationale This improvement will make the code cleaner ### Proposed Solution Using a ternary operator to render the button based on the conditions. Proposed Solution ```js {session ? ( <Button className="w-32" asChild> <Link href="/documents">Documents</Link> </Button> ) : ( <Button className="w-32" asChild> <Link href="/signin">Sign In</Link> </Button> )} ``` ### Alternatives (optional) _No response_ ### Additional Context _No response_ ### Please check the boxes that apply to this improvement suggestion. - [X] I have searched the existing issues and improvement suggestions to avoid duplication. - [X] I have provided a clear description of the improvement being suggested. - [X] I have explained the rationale behind this improvement. - [X] I have included any relevant technical details or design suggestions. - [X] I understand that this is a suggestion and that there is no guarantee of implementation.
kerem 2026-02-26 18:46:00 +03:00
Author
Owner

@catalinpit commented on GitHub (Dec 18, 2023):

Hey @plxity, thanks for opening the issue and for the PR! Mostly, we try to stay away from the conditional ternary operator, since it can make the code harder to read & understand. As a result, we won't move forward with this PR. Thanks for understanding! 🙏

<!-- gh-comment-id:1859865827 --> @catalinpit commented on GitHub (Dec 18, 2023): Hey @plxity, thanks for opening the issue and for the PR! Mostly, we try to stay away from the conditional ternary operator, since it can make the code harder to read & understand. As a result, we won't move forward with this PR. Thanks for understanding! 🙏
Author
Owner

@plxity commented on GitHub (Dec 18, 2023):

@catalinpit : Okay sure, but I believe ternary operators are way more readable than the approach already used. It becomes complex if it's nested, otherwise it's actually a clearer way to implement conditional rendering.

<!-- gh-comment-id:1860473024 --> @plxity commented on GitHub (Dec 18, 2023): @catalinpit : Okay sure, but I believe ternary operators are way more readable than the approach already used. It becomes complex if it's nested, otherwise it's actually a clearer way to implement conditional rendering.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#226
No description provided.