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

✨ Add loading pages #978

Merged
merged 1 commit into from
Jan 13, 2024
Merged

✨ Add loading pages #978

merged 1 commit into from
Jan 13, 2024

Conversation

lukevella
Copy link
Owner

@lukevella lukevella commented Jan 13, 2024

Improve UX by adding loading pages

Summary by CodeRabbit

  • New Features

    • Implemented a new layout for the admin polls page with functionality to create new polls.
    • Added a loading skeleton for the polls list in the admin section.
    • Introduced an invite page for polls with user-specific features and navigation to poll management.
    • Created an alert component for guest users on poll pages, prompting account creation or login.
  • Enhancements

    • Enhanced user experience by adding loading states across various pages.
  • Refactor

    • Refactored the polls page to improve modularity and maintainability.
    • Streamlined the page layout by adjusting padding.
  • Bug Fixes

    • Fixed an issue with asynchronous loading of poll content.

Copy link

vercel bot commented Jan 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2024 11:42am
landing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2024 11:42am

Copy link
Contributor

coderabbitai bot commented Jan 13, 2024

Walkthrough

The web application has undergone a series of updates focused on improving user experience during loading times and enhancing the admin and invite interfaces. New components for loading states and alerts have been introduced, along with a refactoring that separates page logic, adds navigation, and streamlines user interactions with polls. The changes aim to make the app more intuitive and maintainable.

Changes

File Path Change Summary
.../[locale]/(admin)/polls/layout.tsx Added layout component for admin polls with header and new poll button.
.../[locale]/(admin)/polls/loading.tsx, .../[locale]/invite/[urlId]/loading.tsx, .../[locale]/poll/[urlId]/loading.tsx Introduced loading components with skeleton screens.
.../[locale]/(admin)/polls/page.tsx, .../[locale]/poll/[urlId]/page.tsx Refactored to include a delay and return specific components after loading.
.../[locale]/(admin)/polls/polls-list.tsx Updated to display a skeleton table when data is loading.
.../[locale]/invite/[urlId]/invite-page.tsx, .../[locale]/invite/[urlId]/nav.tsx Added new invite page functionality and navigation component.
.../[locale]/poll/[urlId]/guest-poll-alert.tsx Created alert for guest users about administrator rights and account creation.
.../components/page-layout.tsx Modified page content padding.
.../components/layouts/poll-layout.tsx Added import statement and changed return statement.
.../components/poll.tsx Added "use client" directive.

"In the land of code where the byte-bunnies roam,
🐰 A flurry of changes has found a new home.
With skeletons dancing while pages load,
Our digital burrow has been splendidly sowed!"

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a1bac0c and 282615e.
Files selected for processing (13)
  • apps/web/src/app/[locale]/(admin)/polls/layout.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/polls-list.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/nav.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/guest-poll-alert.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/page.tsx (1 hunks)
  • apps/web/src/app/components/page-layout.tsx (1 hunks)
  • apps/web/src/components/poll.tsx (1 hunks)
Files skipped from review due to trivial changes (4)
  • apps/web/src/app/[locale]/(admin)/polls/loading.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/loading.tsx
  • apps/web/src/app/[locale]/poll/[urlId]/page.tsx
  • apps/web/src/app/components/page-layout.tsx
Additional comments: 9
apps/web/src/app/[locale]/poll/[urlId]/loading.tsx (1)
  • 1-11: The implementation of the Loading function with Skeleton components appears correct and aligns with the PR's objective to enhance UX during data loading times. The use of different heights for the Skeleton components likely corresponds to the expected content size, which is a good practice for maintaining layout consistency during loading states.
apps/web/src/app/[locale]/(admin)/polls/page.tsx (1)
  • 5-11: The refactoring of the Page function to include a simulated delay using sleep before rendering the PollsList component is implemented correctly. This change is consistent with the PR's goal of improving UX by simulating data fetching times.
apps/web/src/app/[locale]/invite/[urlId]/nav.tsx (1)
  • 12-37: The Nav component is correctly implemented with conditional rendering based on user permissions, which is a good security practice. The use of the PageHeader and UserDropdown components contributes to a consistent and maintainable UI structure.
