From 47068d861519f9d62877ad8001bc791cbda3b161 Mon Sep 17 00:00:00 2001 From: hellotksan Date: Sat, 14 Dec 2024 13:43:45 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=90=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=81=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #79 --- src/components/layouts/allUsers/AllUsers.tsx | 16 +- src/components/layouts/header/Header.tsx | 15 +- src/components/layouts/login/LoginForm.tsx | 14 -- src/components/layouts/postEdit/PostEdit.tsx | 21 +-- src/components/layouts/profile/Profile.tsx | 14 +- src/components/layouts/setting/Setting.tsx | 34 +++-- src/components/layouts/timeline/PostForm.tsx | 29 ++-- .../layouts/timeline/SinglePost.tsx | 137 ++++++++---------- src/features/auth/authSlice.ts | 4 +- 9 files changed, 127 insertions(+), 157 deletions(-) diff --git a/src/components/layouts/allUsers/AllUsers.tsx b/src/components/layouts/allUsers/AllUsers.tsx index ace3f3e..5497d2d 100644 --- a/src/components/layouts/allUsers/AllUsers.tsx +++ b/src/components/layouts/allUsers/AllUsers.tsx @@ -7,7 +7,7 @@ import * as Feedback from "@/components/shared/feedback/index"; import useAllUsers from "@/hooks/useAllUsers"; import { User } from "@/types/user"; import PersonIcon from "@mui/icons-material/Person"; -import RocketLaunchIcon from "@mui/icons-material/RocketLaunch"; +import RocketIcon from "@mui/icons-material/Rocket"; const AllUsersComponent: React.FC = () => { const { users, loading, error } = useAllUsers(); @@ -22,7 +22,7 @@ const AllUsersComponent: React.FC = () => {

全ユーザー

-
+
{users.map((user: User) => ( { className="flex items-center p-2 rounded hover:bg-gray-300 transition duration-200" >
- {user.profilePicture ? ( - - ) : ( - - )} + {user.profilePicture ? : } {user.username}
diff --git a/src/components/layouts/header/Header.tsx b/src/components/layouts/header/Header.tsx index e8d6817..5fbef5a 100644 --- a/src/components/layouts/header/Header.tsx +++ b/src/components/layouts/header/Header.tsx @@ -18,7 +18,7 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import RocketLaunchIcon from "@mui/icons-material/RocketLaunch"; +import RocketIcon from "@mui/icons-material/Rocket"; import { SidebarTrigger } from "@/components/ui/sidebar"; import { useAuth } from "@/hooks/useAuth"; @@ -43,7 +43,7 @@ const Topbar: React.FC = () => { return (
- +
@@ -76,14 +76,7 @@ const Topbar: React.FC = () => { - {user && user.profilePicture ? ( - - ) : ( - - )} + {user && user.profilePicture ? : } My Account @@ -99,7 +92,7 @@ const Topbar: React.FC = () => { }} className="no-underline" > - + Profile diff --git a/src/components/layouts/login/LoginForm.tsx b/src/components/layouts/login/LoginForm.tsx index 7a183cd..dae9d60 100644 --- a/src/components/layouts/login/LoginForm.tsx +++ b/src/components/layouts/login/LoginForm.tsx @@ -1,13 +1,7 @@ "use client"; import React, { useEffect, useRef } from "react"; -// import { useRouter } from "next/navigation"; import { loginCall } from "@/app/actionCalls"; -// import { -// loginStart, -// loginSuccess, -// loginError, -// } from "@/features/auth/authSlice"; import { useAppDispatch } from "@/hooks/useDispatch"; import { User } from "@/types/user"; import { useAuth } from "@/hooks/useAuth"; @@ -15,10 +9,8 @@ import { useAuth } from "@/hooks/useAuth"; const LoginForm: React.FC = () => { const emailRef = useRef(null); const passwordRef = useRef(null); - const dispatch = useAppDispatch(); const { login } = useAuth(); - // const router = useRouter(); useEffect(() => { // 自動でメールフィールドにフォーカスを当てる @@ -34,17 +26,11 @@ const LoginForm: React.FC = () => { }; const onSubmit = async (email: string, password: string): Promise => { - // dispatch(loginStart()); - try { const userData: User = await loginCall({ email, password, dispatch }); login(userData); - // dispatch(loginSuccess(userData)); - // router.push("/home"); } catch (err) { - // dispatch(loginError("ログインに失敗しました")); alert("エラーが発生しました。"); - // router.refresh(); } }; diff --git a/src/components/layouts/postEdit/PostEdit.tsx b/src/components/layouts/postEdit/PostEdit.tsx index 598c133..6dc583c 100644 --- a/src/components/layouts/postEdit/PostEdit.tsx +++ b/src/components/layouts/postEdit/PostEdit.tsx @@ -5,6 +5,7 @@ import LoadingSpinner from "@/components/elements/loadingSpinner/LoadingSpinner" import usePost from "@/hooks/usePost"; import * as Feedback from "@/components/shared/feedback/index"; import { useAuth } from "@/hooks/useAuth"; +import { Button } from "@/components/ui/button"; interface PostEditProps { postId: string; @@ -33,7 +34,7 @@ const PostEditComponent = ({ postId }: PostEditProps): JSX.Element | null => { } return ( -
+

投稿設定

@@ -55,18 +56,20 @@ const PostEditComponent = ({ postId }: PostEditProps): JSX.Element | null => { />
- - + Delete +
diff --git a/src/components/layouts/profile/Profile.tsx b/src/components/layouts/profile/Profile.tsx index 64f3b04..b19d7f9 100644 --- a/src/components/layouts/profile/Profile.tsx +++ b/src/components/layouts/profile/Profile.tsx @@ -7,7 +7,7 @@ import { toast } from "react-toastify"; import { USERS_ENDPOINT } from "@/constants/api"; import { useUser } from "@/hooks/useUser"; import PersonIcon from "@mui/icons-material/Person"; -import RocketLaunchIcon from "@mui/icons-material/RocketLaunch"; +import RocketIcon from "@mui/icons-material/Rocket"; import { useAuth } from "@/hooks/useAuth"; import { User } from "@/types/user"; @@ -80,11 +80,13 @@ const ProfileComponent: React.FC = ({ username }) => { return (
- {showingUser.profilePicture ? ( - - ) : ( - - )} +
+ {showingUser.profilePicture ? ( + + ) : ( + + )} +
{showingUser.username}{" "} {username === user?.username && ( diff --git a/src/components/layouts/setting/Setting.tsx b/src/components/layouts/setting/Setting.tsx index 20bd762..0aabee1 100644 --- a/src/components/layouts/setting/Setting.tsx +++ b/src/components/layouts/setting/Setting.tsx @@ -5,6 +5,8 @@ import { useRouter } from "next/navigation"; import axios from "axios"; import { USERS_ENDPOINT } from "@/constants/api"; import { useAuth } from "@/hooks/useAuth"; +import { Button } from "@/components/ui/button"; +import Link from "next/link"; const SettingComponent: React.FC = () => { const { user, logoutUser } = useAuth(); @@ -49,10 +51,10 @@ const SettingComponent: React.FC = () => { }; return ( -
+

ユーザー設定

-
+
ユーザー名:{user?.username}
@@ -64,20 +66,32 @@ const SettingComponent: React.FC = () => { rows={2} />
- - + Delete + */}
+
+ alert("現在、アカウントの削除はできません。")} + className="hover:underline" + > + アカウント削除はこちらから + +
); diff --git a/src/components/layouts/timeline/PostForm.tsx b/src/components/layouts/timeline/PostForm.tsx index 5b59066..d8e6357 100644 --- a/src/components/layouts/timeline/PostForm.tsx +++ b/src/components/layouts/timeline/PostForm.tsx @@ -1,13 +1,13 @@ "use client"; -import React, { useEffect, useRef, useState } from "react"; +import React, { useRef } from "react"; import axios from "axios"; import { POSTS_ENDPOINT } from "@/constants/api"; import PersonIcon from "@mui/icons-material/Person"; import { User } from "@/types/user"; import { Post } from "@/types/post"; import PostButton from "./PostButton"; -import RocketLaunchIcon from "@mui/icons-material/RocketLaunch"; +import RocketIcon from "@mui/icons-material/Rocket"; import { useAuth } from "@/hooks/useAuth"; interface PostFormProps { @@ -39,30 +39,21 @@ const PostForm: React.FC = ({ onPostSuccess }) => { if (desc.current) { desc.current.value = ""; // テキストエリアをクリア } - } catch (error) { + } catch (err) { alert("エラーが発生しました。"); } }; - const [isClient, setIsClient] = useState(false); - - useEffect(() => { - setIsClient(true); // クライアントサイドでのレンダリングを有効化 - }, []); - - if (!isClient) return null; // クライアントサイドでない場合、何も表示しない - return (
- {user.profilePicture ? ( - - ) : ( - - )} +
+ {user.profilePicture ? ( + + ) : ( + + )} +