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: UI updates in relation to backend changes #2304

Merged
merged 1 commit into from
Dec 7, 2024

Conversation

OchiengPaul442
Copy link
Contributor

@OchiengPaul442 OchiengPaul442 commented Dec 6, 2024

Summary of Changes (What does this PR do?)

  • Added error handling
  • Adjusted params in certain sections on the UI.

ISSUE: [WEB-458]

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state

Screenshots (optional)

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced user interface for resource links in the event components with new icons and improved layout.
    • Transitioned to client-side data fetching in the Clean Air Layout for a more dynamic experience.
    • Improved handling of partner logos with updated property references.
  • Bug Fixes

    • Added error handling to improve the reliability of file name extraction from URLs.
  • Documentation

    • Updated property names for clarity across various components.
  • Chores

    • Streamlined image loading logic in the Member Card component for better performance.

Copy link

coderabbitai bot commented Dec 6, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several updates across multiple components in the website application. Key changes include enhancements to the SingleEvent components by incorporating new icons and improving resource link layouts. The CleanAirLayout component transitions from server-side to client-side data fetching using React hooks. Partner logo references are updated for consistency, and the getFileNameFromUrl function is fortified with error handling. Additionally, the BannerSection and MemberCard components see property name adjustments and streamlined image handling, respectively. Overall, the modifications aim to enhance user experience and code reliability.

Changes