apps/web/src/app/[locale]/poll/[urlId]/guest-poll-alert.tsx (1)
  • 11-45: The GuestPollAlert component is well-implemented with clear conditional rendering logic to display an important message to guest users. The use of the Alert component and related elements from the UI library ensures consistency in the application's design system.
apps/web/src/app/[locale]/(admin)/polls/layout.tsx (1)
  • 14-42: The Layout function is correctly implemented, providing a structured layout for the admin polls section. The use of Trans for internationalization is appropriate and ensures that the application can support multiple languages.
apps/web/src/app/[locale]/invite/[urlId]/page.tsx (2)
  • 10-21: The refactoring of the Page function to include a simulated delay using sleep before rendering the InvitePage component is implemented correctly. This change is consistent with the PR's goal of improving UX by simulating data fetching times.

  • 23-76: The generateMetadata function is well-implemented, fetching necessary poll data and constructing comprehensive metadata for the page. The use of absoluteUrl to generate fully qualified URLs for Open Graph tags is a good practice for SEO and sharing purposes.

apps/web/src/components/poll.tsx (1)
  • 1-1: The addition of the "use client" directive at the beginning of the file is correct and indicates that the Poll component should only be rendered on the client side, aligning with modern best practices for dynamic rendering in web applications.
apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx (1)
  • 87-104: The InvitePage function is correctly implemented, using context providers to pass data down the component tree, which is a good practice for avoiding prop drilling and maintaining clean component interfaces. The use of the Prefetch component to fetch necessary data before rendering the page aligns with the PR's objectives to improve UX during data loading times.

