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

detailPage #128

Merged
merged 9 commits into from
Dec 11, 2024
Merged

detailPage #128

merged 9 commits into from
Dec 11, 2024

Conversation

Elaine2899
Copy link
Contributor

@Elaine2899 Elaine2899 commented Nov 30, 2024

In progress:

  1. supabase 時區顯示問題
  2. 報名活動鈕
  3. carousel 的顯示鈕
  4. navigation bar
    螢幕擷取畫面 2024-11-30 222003

Summary by CodeRabbit

  • New Features

    • Enhanced route definitions with explicit identifiers for improved clarity.
    • Revamped Event Details component with a dynamic layout, including an image carousel and detailed event sections.
    • Added interactive elements such as a favoriting checkbox and sign-up buttons.
  • Documentation

    • Updated comments to clarify the auto-generated nature of route configuration files and exclude them from linters and formatters.

Copy link
Contributor

coderabbitai bot commented Nov 30, 2024

Walkthrough

The changes in this pull request primarily involve modifications to two files: src/routeTree.gen.ts and src/routes/events/$eventId.tsx. The first file has been updated to enhance documentation and introduce an id property for each route, ensuring clearer identification and consistency. The second file sees significant restructuring of the EventDetails component, transforming its layout to include a carousel and additional sections for event information, thereby improving the user interface.

Changes

File Change Summary
src/routeTree.gen.ts Updated documentation to indicate auto-generation; added id properties to all route configs; modified FileRoutesByPath interface to include id.
src/routes/events/$eventId.tsx Introduced a new styles object; restructured component layout to include a carousel and detailed sections for event information.

Possibly related PRs

Suggested reviewers

  • 1989ONCE
  • yeahlowflicker

🐰 In the code where routes align,
Each path now has an id so fine.
Events now dance in a carousel bright,
With details that sparkle, a true delight!
Auto-generated, clear as can be,
Hop along, let’s code joyfully! 🐇✨


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

🧹 Outside diff range and nitpick comments (1)
src/routes/events/$eventId.tsx (1)

94-95: Format event start and end times for better readability

Displaying raw timestamps may not be user-friendly. Consider formatting event.start_time and event.end_time to a more readable date and time format.

Apply this diff to format the event times:

            <p>{event.start_time}~{event.end_time}</p>
+           <p>{new Date(event.start_time).toLocaleString()} ~ {new Date(event.end_time).toLocaleString()}</p>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f00464a and d5ebb7b.

📒 Files selected for processing (2)
  • src/routeTree.gen.ts (2 hunks)
  • src/routes/events/$eventId.tsx (1 hunks)
🔇 Additional comments (1)
src/routeTree.gen.ts (1)

7-9: Acknowledged auto-generated file with updates

The file is auto-generated, and the added id properties for routes enhance route identification. No action needed.

Comment on lines 135 to 137
<p>學生學習護照</p>
<p>實數類型 {event.fee} 小時</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Verify the correct usage of event.fee

The event.fee property is used to represent both 'hours' and 'participant limit', which may lead to confusion. Ensure that event.fee is correctly used or consider using separate properties for clarity.

Also applies to: 148-150

Comment on lines 150 to 151
<li>{event.user_id}</li>
</ol>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid displaying event.user_id directly to users

Displaying event.user_id may not be meaningful to users and could expose sensitive information. Consider showing the organizer's name or a more user-friendly identifier.

Comment on lines 104 to 109
<div className='flex'>
<svg className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 17.345a4.76 4.76 0 0 0 2.558 1.618c2.274.589 4.512-.446 4.999-2.31.487-1.866-1.273-3.9-3.546-4.49-2.273-.59-4.034-2.623-3.547-4.488.486-1.865 2.724-2.899 4.998-2.31.982.236 1.87.793 2.538 1.592m-3.879 12.171V21m0-18v2.2"/>
</svg>
<p>活動價格</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Display the event price

The event price label is shown without the actual price. Include the price from event.price to inform users about the cost.

