fix: media path
This commit is contained in:
parent
dfd3bb5f48
commit
8056946f03
6 changed files with 159 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ export function TitleCardHorizontal({ title }: { title: Title }) {
|
||||||
borderRadius: 8
|
borderRadius: 8
|
||||||
}}>
|
}}>
|
||||||
{title.poster?.image_path && (
|
{title.poster?.image_path && (
|
||||||
<img src={title.poster.image_path} width={80} />
|
<img src={"media/" + title.poster.image_path} width={80} />
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<h3>{title.title_names["en"]}</h3>
|
<h3>{title.title_names["en"]}</h3>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export function TitleCardSquare({ title }: { title: Title }) {
|
||||||
textAlign: "center"
|
textAlign: "center"
|
||||||
}}>
|
}}>
|
||||||
{title.poster?.image_path && (
|
{title.poster?.image_path && (
|
||||||
<img src={title.poster.image_path} width={140} />
|
<img src={"media/" + title.poster.image_path} width={140} />
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<h4>{title.title_names["en"]}</h4>
|
<h4>{title.title_names["en"]}</h4>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export function UserTitleCardHorizontal({ title }: { title: UserTitle }) {
|
||||||
borderRadius: 8
|
borderRadius: 8
|
||||||
}}>
|
}}>
|
||||||
{title.title?.poster?.image_path && (
|
{title.title?.poster?.image_path && (
|
||||||
<img src={title.title?.poster.image_path} width={80} />
|
<img src={"media/" + title.title?.poster.image_path} width={80} />
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<h3>{title.title?.title_names["en"]}</h3>
|
<h3>{title.title?.title_names["en"]}</h3>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export function UserTitleCardSquare({ title }: { title: UserTitle }) {
|
||||||
textAlign: "center"
|
textAlign: "center"
|
||||||
}}>
|
}}>
|
||||||
{title.title?.poster?.image_path && (
|
{title.title?.poster?.image_path && (
|
||||||
<img src={title.title?.poster.image_path} width={140} />
|
<img src={"media/" + title.title?.poster.image_path} width={140} />
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<h4>{title.title?.title_names["en"]}</h4>
|
<h4>{title.title?.title_names["en"]}</h4>
|
||||||
|
|
|
||||||
154
modules/frontend/src/pages/SettingsPage/SettingsPage.tsx
Normal file
154
modules/frontend/src/pages/SettingsPage/SettingsPage.tsx
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
// import React, { useEffect, useState } from "react";
|
||||||
|
// import { updateUser, getUsersId } from "../../api";
|
||||||
|
// import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
// export const SettingsPage: React.FC = () => {
|
||||||
|
// const navigate = useNavigate();
|
||||||
|
|
||||||
|
// const userId = Number(localStorage.getItem("user_id"));
|
||||||
|
// const initialNickname = localStorage.getItem("user_name") || "";
|
||||||
|
// const [mail, setMail] = useState("");
|
||||||
|
// const [nickname, setNickname] = useState(initialNickname);
|
||||||
|
// const [dispName, setDispName] = useState("");
|
||||||
|
// const [userDesc, setUserDesc] = useState("");
|
||||||
|
// const [avatarId, setAvatarId] = useState<number | null>(null);
|
||||||
|
|
||||||
|
// const [loading, setLoading] = useState(false);
|
||||||
|
// const [success, setSuccess] = useState<string | null>(null);
|
||||||
|
// const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const fetch = async () => {
|
||||||
|
// const res = await getUsersId({
|
||||||
|
// path: { user_id: String(userId) },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// setProfile(res.data);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// fetch();
|
||||||
|
// }, [userId]);
|
||||||
|
|
||||||
|
// const saveSettings = async (e: React.FormEvent) => {
|
||||||
|
// e.preventDefault();
|
||||||
|
// setLoading(true);
|
||||||
|
// setSuccess(null);
|
||||||
|
// setError(null);
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// const res = await updateUser({
|
||||||
|
// path: { user_id: userId },
|
||||||
|
// body: {
|
||||||
|
// ...(mail ? { mail } : {}),
|
||||||
|
// ...(nickname ? { nickname } : {}),
|
||||||
|
// ...(dispName ? { disp_name: dispName } : {}),
|
||||||
|
// ...(userDesc ? { user_desc: userDesc } : {}),
|
||||||
|
// ...(avatarId !== undefined ? { avatar_id: avatarId } : {}),
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Обновляем локальное отображение username
|
||||||
|
// if (nickname) {
|
||||||
|
// localStorage.setItem("user_name", nickname);
|
||||||
|
// window.dispatchEvent(new Event("storage")); // чтобы Header обновился
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setSuccess("Settings updated!");
|
||||||
|
// setTimeout(() => navigate("/profile"), 800);
|
||||||
|
|
||||||
|
// } catch (err: any) {
|
||||||
|
// console.error(err);
|
||||||
|
// setError(err?.message || "Failed to update settings");
|
||||||
|
// } finally {
|
||||||
|
// setLoading(false);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// <div className="max-w-2xl mx-auto p-6">
|
||||||
|
// <h1 className="text-3xl font-bold mb-6">User Settings</h1>
|
||||||
|
|
||||||
|
// {success && <div className="text-green-600 mb-4">{success}</div>}
|
||||||
|
// {error && <div className="text-red-600 mb-4">{error}</div>}
|
||||||
|
|
||||||
|
// <form className="space-y-6" onSubmit={saveSettings}>
|
||||||
|
// {/* Email */}
|
||||||
|
// <div>
|
||||||
|
// <label className="block text-sm font-medium mb-1">Email</label>
|
||||||
|
// <input
|
||||||
|
// type="email"
|
||||||
|
// value={mail}
|
||||||
|
// onChange={(e) => setMail(e.target.value)}
|
||||||
|
// placeholder="example@mail.com"
|
||||||
|
// className="w-full px-4 py-2 border rounded-lg"
|
||||||
|
// />
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// {/* Nickname */}
|
||||||
|
// <div>
|
||||||
|
// <label className="block text-sm font-medium mb-1">Nickname</label>
|
||||||
|
// <input
|
||||||
|
// type="text"
|
||||||
|
// value={nickname}
|
||||||
|
// onChange={(e) => setNickname(e.target.value)}
|
||||||
|
// className="w-full px-4 py-2 border rounded-lg"
|
||||||
|
// />
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// {/* Display name */}
|
||||||
|
// <div>
|
||||||
|
// <label className="block text-sm font-medium mb-1">Display name</label>
|
||||||
|
// <input
|
||||||
|
// type="text"
|
||||||
|
// value={dispName}
|
||||||
|
// onChange={(e) => setDispName(e.target.value)}
|
||||||
|
// placeholder="Shown name"
|
||||||
|
// className="w-full px-4 py-2 border rounded-lg"
|
||||||
|
// />
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// {/* Bio */}
|
||||||
|
// <div>
|
||||||
|
// <label className="block text-sm font-medium mb-1">Bio</label>
|
||||||
|
// <textarea
|
||||||
|
// value={userDesc}
|
||||||
|
// onChange={(e) => setUserDesc(e.target.value)}
|
||||||
|
// rows={4}
|
||||||
|
// className="w-full px-4 py-2 border rounded-lg resize-none"
|
||||||
|
// />
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// {/* Avatar ID */}
|
||||||
|
// <div>
|
||||||
|
// <label className="block text-sm font-medium mb-1">Avatar ID</label>
|
||||||
|
// <input
|
||||||
|
// type="number"
|
||||||
|
// value={avatarId ?? ""}
|
||||||
|
// onChange={(e) => {
|
||||||
|
// const v = e.target.value;
|
||||||
|
// setAvatarId(v === "" ? null : Number(v));
|
||||||
|
// }}
|
||||||
|
// placeholder="Image ID"
|
||||||
|
// className="w-full px-4 py-2 border rounded-lg"
|
||||||
|
// />
|
||||||
|
|
||||||
|
// <button
|
||||||
|
// type="button"
|
||||||
|
// onClick={() => setAvatarId(null)}
|
||||||
|
// className="text-sm text-blue-600 mt-1 hover:underline"
|
||||||
|
// >
|
||||||
|
// Remove avatar
|
||||||
|
// </button>
|
||||||
|
// </div>
|
||||||
|
|
||||||
|
// <button
|
||||||
|
// type="submit"
|
||||||
|
// disabled={loading}
|
||||||
|
// className="w-full bg-blue-600 text-white py-2 rounded-lg font-semibold hover:bg-blue-700 disabled:opacity-50"
|
||||||
|
// >
|
||||||
|
// {loading ? "Saving..." : "Save changes"}
|
||||||
|
// </button>
|
||||||
|
// </form>
|
||||||
|
// </div>
|
||||||
|
// );
|
||||||
|
// };
|
||||||
|
|
@ -46,7 +46,7 @@ export default function TitlePage() {
|
||||||
{/* Poster + status buttons */}
|
{/* Poster + status buttons */}
|
||||||
<div className="flex flex-col items-center">
|
<div className="flex flex-col items-center">
|
||||||
<img
|
<img
|
||||||
src={title.poster?.image_path || "/default-poster.png"}
|
src={"media/" + title.poster?.image_path || "/default-poster.png"}
|
||||||
alt={title.title_names?.en?.[0] || "Title poster"}
|
alt={title.title_names?.en?.[0] || "Title poster"}
|
||||||
className="w-48 h-72 object-cover rounded-lg mb-4"
|
className="w-48 h-72 object-cover rounded-lg mb-4"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue