Compare commits

...

2 Commits

Author SHA1 Message Date
c72ce9baa4 feat: avatars 2025-05-12 16:16:26 +03:00
ac1b7338f8 feat: nice isLoading view 2025-05-12 15:59:16 +03:00
11 changed files with 262 additions and 234 deletions

BIN
src/assets/status/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 KiB

BIN
src/assets/status/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
src/assets/status/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 KiB

BIN
src/assets/status/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
src/assets/status/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 KiB

View File

@@ -1,12 +1,13 @@
import { useAppContext } from "@/providers/AuthProvider";
import apiClient from "@/services/api";
import { getAvatarPicUrl } from "@/services/avatar-pic";
import { cn } from "@/utils/class-merge"; import { cn } from "@/utils/class-merge";
import { CalendarDaysIcon, ListBulletIcon, UserIcon } from "@heroicons/react/24/solid"; import { CalendarDaysIcon, ListBulletIcon, UserIcon } from "@heroicons/react/24/solid";
import { FunctionComponent, h } from "preact"; import { FunctionComponent, h } from "preact";
import { useLocation } from "preact-iso"; import { useLocation } from "preact-iso";
import { useEffect, useState } from "preact/hooks";
import { tv } from "tailwind-variants"; import { tv } from "tailwind-variants";
import classes from "./menu.module.scss"; import classes from "./menu.module.scss";
import { useEffect, useState } from "preact/hooks";
import apiClient from "@/services/api";
import { useAppContext } from "@/providers/AuthProvider";
interface UserProfile { interface UserProfile {
username: string; username: string;
@@ -72,7 +73,7 @@ const Avatar: FunctionComponent = () => {
} }
}, [isLoggedIn.value]); }, [isLoggedIn.value]);
return ( return username ? (
<button <button
onClick={() => route("/profile/settings")} onClick={() => route("/profile/settings")}
class={cn("hidden h-32 w-full cursor-pointer overflow-hidden opacity-100 transition-[height,opacity] md:block", { class={cn("hidden h-32 w-full cursor-pointer overflow-hidden opacity-100 transition-[height,opacity] md:block", {
@@ -84,14 +85,16 @@ const Avatar: FunctionComponent = () => {
"h-full flex-row items-center justify-around rounded-[3rem] bg-[linear-gradient(180.00deg,rgba(249,134,143,0.5)_3.053%,rgb(228,242,252)_96.183%)] px-5 py-5 md:flex" "h-full flex-row items-center justify-around rounded-[3rem] bg-[linear-gradient(180.00deg,rgba(249,134,143,0.5)_3.053%,rgb(228,242,252)_96.183%)] px-5 py-5 md:flex"
)} )}
> >
<div class="my-5 aspect-square h-full rounded-full bg-white"></div> <div class="my-5 aspect-square h-full rounded-full">
<img class="size-full rounded-full" src={getAvatarPicUrl(status)} alt="avatar" />
</div>
<div class="flex flex-col items-center justify-center"> <div class="flex flex-col items-center justify-center">
<p class="text-3xl font-semibold">{username}</p> <p class="text-3xl font-semibold">{username}</p>
<div class="rounded-[1rem] bg-white px-5 leading-5 font-light italic">{status}</div> <div class="rounded-[1rem] bg-white px-5 leading-5 font-light italic">{status}</div>
</div> </div>
</div> </div>
</button> </button>
); ) : null;
}; };
interface MenuItems { interface MenuItems {

View File

@@ -374,15 +374,15 @@ const ProfileCalendar: FunctionComponent = () => {
month: { className: calendarStyles.month }, month: { className: calendarStyles.month },
year: { className: calendarStyles.year }, year: { className: calendarStyles.year },
}; };
if (isLoading)
return (
<div class="flex h-full w-full flex-1 flex-col items-center justify-center">
<div class="flex w-full flex-1 items-center justify-center">Загрузка...</div>;
</div>
);
return ( return (
<div class="flex w-full flex-col items-center"> <div class="flex w-full flex-col items-center">
{isLoading ? (
<div class="flex w-full flex-1 items-center justify-center">
<div class="text-2xl">Загрузка...</div>
</div>
) : (
<>
<ModalTags <ModalTags
refreshTags={fetchTags} refreshTags={fetchTags}
isOpen={openModalTags} isOpen={openModalTags}
@@ -492,12 +492,9 @@ const ProfileCalendar: FunctionComponent = () => {
{errors.subject && <p class="text-red-500">{errors.subject.message}</p>} {errors.subject && <p class="text-red-500">{errors.subject.message}</p>}
<div class="flex flex-col items-center gap-6 self-center md:flex-row md:justify-start md:self-start"> <div class="flex flex-col items-center gap-6 self-center md:flex-row md:justify-start md:self-start">
<div <div
class={cn( class={cn("flex h-full flex-row items-center gap-1 rounded-2xl bg-[rgba(251,194,199,0.38)] px-2 py-1", {
"flex h-full flex-row items-center gap-1 rounded-2xl bg-[rgba(251,194,199,0.38)] px-2 py-1",
{
"cursor-pointer": isEditModal, "cursor-pointer": isEditModal,
} })}
)}
onClick={() => { onClick={() => {
if (!isEditModal) return; if (!isEditModal) return;
setOpenModalCalendar(true); setOpenModalCalendar(true);
@@ -516,12 +513,9 @@ const ProfileCalendar: FunctionComponent = () => {
</p> </p>
</div> </div>
<div <div
class={cn( class={cn("flex h-full flex-col items-start gap-1 rounded-2xl bg-[rgba(251,194,199,0.38)] px-4 py-2", {
"flex h-full flex-col items-start gap-1 rounded-2xl bg-[rgba(251,194,199,0.38)] px-4 py-2",
{
"cursor-pointer": isEditModal, "cursor-pointer": isEditModal,
} })}
)}
onClick={() => { onClick={() => {
if (!isEditModal) return; if (!isEditModal) return;
setTags({ first: editContent.subject.id, second: editContent.taskType.id, overdue: false }); setTags({ first: editContent.subject.id, second: editContent.taskType.id, overdue: false });
@@ -589,8 +583,6 @@ const ProfileCalendar: FunctionComponent = () => {
<div class="rounded-lg bg-[rgba(251,194,199,0.2)] p-4 text-center">На этот день задач нет</div> <div class="rounded-lg bg-[rgba(251,194,199,0.2)] p-4 text-center">На этот день задач нет</div>
)} )}
</div> </div>
</>
)}
</div> </div>
); );
}; };

View File

@@ -5,7 +5,7 @@
} }
#avatar { #avatar {
@apply flex aspect-square h-[7rem] flex-col items-center justify-center rounded-full bg-white; @apply flex aspect-square h-[7rem] flex-col items-center justify-center rounded-full;
} }
.profile_container { .profile_container {

View File

@@ -4,6 +4,7 @@ import { withTitle } from "@/constructors/Component";
import { UrlsTitle } from "@/enums/urls"; import { UrlsTitle } from "@/enums/urls";
import { useAppContext } from "@/providers/AuthProvider"; import { useAppContext } from "@/providers/AuthProvider";
import apiClient from "@/services/api"; import apiClient from "@/services/api";
import { getAvatarPicUrl } from "@/services/avatar-pic";
import { cn } from "@/utils/class-merge"; import { cn } from "@/utils/class-merge";
import { ArrowRightStartOnRectangleIcon, Cog8ToothIcon } from "@heroicons/react/24/outline"; import { ArrowRightStartOnRectangleIcon, Cog8ToothIcon } from "@heroicons/react/24/outline";
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
@@ -62,11 +63,19 @@ const ProfileSettings: FunctionComponent = () => {
console.error("Logout failed:", error); console.error("Logout failed:", error);
} }
}; };
if (!userData.username)
return (
<div class="flex h-full w-full flex-1 flex-col items-center justify-center">
<div class="flex w-full flex-1 items-center justify-center">Загрузка...</div>;
</div>
);
return ( return (
<div class={classes.container}> <div class={classes.container}>
<ModalSettings isOpen={isSettingsOpen} setIsOpen={setIsSettingsOpen} onClose={fetchUserData} /> <ModalSettings isOpen={isSettingsOpen} setIsOpen={setIsSettingsOpen} onClose={fetchUserData} />
<div class="flex w-full flex-col items-center rounded-[4rem] bg-[linear-gradient(180.00deg,rgb(251,194,199),rgba(206,232,251,0.72)_100%)] px-7 py-5 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] md:flex-row"> <div class="flex w-full flex-col items-center rounded-[4rem] bg-[linear-gradient(180.00deg,rgb(251,194,199),rgba(206,232,251,0.72)_100%)] px-7 py-5 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] md:flex-row">
<div id={classes.avatar}>"Аватар"</div> <div id={classes.avatar}>
<img class="size-28 rounded-full" src={getAvatarPicUrl(userData.status)} alt="avatar" />
</div>
<div class={classes.header_block__name}> <div class={classes.header_block__name}>
<p class="text-4xl font-semibold">{userData.username}</p> <p class="text-4xl font-semibold">{userData.username}</p>
<p class="text-2xl font-light">{userData.status}</p> <p class="text-2xl font-light">{userData.status}</p>
@@ -100,4 +109,6 @@ const ProfileSettings: FunctionComponent = () => {
); );
}; };
ProfileSettings.displayName = "ProfileSettings";
export default withTitle(UrlsTitle.PROFILE, ProfileSettings); export default withTitle(UrlsTitle.PROFILE, ProfileSettings);

View File

@@ -385,13 +385,15 @@ const ProfileTasks: FunctionComponent = () => {
} }
}; };
if (isLoading)
return (
<div class="flex h-full w-full flex-1 flex-col items-center justify-center">
<div class="flex w-full flex-1 items-center justify-center">Загрузка...</div>;
</div>
);
return ( return (
<div class={classes.container}> <div class={classes.container}>
{isLoading ? (
<div class="flex w-full flex-1 items-center justify-center">
<div class="text-2xl">Загрузка...</div>
</div>
) : (
<ModalTags <ModalTags
refreshTags={fetchTags} refreshTags={fetchTags}
zIndex={70} zIndex={70}
@@ -404,7 +406,6 @@ const ProfileTasks: FunctionComponent = () => {
}} }}
onChange={setTags} onChange={setTags}
/> />
)}
<ModalCalendar <ModalCalendar
zIndex={80} zIndex={80}
isOpen={openModalCalendar} isOpen={openModalCalendar}

View File

@@ -0,0 +1,21 @@
import Status1 from "@/assets/status/1.png";
import Status2 from "@/assets/status/2.png";
import Status3 from "@/assets/status/3.png";
import Status4 from "@/assets/status/4.png";
import Status5 from "@/assets/status/5.png";
export const getAvatarPicUrl = (status: string) => {
switch (true) {
case status.includes("точно"):
return Status1;
case status.includes("плана нет"):
return Status2;
case status.includes("прокрастинации"):
return Status3;
case status.includes("3000"):
return Status4;
case status.includes("планирования"):
return Status5;
default:
return Status1;
}
};