Apply this diff to include the event price:

          {/* 活動價格 */}
          <div className='flex'>
            <svg className="w-6 h-6 text-gray-800 dark:text-white" /* SVG content */ />
-           <p>活動價格</p>
+           <p>活動價格:{event.price}</p>
          </div>

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

Comment on lines 47 to 66
<div id="item1" className="carousel-item w-full">
<img src="https://i.pinimg.com/originals/68/21/7d/68217da82cbeb3cc833ed2acdea7c738.gif" className="w-full" />
</div>
<div id="item2" className="carousel-item w-full">
<img src="https://i.pinimg.com/originals/79/de/27/79de27bafeb77f608ef74b3d02e727ba.gif"className="w-full" />
</div>
<div id="item3" className="carousel-item w-full">
<img src="https://i.pinimg.com/originals/df/f2/75/dff275ddc4aea5548575fd78d218965d.gif" className="w-full" />
</div>
<div id="item4" className="carousel-item w-full">
<img src="https://i.pinimg.com/originals/fc/b4/ee/fcb4ee6e201ec8f0de461a9f1ac65d2e.gif" className="w-full" />
</div>
</div>
{/* 換頁點點-要根據使用者提供的張數更改個數 */}
<div className="absolute bottom-4 flex w-full justify-center gap-2 py-2">
<a href="#item1" className="btn btn-xs">1</a>
<a href="#item2" className="btn btn-xs">2</a>
<a href="#item3" className="btn btn-xs">3</a>
<a href="#item4" className="btn btn-xs">4</a>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make the carousel dynamic based on event images

Currently, the carousel images and navigation buttons are hardcoded with static image URLs and a fixed number of items. To improve scalability and maintainability, consider fetching the images from the event data and dynamically generating the carousel items and navigation buttons based on the actual number of images.

Apply this diff to make the carousel dynamic:

-        <div className="carousel w-full">
-          <div id="item1" className="carousel-item w-full">
-            <img src="https://i.pinimg.com/originals/68/21/7d/68217da82cbeb3cc833ed2acdea7c738.gif" className="w-full" />
-          </div>
-          <!-- Additional hardcoded items -->
-        </div>
+        <div className="carousel w-full">
+          {event.images.map((imageUrl, index) => (
+            <div key={index} id={`item${index + 1}`} className="carousel-item w-full">
+              <img src={imageUrl} className="w-full" />
+            </div>
+          ))}
+        </div>

-        <div className="absolute bottom-4 flex w-full justify-center gap-2 py-2">
-          <a href="#item1" className="btn btn-xs">1</a>
-          <!-- Additional hardcoded navigation buttons -->
-        </div>
+        <div className="absolute bottom-4 flex w-full justify-center gap-2 py-2">
+          {event.images.map((_, index) => (
+            <a key={index} href={`#item${index + 1}`} className="btn btn-xs">
+              {index + 1}
+            </a>
+          ))}
+        </div>

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

Comment on lines 97 to 102
<div className='flex'>
<svg className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 13a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/>
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.8 13.938h-.011a7 7 0 1 0-11.464.144h-.016l.14.171c.1.127.2.251.3.371L12 21l5.13-6.248c.194-.209.374-.429.54-.659l.13-.155Z"/>
</svg>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Display the event location

The event location is currently not shown. Including the location helps users know where the event is held.

Apply this diff to display the event location:

          {/* 活動地點 */}
          <div className='flex'>
            <svg className="w-6 h-6 text-gray-800 dark:text-white" /* SVG content */ />
+           <p>{event.location}</p>
          </div>

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

@1989ONCE 1989ONCE added the enhancement New feature or request label Dec 2, 2024
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: 2

🧹 Outside diff range and nitpick comments (1)
src/routes/events/$eventId.tsx (1)

23-40: Consider using Tailwind classes instead of inline styles

The inline styles object could be replaced with Tailwind utility classes for better maintainability and consistency with the rest of the codebase.

-const styles = {
-  body:{
-    backgroundColor:'#3E3E3E'
-  },
-  container:{
-    flex: 1,
-    backgroundColor: '#FFFFFF'
-  },
-  card:{
-    borderRadius: "15px",
-    backgroundColor:'#FFFFFF',
-    margin: "1rem 1.5rem",
-    padding: "1rem"
-  },
-  icon:{
-    margin:"0.5rem"
-  },
-}

Replace usages with Tailwind classes:

  • style={styles.body}className="bg-[#3E3E3E]"
  • style={styles.container}className="flex-1 bg-white"
  • style={styles.card}className="rounded-2xl bg-white m-6 p-4"
  • style={styles.icon}className="m-2"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d5ebb7b and 7a63e0b.

📒 Files selected for processing (1)
  • src/routes/events/$eventId.tsx (2 hunks)
🔇 Additional comments (5)
src/routes/events/$eventId.tsx (5)

52-76: Make the carousel dynamic based on event images

The carousel currently uses hardcoded images and navigation buttons. This should be made dynamic based on the event's images.

#!/bin/bash
# Check if events table has an images column
rg -A 5 "images.*from.*events" 

118-118: Display the event price

The price section only shows the label without the actual price.


238-238: Verify the correct usage of event.fee and user information

  1. The event.fee property is used for both hours and participant limit
  2. The event.user_id is displayed directly to users

Also applies to: 251-252


270-275: Work in progress items align with PR objectives

The TODO comments match the PR objectives regarding:

  • Supabase timezone display
  • Carousel display buttons
  • Favorite function
  • Header display

111-111: ⚠️ Potential issue

Add missing location display

The location section is empty but has the icon prepared.

+<p>{event.location}</p>

Likely invalid or redundant comment.

Comment on lines +121 to +211
<button className="btn absolute bottom-1 right-1"
onClick={() => {
if (join) {
(document.getElementById("cancel_modal") as HTMLFormElement).showModal();
} else {
(document.getElementById("join_modal") as HTMLFormElement).showModal();
}
}}>
{join ? "已報名" : "報名活動"}
</button>

<dialog id="join_modal" className="modal">
<div className="modal-box w-11/12 max-w-5xl">
<h3 className="text-xl flex items-center justify-center">
<svg className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5.365V3m0 2.365a5.338 5.338 0 0 1 5.133 5.368v1.8c0 2.386 1.867 2.982 1.867 4.175 0 .593 0 1.292-.538 1.292H5.538C5 18 5 17.301 5 16.708c0-1.193 1.867-1.789 1.867-4.175v-1.8A5.338 5.338 0 0 1 12 5.365ZM8.733 18c.094.852.306 1.54.944 2.112a3.48 3.48 0 0 0 4.646 0c.638-.572 1.236-1.26 1.33-2.112h-6.92Z"/>
</svg>
</h3>
<p className="py-4 text-xl flex items-center justify-center">確定要報名此活動嗎?</p>
<div className="modal-action justify-between">
<button className="btn w-1/2"
onClick={()=>{
setJoin(true);
if(document){
(document.getElementById('joinSuccess_modal') as HTMLFormElement).showModal();
(document.getElementById("join_modal") as HTMLFormElement).close();
}}}
></button>
<dialog id="joinSuccess_modal" className="modal">
<div className="modal-box w-11/12 max-w-5xl">
<div className='flex item-center justify-center'>
<svg className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5.365V3m0 2.365a5.338 5.338 0 0 1 5.133 5.368v1.8c0 2.386 1.867 2.982 1.867 4.175 0 .593 0 1.292-.538 1.292H5.538C5 18 5 17.301 5 16.708c0-1.193 1.867-1.789 1.867-4.175v-1.8A5.338 5.338 0 0 1 12 5.365ZM8.733 18c.094.852.306 1.54.944 2.112a3.48 3.48 0 0 0 4.646 0c.638-.572 1.236-1.26 1.33-2.112h-6.92Z"/>
</svg>
<h3 className="font-bold text-lg">通知</h3>
</div>
<p className="py-4 flex item-center justify-center">活動報名成功!</p>
<div className="modal-action">
<form method="dialog" className='w-full'>
<button className="btn w-full"></button>
</form>
</div>
</div>
</dialog>
<form method="dialog" className='w-1/2'>
<button className="btn w-full">取消</button>
</form>
</div>
</div>
</dialog>
<dialog id="cancel_modal" className="modal">
<div className="modal-box w-11/12 max-w-5xl">
<div>
<svg className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5.365V3m0 2.365a5.338 5.338 0 0 1 5.133 5.368v1.8c0 2.386 1.867 2.982 1.867 4.175 0 .593 0 1.292-.538 1.292H5.538C5 18 5 17.301 5 16.708c0-1.193 1.867-1.789 1.867-4.175v-1.8A5.338 5.338 0 0 1 12 5.365ZM8.733 18c.094.852.306 1.54.944 2.112a3.48 3.48 0 0 0 4.646 0c.638-.572 1.236-1.26 1.33-2.112h-6.92Z"/>
</svg>
<h3 className="text-xl flex items-center justify-center">確定要取消報名此活動嗎?</h3>
</div>
<div className="modal-action justify-between">
<button
className="btn w-1/2"
onClick={() => {
setJoin(false);
(document.getElementById("cancel_modal") as HTMLFormElement).close();
(document.getElementById("cancelSuccess_modal") as HTMLFormElement).showModal();
}}
>
</button>
<dialog id="cancelSuccess_modal" className="modal">
<div className="modal-box w-11/12 max-w-5xl">
<div className='flex item-center justify-center'>
<svg className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5.365V3m0 2.365a5.338 5.338 0 0 1 5.133 5.368v1.8c0 2.386 1.867 2.982 1.867 4.175 0 .593 0 1.292-.538 1.292H5.538C5 18 5 17.301 5 16.708c0-1.193 1.867-1.789 1.867-4.175v-1.8A5.338 5.338 0 0 1 12 5.365ZM8.733 18c.094.852.306 1.54.944 2.112a3.48 3.48 0 0 0 4.646 0c.638-.572 1.236-1.26 1.33-2.112h-6.92Z"/>
</svg>
<h3 className="font-bold text-lg">通知</h3>
</div>
<p className="py-4 flex item-center justify-center">活動取消報名成功!</p>
<div className="modal-action">
<form method="dialog" className='w-full'>
<button className="btn w-full"></button>
</form>
</div>
</div>
</dialog>
<form method="dialog" className="w-1/2">
<button className="btn w-full">取消</button>
</form>
</div>
</div>
</dialog>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve modal implementation and error handling

The current modal implementation has several areas for improvement:

  1. TypeScript assertions could be avoided with proper typing
  2. Similar modal structures could be extracted into a reusable component
  3. Missing error handling for registration actions

Consider creating a reusable modal component:

type ModalProps = {
  id: string;
  title: string;
  message: string;
  onConfirm: () => Promise<void>;
  onCancel: () => void;
};

const ConfirmationModal: React.FC<ModalProps> = ({
  id,
  title,
  message,
  onConfirm,
  onCancel,
}) => {
  const [error, setError] = useState<string | null>(null);
  
  const handleConfirm = async () => {
    try {
      await onConfirm();
    } catch (err) {
      setError(err.message);
    }
  };

  return (
    <dialog id={id} className="modal">
      {/* ... existing modal structure ... */}
    </dialog>
  );
};

<svg style={styles.icon} className="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
</svg>
<p>{event.start_time}~{event.end_time}</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle timezone display in event times

The direct display of start_time and end_time might show incorrect timezone information as mentioned in the PR objectives.

Consider using a date formatting library like date-fns or luxon to properly format the times:

-<p>{event.start_time}~{event.end_time}</p>
+<p>{format(parseISO(event.start_time), 'PPp')} ~ {format(parseISO(event.end_time), 'PPp')}</p>

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

@1989ONCE 1989ONCE merged commit b67c05e into NCUAppTeam:main Dec 11, 2024
3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants