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

ログアウトボタンとメール通知の切り替えボタン&APIを追加 #73

Merged
merged 10 commits into from
Nov 16, 2024

Conversation

TkymHrt
Copy link
Collaborator

@TkymHrt TkymHrt commented Nov 16, 2024

User description

概要

ログアウトボタンとメール通知の切り替えボタンを追加しました。

変更内容

ボタンの追加とCSSを調整しました。
メール通知の可否を変更できます。

動作確認


PR Type

enhancement


Description

  • ログアウトボタンを追加し、ユーザーが簡単にサインアウトできるようにしました。
  • メール通知の切り替えボタンを追加し、ユーザーが通知を停止または再開できるようにしました。
  • ユーザーインターフェースのレイアウトを調整し、より直感的な操作が可能になりました。
  • スコア表示部分にスクロール機能を追加し、多くのスコアがある場合でも見やすくしました。

Changes walkthrough 📝

Relevant files
Enhancement
page.tsx
ログアウトとメール通知切り替えボタンの追加とUI調整                                                             

app/src/app/user/page.tsx

  • ログアウトボタンを追加し、signOut関数を呼び出すように設定
  • メール通知の切り替えボタンを追加し、状態に応じた関数を呼び出す
  • ユーザーインターフェースのレイアウトを調整
  • スコア表示部分にスクロール機能を追加
  • +56/-31 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    未実装の関数
    handleUnsubscribehandleResubscribe 関数が未実装です。これらの関数が正しく動作するかどうか確認する必要があります。

    UIの一貫性
    ボタンのスタイルが一貫していない可能性があります。特に、ログアウト ボタンと メール通知を停止/再開 ボタンのスタイルを確認してください。

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add validation to prevent errors when mapping over potentially undefined data

    Validate the myScore data before mapping to prevent potential runtime errors if the
    data structure changes.

    app/src/app/user/page.tsx [131]

    -myScore.map((score) => (
    +myScore?.map((score) => (
    Suggestion importance[1-10]: 8

    Why: This suggestion is critical as it addresses potential runtime errors by validating the data before mapping, which can prevent crashes if the data structure changes unexpectedly.

    8
    Possible bug
    Add error handling to the sign-out process to improve robustness

    Ensure that signOut handles any potential errors that may arise during the sign-out
    process.

    app/src/app/user/page.tsx [159]

    -onClick={signOut}
    +onClick={async () => { try { await signOut(); } catch (error) { /* handle error */ } }}
    Suggestion importance[1-10]: 7

    Why: This suggestion enhances the robustness of the sign-out functionality by recommending error handling, which is crucial for a better user experience and to prevent unhandled exceptions.

    7
    Ensure that the unsubscribe functionality is implemented correctly

    handleUnsubscribe and handleResubscribe functions should implement the actual
    unsubscribe and resubscribe logic to ensure functionality.

    app/src/app/user/page.tsx [51]

    -const handleUnsubscribe = async () => {};
    +const handleUnsubscribe = async () => {
    +    // Implement unsubscribe logic here
    +};
    Suggestion importance[1-10]: 5

    Why: The suggestion addresses a potential functionality gap by indicating that the unsubscribe logic needs to be implemented, which is important for the feature to work as intended.

    5
    Enhancement
    Improve user experience by adding a loading state to async buttons

    Consider adding a loading state for the unsubscribe and resubscribe buttons to
    improve user experience during async operations.

    app/src/app/user/page.tsx [164]

     {isSubscribed ? (
    +    <Button variant={"outline"} onClick={handleUnsubscribe} disabled={loading}>
    Suggestion importance[1-10]: 6

    Why: Adding a loading state for async operations is a good practice that enhances user experience, making it clear to users that an action is being processed.

    6

    @TkymHrt TkymHrt changed the title ログアウトボタンとメール通知の切り替えボタンを追加 ログアウトボタンとメール通知の切り替えボタン&APIを追加 Nov 16, 2024
    import { prisma } from "@lib/prisma";
    import type { NextRequest } from "next/server";

    export async function POST(req: NextRequest) {
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    export async function POST(req: NextRequest) {
    export async function PUT(req: NextRequest) {


    try {
    const response = await fetch("/api/user/updateEmailPreference", {
    method: "POST",
    Copy link
    Collaborator

    Choose a reason for hiding this comment

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

    Suggested change
    method: "POST",
    method: "PUT",

    @nose221834 nose221834 merged commit 7992352 into main Nov 16, 2024
    1 check passed
    @nose221834 nose221834 deleted the feat/yama/create-logout-button branch November 16, 2024 12:09
    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.

    3 participants