Comment on lines 189 to 194
if (!data) {
// return a table using <Skeleton /> components
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The AI-generated summary mentions a conditional block to return a table using <Skeleton /> components when the data is falsy, but this is not present in the provided code. It seems there might be a missing implementation for the loading state in the PollsList function, which should be addressed to align with the PR's objectives.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a1bac0c and d8cddd7.
Files selected for processing (14)
  • apps/web/src/app/[locale]/(admin)/polls/layout.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/polls-list.tsx (2 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/nav.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/guest-poll-alert.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/page.tsx (1 hunks)
  • apps/web/src/app/components/page-layout.tsx (1 hunks)
  • apps/web/src/components/layouts/poll-layout.tsx (2 hunks)
  • apps/web/src/components/poll.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (12)
  • apps/web/src/app/[locale]/(admin)/polls/layout.tsx
  • apps/web/src/app/[locale]/(admin)/polls/loading.tsx
  • apps/web/src/app/[locale]/(admin)/polls/page.tsx
  • apps/web/src/app/[locale]/(admin)/polls/polls-list.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/loading.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/nav.tsx
  • apps/web/src/app/[locale]/poll/[urlId]/guest-poll-alert.tsx
  • apps/web/src/app/[locale]/poll/[urlId]/loading.tsx
  • apps/web/src/app/[locale]/poll/[urlId]/page.tsx
  • apps/web/src/app/components/page-layout.tsx
  • apps/web/src/components/poll.tsx
Additional comments: 5
apps/web/src/app/[locale]/invite/[urlId]/page.tsx (3)
  • 1-8: The imports have been streamlined, which is generally a positive change, assuming that the removed components are no longer used in this file.

  • 10-14: The Page function now simply returns a PageContainer wrapping an InvitePage component. This change suggests a move towards a more component-based architecture, which is good for maintainability and readability.

  • 18-71: The generateMetadata function is a new addition that seems to be responsible for generating metadata for a poll. It's important to ensure that the prisma.poll.findUnique call is properly handling cases where the poll might not be found, which it appears to do with a check on line 43. However, the satisfies Metadata at the end of the function is unusual syntax and should be verified for correctness.

Verification successful

The search for 'Metadata' within TypeScript files has yielded several results. Notably, it shows that Metadata is imported from "next" in the file apps/web/src/app/[locale]/invite/[urlId]/page.tsx. This suggests that Metadata is a type or interface provided by the Next.js framework. The usage of satisfies Metadata in the same file indicates that it is likely a TypeScript feature or pattern used in conjunction with Next.js to ensure that the returned object conforms to the Metadata type.

Given this context, the syntax satisfies Metadata appears to be valid and is used to assert that the returned object from generateMetadata function conforms to the Metadata type expected by Next.js.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the 'satisfies Metadata' syntax is correct and valid in the context of the application.
ast-grep --lang typescript --pattern $'return $_ satisfies Metadata;'

Length of output: 70



Script:

#!/bin/bash
# Search for the definition of 'Metadata' to understand its usage in the application.
ast-grep --lang typescript --pattern $'type Metadata = $_;'

Length of output: 60



Script:

#!/bin/bash
# Search for import statements or other usages of 'Metadata' to understand its context.
rg 'Metadata' --type ts

Length of output: 1367

apps/web/src/components/layouts/poll-layout.tsx (2)
  • 26-26: The addition of the Loader import is consistent with the new loading behavior described in the PR objectives. This change is good for UX, as it provides visual feedback during data fetching.

  • 263-263: Replacing return null; with return <Loader />; in the Prefetch component is a clear indication of the new loading state UX implementation. This is a positive change, aligning with the PR's objectives to improve user feedback during loading times.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a1bac0c and f526d58.
Files selected for processing (15)
  • apps/web/src/app/[locale]/(admin)/polls/layout.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/(admin)/polls/polls-list.tsx (2 hunks)
  • apps/web/src/app/[locale]/(auth)/login/login-form.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/loading.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/nav.tsx (1 hunks)
  • apps/web/src/app/[locale]/invite/[urlId]/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/guest-poll-alert.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/page.tsx (1 hunks)
  • apps/web/src/app/[locale]/poll/[urlId]/skeleton.tsx (1 hunks)
  • apps/web/src/app/components/page-layout.tsx (1 hunks)
  • apps/web/src/components/layouts/poll-layout.tsx (2 hunks)
  • apps/web/src/components/poll.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • apps/web/src/app/[locale]/poll/[urlId]/skeleton.tsx
Files skipped from review as they are similar to previous changes (12)
  • apps/web/src/app/[locale]/(admin)/polls/layout.tsx
  • apps/web/src/app/[locale]/(admin)/polls/loading.tsx
  • apps/web/src/app/[locale]/(admin)/polls/page.tsx
  • apps/web/src/app/[locale]/(admin)/polls/polls-list.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/loading.tsx
  • apps/web/src/app/[locale]/invite/[urlId]/nav.tsx
  • apps/web/src/app/[locale]/poll/[urlId]/guest-poll-alert.tsx
  • apps/web/src/app/[locale]/poll/[urlId]/page.tsx
  • apps/web/src/app/components/page-layout.tsx
  • apps/web/src/components/layouts/poll-layout.tsx
  • apps/web/src/components/poll.tsx
Additional comments: 4
apps/web/src/app/[locale]/invite/[urlId]/page.tsx (3)
  • 1-8: The imports have been streamlined, which suggests a refactoring towards a more modular architecture. Ensure that the removed components are either no longer needed or have been replaced appropriately in the new structure.

  • 10-16: The Page function now simply renders a PageContainer with an InvitePage component. This change indicates a move towards a cleaner separation of concerns. Verify that the InvitePage component is correctly handling the responsibilities previously managed by Page.

Verification successful

Based on the provided script output, the InvitePage component in invite-page.tsx appears to be correctly structured and is handling the responsibilities that were previously managed by the Page function in page.tsx. The InvitePage component is wrapped with context providers and uses various hooks and components, indicating a clear separation of concerns and modular structure.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that InvitePage component exists and is properly structured.
fd 'invite-page.tsx' --exec cat {} \;

Length of output: 2909

* 18-71: The `generateMetadata` function has been added to handle metadata generation for SEO purposes. It's important to ensure that this function is being called in the appropriate context and that the metadata is correctly formed and utilized.
apps/web/src/app/[locale]/(auth)/login/login-form.tsx (1)
  • 57-57: Adding await before queryClient.invalidate() and session.update() ensures that the state is properly updated before proceeding. This is a good practice to prevent race conditions and ensure that the UI reflects the latest state.

@lukevella lukevella merged commit 0a2e3e3 into main Jan 13, 2024
5 checks passed
@lukevella lukevella deleted the loading branch January 13, 2024 11:45
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.

1 participant