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

Website: Survey page (fixing bugs) #971

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Conversation

dnhn
Copy link
Member

@dnhn dnhn commented Dec 6, 2024

Hi team,

I found this project through For Good First Issue. After reviewing issues #759, #760, #761, I noticed they are all related to the Survey page and have remained unresolved since their last activities. I decided to investigate and fix them.

Let me know if you have any feedback!

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a custom hook useIsPage to determine if the current page is a survey page, enhancing component logic.
    • Conditional rendering for regions dropdown in the I18nDialog component based on the current page type.
    • Updated logic in the CookieConsentBanner to hide the banner on survey pages.
  • Style

    • Updated the --background-dim CSS variable to transparent for improved visual clarity on survey pages.

dnhn added 2 commits December 6, 2024 16:36
- Cookie banner
- Region selection dropdown
Copy link

vercel bot commented Dec 6, 2024

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

Name Status Preview Comments Updated (UTC)
public ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 6, 2024 11:05am

Copy link

vercel bot commented Dec 6, 2024

@dnhn is attempting to deploy a commit to the Social Income Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

coderabbitai bot commented Dec 6, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request include modifications to a CSS file, the introduction of a new custom React hook, and updates to two components to utilize this hook. The CSS variable --background-dim was changed from #f3f3f3 to transparent. The I18nDialog and CookieConsentBanner components now incorporate the useIsPage hook to conditionally render UI elements based on whether the current page is a survey page.

Changes

File Path Change Summary
website/src/app/[lang]/[region]/survey/[recipient]/[survey]/survey.css Updated CSS variable --background-dim from #f3f3f3 to transparent.
website/src/components/i18n-dialog.tsx Added import for useIsPage and modified rendering logic to conditionally show regions dropdown based on isSurveyPage.
website/src/components/tracking/cookie-consent-banner.tsx Added import for useIsPage and updated logic to hide banner based on isSurveyPage and cookie consent.
website/src/hooks/useIsPage.ts Introduced new hook useIsPage to determine if the current page matches a specified page string.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e8e6d23 and 61e842a.

📒 Files selected for processing (1)
  • website/src/hooks/useIsPage.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/src/hooks/useIsPage.ts

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

@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: 1

🧹 Outside diff range and nitpick comments (2)
website/src/components/tracking/cookie-consent-banner.tsx (1)

17-23: Add type annotation and document the survey page exception

The survey page exclusion logic is correct but could be more explicit.

Consider these improvements:

-  const isSurveyPage = useIsPage('survey');
+  const isSurveyPage: boolean = useIsPage('survey');

   useEffect(() => {
     const cookieConsent = localStorage.getItem('cookie_consent');
+    // Hide banner for survey pages or when consent is already given
     setHideBanner(Boolean(cookieConsent) || isSurveyPage);
   }, [isSurveyPage, setHideBanner]);
website/src/components/i18n-dialog.tsx (1)

52-52: Improve code organization and documentation

The survey page check should be closer to where it's used, and the special case should be documented.

Consider moving and documenting the check:

-  const isSurveyPage = useIsPage('survey');
   const [open, setOpen] = useState(false);
   const { language, setLanguage, region, setRegion, currency, setCurrency } = useI18n();

   // ... other code ...

+  // Hide region selection for survey pages as they're region-independent
+  const isSurveyPage = useIsPage('survey');
   {!_.isEmpty(regions) && !isSurveyPage && (

Also applies to: 79-79

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 43c070f and e8e6d23.

📒 Files selected for processing (4)
  • website/src/app/[lang]/[region]/survey/[recipient]/[survey]/survey.css (1 hunks)
  • website/src/components/i18n-dialog.tsx (3 hunks)
  • website/src/components/tracking/cookie-consent-banner.tsx (2 hunks)
  • website/src/hooks/useIsPage.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • website/src/app/[lang]/[region]/survey/[recipient]/[survey]/survey.css

website/src/hooks/useIsPage.ts Outdated Show resolved Hide resolved
@ssandino ssandino changed the title Website: Survey page Website: Survey page (fixing bugs) Dec 6, 2024
@ssandino
Copy link
Member

ssandino commented Dec 6, 2024

Testing on the staging user nDJwnvktHXolcAiYYnAm and his
(direct link: checkin survey) it resolves the issues #759, #760, #761 as intended:

Background gone: (left = new)
Screenshot 2024-12-06 at 13 51 04

Removes region selection dropdown: (left = new)
Screenshot 2024-12-06 at 13 50 48

Also Cookie banner is not appearing. Great job @dnhn ! Next will be a technical review by @mkue

@@ -0,0 +1,12 @@
import { usePathname } from 'next/navigation';

export function useIsPage(page: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This hook seems to have a quite specific use-case. It only checks for the third item in the path segments. Maybe a hook usePathnameContains(page: string) would be more re-usable?

You then still do

const isSurveyPage = usePathnameContains('/[lang]/[region]/survey');

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

That’s a good idea, I’ll update it.

@mkue mkue merged commit ee9617c into socialincome-san:main Dec 10, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
website Issues concerning Website
Projects
None yet
3 participants