File Path Change Summary
website2/src/app/(about)/events/[id]/SingleEvent.tsx Added icons FiDownload and FiExternalLink, improved resource section layout, renamed resource to resource_url, modified class names for styling.
website2/src/app/clean-air-forum/layout.tsx Changed CleanAirLayout from an async function to a functional component using hooks, removed static metadata, added state management for loading and data fetching.
website2/src/app/clean-air-forum/partners/page.tsx Updated partner logo references from partner.partner_logo to partner.partner_logo_url.
website2/src/app/clean-air-forum/resources/page.tsx Modified getFileNameFromUrl function to handle `string
website2/src/app/clean-air-network/events/[id]/SingleEvent.tsx Similar updates as in the first SingleEvent component, including new icons and resource section enhancements.
website2/src/components/sections/Forum/BannerSection.tsx Renamed background_image to background_image_url for image rendering.
website2/src/components/ui/MemberCard.tsx Updated image handling to use only member.picture_url, added customizable btnText property to MemberCardProps interface.

Possibly related PRs

Suggested labels

ready for review

Suggested reviewers

  • Baalmart
  • Codebmk

🎉 In the code's embrace, we find delight,
With icons and layouts, everything feels right.
From partners to banners, all things anew,
A sprinkle of logic, and a dash of the view.
So here’s to the changes, let’s raise a cheer,
For a smoother experience, we hold dear! 🎊


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 or @coderabbitai title 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: 2

🧹 Outside diff range and nitpick comments (2)
website2/src/app/clean-air-forum/layout.tsx (1)

15-52: Consider removing the commented-out metadata to keep the code clean

The large block of commented-out code can make the file less readable. If the metadata is no longer needed, it's better to remove it entirely to maintain clarity.

website2/src/app/clean-air-forum/resources/page.tsx (1)

9-13: Consider refining error handling in 'getFileNameFromUrl'

While the added type checks enhance robustness, logging errors to the console might not be ideal in production environments. Consider using a logging framework or handling the error differently.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4cd1446 and ee1a922.

📒 Files selected for processing (7)
  • website2/src/app/(about)/events/[id]/SingleEvent.tsx (2 hunks)
  • website2/src/app/clean-air-forum/layout.tsx (3 hunks)
  • website2/src/app/clean-air-forum/partners/page.tsx (1 hunks)
  • website2/src/app/clean-air-forum/resources/page.tsx (1 hunks)
  • website2/src/app/clean-air-network/events/[id]/SingleEvent.tsx (2 hunks)
  • website2/src/components/sections/Forum/BannerSection.tsx (1 hunks)
  • website2/src/components/ui/MemberCard.tsx (1 hunks)
🔇 Additional comments (6)
website2/src/components/sections/Forum/BannerSection.tsx (1)

43-43: Update aligns with consistent naming conventions

Changing background_image to background_image_url improves clarity and consistency in how image URLs are referenced across the codebase.

website2/src/app/clean-air-forum/partners/page.tsx (1)

21-21: Consistent use of 'partner_logo_url' enhances clarity

Updating partner.partner_logo to partner.partner_logo_url ensures consistency in naming conventions for URL properties, improving code readability.

Also applies to: 29-29, 36-36, 44-44

website2/src/components/ui/MemberCard.tsx (2)

Line range hint 24-25: Optional props 'btnText' and 'cardClassName' enhance flexibility

Adding btnText and cardClassName as optional properties makes the MemberCard component more customizable and adaptable to different use cases.


59-59: Ensure 'member.picture_url' is reliably populated

With the removal of member.picture as a fallback, make sure that member.picture_url is consistently provided to avoid missing images.

Run the following script to check for any remaining usages of member.picture:

website2/src/app/clean-air-network/events/[id]/SingleEvent.tsx (1)

7-12: LGTM: Clean icon imports

The new icon imports are well-organized and properly grouped.

website2/src/app/(about)/events/[id]/SingleEvent.tsx (1)

350-376: Apply the same security enhancements as the other SingleEvent component

The changes in this file are identical to those in website2/src/app/clean-air-network/events/[id]/SingleEvent.tsx. Please apply the same security enhancements suggested in the previous review.

}: CleanAirLayoutProps) {
let data = null;
const CleanAirLayout: React.FC<CleanAirLayoutProps> = ({ children }) => {
const [data, setData] = useState<any>(null); // Replace `any` with your actual data type
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Specify the exact data type instead of using 'any'

Using any reduces the benefits of TypeScript's type safety. Replacing it with the actual data type of data will enhance reliability and maintainability.

Comment on lines +346 to +372
className="flex justify-between items-center p-4 bg-gray-50 rounded-lg shadow-md hover:shadow-lg transition-shadow duration-200"
>
<div>
<h3 className="text-lg font-medium">{resource.title}</h3>
{resource.link && (
<a
href={resource.link}
target="_blank"
rel="noopener noreferrer"
className="text-blue-500 hover:underline"
>
View Link
</a>
)}
{resource.resource && (
<a
href={resource.resource}
download
className="text-blue-500 hover:underline ml-4"
>
Download
</a>
)}
<h3 className="text-xl font-semibold mb-2 text-gray-800">
{resource.title}
</h3>
<div className="flex space-x-4">
{resource.link && (
<a
href={resource.link}
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center text-blue-600 hover:underline font-medium"
>
<FiExternalLink className="mr-2" /> View Link
</a>
)}
{resource.resource_url && (
<a
href={resource.resource_url}
download
className="inline-flex items-center text-blue-600 hover:underline font-medium"
>
<FiDownload className="mr-2" /> Download
</a>
)}
</div>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider enhancing security for external links and downloads

While the UI improvements look great, there are some security considerations:

  1. External links should include additional security attributes
  2. Download links should validate file types

Apply this diff to enhance security:

-                        target="_blank"
-                        rel="noopener noreferrer"
+                        target="_blank"
+                        rel="noopener noreferrer nofollow"
+                        className="inline-flex items-center text-blue-600 hover:underline font-medium"
-                        download
+                        download
+                        onClick={(e) => {
+                          const fileExtension = resource.resource_url.split('.').pop()?.toLowerCase();
+                          const allowedTypes = ['pdf', 'doc', 'docx', 'xls', 'xlsx'];
+                          if (!allowedTypes.includes(fileExtension)) {
+                            e.preventDefault();
+                            alert('Invalid file type');
+                          }
+                        }}

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

github-actions bot commented Dec 6, 2024

New Website2 changes available for preview here

@Baalmart Baalmart merged commit 583af15 into staging Dec 7, 2024
31 checks passed
@Baalmart Baalmart deleted the website-frontend-update branch December 7, 2024 00:03
@Baalmart Baalmart mentioned this pull request Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants