10 Commits

12 changed files with 251 additions and 93 deletions

View File

@@ -18,7 +18,7 @@
"react-hook-form": "^7.56.1", "react-hook-form": "^7.56.1",
"tailwind-merge": "^3.0.2", "tailwind-merge": "^3.0.2",
"tailwind-variants": "^1.0.0", "tailwind-variants": "^1.0.0",
"tailwindcss": "^4.0.17", "tailwindcss": "^4.1.5",
"uuid": "^11.1.0", "uuid": "^11.1.0",
}, },
"devDependencies": { "devDependencies": {
@@ -713,7 +713,7 @@
"tailwind-variants": ["tailwind-variants@1.0.0", "", { "dependencies": { "tailwind-merge": "3.0.2" }, "peerDependencies": { "tailwindcss": "*" } }, "sha512-2WSbv4ulEEyuBKomOunut65D8UZwxrHoRfYnxGcQNnHqlSCp2+B7Yz2W+yrNDrxRodOXtGD/1oCcKGNBnUqMqA=="], "tailwind-variants": ["tailwind-variants@1.0.0", "", { "dependencies": { "tailwind-merge": "3.0.2" }, "peerDependencies": { "tailwindcss": "*" } }, "sha512-2WSbv4ulEEyuBKomOunut65D8UZwxrHoRfYnxGcQNnHqlSCp2+B7Yz2W+yrNDrxRodOXtGD/1oCcKGNBnUqMqA=="],
"tailwindcss": ["tailwindcss@4.0.17", "", {}, "sha512-OErSiGzRa6rLiOvaipsDZvLMSpsBZ4ysB4f0VKGXUrjw2jfkJRd6kjRKV2+ZmTCNvwtvgdDam5D7w6WXsdLJZw=="], "tailwindcss": ["tailwindcss@4.1.5", "", {}, "sha512-nYtSPfWGDiWgCkwQG/m+aX83XCwf62sBgg3bIlNiiOcggnS1x3uVRDAuyelBFL+vJdOPPCGElxv9DjHJjRHiVA=="],
"tapable": ["tapable@2.2.1", "", {}, "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ=="], "tapable": ["tapable@2.2.1", "", {}, "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ=="],
@@ -767,6 +767,12 @@
"@humanfs/node/@humanwhocodes/retry": ["@humanwhocodes/retry@0.3.1", "", {}, "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA=="], "@humanfs/node/@humanwhocodes/retry": ["@humanwhocodes/retry@0.3.1", "", {}, "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA=="],
"@tailwindcss/node/tailwindcss": ["tailwindcss@4.0.17", "", {}, "sha512-OErSiGzRa6rLiOvaipsDZvLMSpsBZ4ysB4f0VKGXUrjw2jfkJRd6kjRKV2+ZmTCNvwtvgdDam5D7w6WXsdLJZw=="],
"@tailwindcss/postcss/tailwindcss": ["tailwindcss@4.0.17", "", {}, "sha512-OErSiGzRa6rLiOvaipsDZvLMSpsBZ4ysB4f0VKGXUrjw2jfkJRd6kjRKV2+ZmTCNvwtvgdDam5D7w6WXsdLJZw=="],
"@tailwindcss/vite/tailwindcss": ["tailwindcss@4.0.17", "", {}, "sha512-OErSiGzRa6rLiOvaipsDZvLMSpsBZ4ysB4f0VKGXUrjw2jfkJRd6kjRKV2+ZmTCNvwtvgdDam5D7w6WXsdLJZw=="],
"@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="], "@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
"@typescript-eslint/typescript-estree/semver": ["semver@7.7.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA=="], "@typescript-eslint/typescript-estree/semver": ["semver@7.7.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA=="],

View File

@@ -23,7 +23,7 @@
"react-hook-form": "^7.56.1", "react-hook-form": "^7.56.1",
"tailwind-merge": "^3.0.2", "tailwind-merge": "^3.0.2",
"tailwind-variants": "^1.0.0", "tailwind-variants": "^1.0.0",
"tailwindcss": "^4.0.17", "tailwindcss": "^4.1.5",
"uuid": "^11.1.0" "uuid": "^11.1.0"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1,13 +1,13 @@
import { cn } from "@/utils/class-merge"; import { cn } from "@/utils/class-merge";
import { ClockIcon } from "@heroicons/react/24/outline"; import { ClockIcon } from "@heroicons/react/24/outline";
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
import { Dispatch, StateUpdater, useState } from "preact/hooks"; import { Dispatch, StateUpdater, useEffect, useState } from "preact/hooks";
import { Calendar, CalendarPassThroughMethodOptions } from "primereact/calendar"; import { Calendar, CalendarPassThroughMethodOptions } from "primereact/calendar";
import { FormEvent } from "primereact/ts-helpers"; import { FormEvent } from "primereact/ts-helpers";
import Button from "./ui/Button"; import Button from "./ui/Button";
import ModalWindow from "./ui/Modal"; import ModalWindow, { ModalWindowProps } from "./ui/Modal";
interface ModalCalendarProps { interface ModalCalendarProps extends ModalWindowProps {
isOpen?: boolean; isOpen?: boolean;
setIsOpen?: Dispatch<StateUpdater<boolean>>; setIsOpen?: Dispatch<StateUpdater<boolean>>;
onClose?: () => void; onClose?: () => void;
@@ -27,10 +27,25 @@ const TRANSITIONS = {
}, },
}; };
const ModalCalendar: FunctionComponent<ModalCalendarProps> = ({ isOpen, setIsOpen, onClose, onChange, value }) => { const ModalCalendar: FunctionComponent<ModalCalendarProps> = ({
isOpen,
setIsOpen,
onClose,
onChange,
value,
...rest
}) => {
const [showTime, setShowTime] = useState(false); const [showTime, setShowTime] = useState(false);
const [minDate, setMinDate] = useState(new Date());
useEffect(() => {
const interval = setInterval(() => {
setMinDate(new Date());
}, 1000);
return () => clearInterval(interval);
}, []);
return ( return (
<ModalWindow <ModalWindow
{...rest}
isOpen={isOpen} isOpen={isOpen}
setIsOpen={setIsOpen} setIsOpen={setIsOpen}
onClose={() => { onClose={() => {
@@ -38,7 +53,6 @@ const ModalCalendar: FunctionComponent<ModalCalendarProps> = ({ isOpen, setIsOpe
setShowTime(false); setShowTime(false);
}} }}
className="md:h-[40rem] md:w-[30rem]" className="md:h-[40rem] md:w-[30rem]"
zIndex={60}
> >
<div class="w-full flex-1 self-start"> <div class="w-full flex-1 self-start">
<Calendar <Calendar
@@ -46,6 +60,7 @@ const ModalCalendar: FunctionComponent<ModalCalendarProps> = ({ isOpen, setIsOpe
onChange={onChange} onChange={onChange}
value={value} value={value}
hourFormat="24" hourFormat="24"
minDate={minDate}
showTime={showTime} showTime={showTime}
pt={{ pt={{
root: ({ props }: CalendarPassThroughMethodOptions) => ({ root: ({ props }: CalendarPassThroughMethodOptions) => ({

View File

@@ -3,14 +3,15 @@ import { BookOpenIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
import { Dispatch, StateUpdater, useEffect, useState } from "preact/hooks"; import { Dispatch, StateUpdater, useEffect, useState } from "preact/hooks";
import Button from "./ui/Button"; import Button from "./ui/Button";
import ModalWindow from "./ui/Modal"; import ModalWindow, { ModalWindowProps } from "./ui/Modal";
export interface ITags { export interface ITags {
first: string; first: string;
second: string; second: string;
overdue: boolean;
} }
interface ModalTagsProps { interface ModalTagsProps extends ModalWindowProps {
isOpen?: boolean; isOpen?: boolean;
setIsOpen?: Dispatch<StateUpdater<boolean>>; setIsOpen?: Dispatch<StateUpdater<boolean>>;
onClose?: () => void; onClose?: () => void;
@@ -22,7 +23,15 @@ interface ModalTagsProps {
}; };
} }
const ModalTags: FunctionComponent<ModalTagsProps> = ({ isOpen, setIsOpen, onClose, onChange, value, tagsList }) => { const ModalTags: FunctionComponent<ModalTagsProps> = ({
isOpen,
setIsOpen,
onClose,
onChange,
value,
tagsList,
...rest
}) => {
const [showFirstTags, setShowFirstTags] = useState(false); const [showFirstTags, setShowFirstTags] = useState(false);
const [showSecondTags, setShowSecondTags] = useState(false); const [showSecondTags, setShowSecondTags] = useState(false);
useEffect(() => { useEffect(() => {
@@ -34,6 +43,7 @@ const ModalTags: FunctionComponent<ModalTagsProps> = ({ isOpen, setIsOpen, onClo
return ( return (
<ModalWindow <ModalWindow
isOpen={isOpen} isOpen={isOpen}
{...rest}
setIsOpen={setIsOpen} setIsOpen={setIsOpen}
onClose={() => { onClose={() => {
onClose!(); onClose!();

View File

@@ -1,5 +1,5 @@
@reference "../index.scss"; @reference "../index.scss";
.task { .task {
@apply flex h-24 w-full cursor-pointer flex-row items-center justify-start gap-4 rounded-[3rem] bg-[rgba(251,194,199,0.53)] px-5 py-6 text-xl shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] transition-transform hover:scale-[1.05] hover:bg-[rgba(251,194,199,0.7)] active:scale-[1.05] md:w-[500px]; @apply relative flex h-24 w-full cursor-pointer flex-row items-center justify-start gap-4 rounded-[3rem] bg-[rgba(251,194,199,0.53)] px-5 py-6 text-xl shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] transition-transform hover:scale-[1.05] hover:bg-[rgba(251,194,199,0.7)] active:scale-[1.05] md:w-[500px];
} }

View File

@@ -6,6 +6,7 @@ import classes from "./task.module.scss";
interface TaskProps { interface TaskProps {
name: string; name: string;
checked?: boolean; checked?: boolean;
overdue?: boolean;
onClick?: () => void; onClick?: () => void;
onMarkClick?: MouseEventHandler<HTMLParagraphElement>; onMarkClick?: MouseEventHandler<HTMLParagraphElement>;
} }
@@ -30,7 +31,13 @@ const markStyle = tv({
}, },
}); });
const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {}, onMarkClick = () => {} }) => { const Task: FunctionComponent<TaskProps> = ({
name,
checked = false,
onClick = () => {},
onMarkClick = () => {},
overdue,
}) => {
return ( return (
<div class="w-[95%]"> <div class="w-[95%]">
<div class={classes.task} onClick={onClick}> <div class={classes.task} onClick={onClick}>
@@ -44,6 +51,7 @@ const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = (
<p class={markStyle({ checked })}></p> <p class={markStyle({ checked })}></p>
</div> </div>
{name} {name}
{overdue && <span class="absolute top-2 right-16 text-xs text-red-500">Просрочено</span>}
</div> </div>
</div> </div>
); );

View File

@@ -23,15 +23,12 @@ const Dialog: FunctionComponent<DialogProps> = ({
if (!isOpen) return null; if (!isOpen) return null;
return ( return (
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"> <div class="fixed inset-0 z-150 flex items-center justify-center bg-black/50">
<div class="w-full max-w-md rounded-[4rem] bg-white p-6 shadow-lg"> <div class="w-full max-w-md rounded-[4rem] bg-white p-6 shadow-lg">
<h2 class="mb-4 text-xl font-semibold">{title}</h2> <h2 class="mb-4 text-xl font-semibold">{title}</h2>
<p class="mb-6">{content}</p> <p class="mb-6 text-sm sm:text-[1rem]">{content}</p>
<div class="flex justify-end gap-4"> <div class="flex justify-end gap-4">
<Button <Button onClick={() => setIsOpen(false)} className="bg-gray-200 text-gray-800 hover:bg-gray-300">
onClick={() => setIsOpen(false)}
className="bg-gray-200 text-gray-800 hover:bg-gray-300"
>
{cancelText} {cancelText}
</Button> </Button>
<Button <Button
@@ -49,4 +46,4 @@ const Dialog: FunctionComponent<DialogProps> = ({
); );
}; };
export default Dialog; export default Dialog;

View File

@@ -2,7 +2,7 @@ import { cn } from "@/utils/class-merge";
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
import { Dispatch, StateUpdater, useEffect } from "preact/hooks"; import { Dispatch, StateUpdater, useEffect } from "preact/hooks";
interface ModalWindowProps { export interface ModalWindowProps {
isOpen?: boolean; isOpen?: boolean;
setIsOpen?: Dispatch<StateUpdater<boolean>>; setIsOpen?: Dispatch<StateUpdater<boolean>>;
onClose?: () => void; onClose?: () => void;

View File

@@ -1,26 +1,25 @@
import { withTitle } from "@/constructors/Component";
import { UrlsTitle } from "@/enums/urls";
import { FunctionComponent } from "preact";
import { useState, useEffect } from "preact/hooks";
import { Calendar, CalendarDateTemplateEvent } from "primereact/calendar";
import { cn } from "@/utils/class-merge";
import { ITask } from "./profile_tasks.dto";
import Task from "@/components/task";
import ModalWindow from "@/components/ui/Modal";
import ModalCalendar from "@/components/ModalCalendar"; import ModalCalendar from "@/components/ModalCalendar";
import ModalTags, { ITags } from "@/components/ModalTags"; import ModalTags, { ITags } from "@/components/ModalTags";
import { useForm } from "react-hook-form"; import Task from "@/components/task";
import { ITaskForm } from "./profile_tasks.dto"; import Dialog from "@/components/ui/Dialog";
import { Nullable } from "primereact/ts-helpers"; import ModalWindow from "@/components/ui/Modal";
import { withTitle } from "@/constructors/Component";
import { UrlsTitle } from "@/enums/urls";
import { cn } from "@/utils/class-merge";
import { import {
PencilIcon,
InboxArrowDownIcon,
CalendarDaysIcon,
BookOpenIcon, BookOpenIcon,
CalendarDaysIcon,
DocumentDuplicateIcon, DocumentDuplicateIcon,
InboxArrowDownIcon,
PencilIcon,
TrashIcon, TrashIcon,
} from "@heroicons/react/24/outline"; } from "@heroicons/react/24/outline";
import Dialog from "@/components/ui/Dialog"; import { FunctionComponent } from "preact";
import { useEffect, useState } from "preact/hooks";
import { Calendar, CalendarDateTemplateEvent } from "primereact/calendar";
import { Nullable } from "primereact/ts-helpers";
import { useForm } from "react-hook-form";
import { ITask, ITaskForm } from "./profile_tasks.dto";
const example_tags: { first: string[]; second: string[] } = { const example_tags: { first: string[]; second: string[] } = {
first: ["Программирование", "Информатика", "Физика", "Математика"], first: ["Программирование", "Информатика", "Физика", "Математика"],
@@ -58,10 +57,9 @@ const ProfileCalendar: FunctionComponent = () => {
const [isEditModal, setIsEditModal] = useState(false); const [isEditModal, setIsEditModal] = useState(false);
const [editContent, setEditContent] = useState<ITask | null>(null); const [editContent, setEditContent] = useState<ITask | null>(null);
const [calendarDate, setCalendarDate] = useState<Nullable<Date>>(); const [calendarDate, setCalendarDate] = useState<Nullable<Date>>();
const [tags, setTags] = useState<ITags>({ first: "", second: "" }); const [tags, setTags] = useState<ITags>({ first: "", second: "", overdue: false });
const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const { const {
handleSubmit, handleSubmit,
register, register,
@@ -123,6 +121,15 @@ const ProfileCalendar: FunctionComponent = () => {
setEditContent(newEditContent); setEditContent(newEditContent);
}, [tags]); }, [tags]);
const tasksCount = (date: CalendarDateTemplateEvent) => {
return tasks.filter((task) => {
const taskDate = task.date;
return (
taskDate.getDate() === date.day && taskDate.getMonth() === date.month && taskDate.getFullYear() === date.year
);
}).length;
};
const hasTasksOnDate = (date: CalendarDateTemplateEvent) => { const hasTasksOnDate = (date: CalendarDateTemplateEvent) => {
return tasks.some((task) => { return tasks.some((task) => {
const taskDate = task.date; const taskDate = task.date;
@@ -134,6 +141,7 @@ const ProfileCalendar: FunctionComponent = () => {
const dateTemplate = (date: CalendarDateTemplateEvent) => { const dateTemplate = (date: CalendarDateTemplateEvent) => {
const isHighlighted = hasTasksOnDate(date); const isHighlighted = hasTasksOnDate(date);
const countT = tasksCount(date);
const isSelected = const isSelected =
currentDate && currentDate &&
currentDate.getDate() === date.day && currentDate.getDate() === date.day &&
@@ -143,7 +151,6 @@ const ProfileCalendar: FunctionComponent = () => {
new Date().getDate() === date.day && new Date().getDate() === date.day &&
new Date().getMonth() === date.month && new Date().getMonth() === date.month &&
new Date().getFullYear() === date.year; new Date().getFullYear() === date.year;
return ( return (
<div <div
className={cn( className={cn(
@@ -156,7 +163,14 @@ const ProfileCalendar: FunctionComponent = () => {
)} )}
> >
<span>{date.day}</span> <span>{date.day}</span>
{isHighlighted && <span className="absolute top-2 right-2 h-2 w-2 rounded-full bg-pink-400" />} {isHighlighted && (
<div class="absolute top-2 right-2 flex h-fit w-2 flex-col items-center gap-1 md:h-2 md:w-fit md:flex-row">
{Array.from({ length: countT > 3 ? 3 : countT }).map((_, i) => (
<span key={i} className="size-2 rounded-full bg-pink-400" />
))}
{countT > 3 && <span className="text-xs font-bold text-pink-400 select-none">+</span>}
</div>
)}
</div> </div>
); );
}; };
@@ -192,7 +206,7 @@ const ProfileCalendar: FunctionComponent = () => {
}; };
setTasks(tasks.map((task) => (task.id === eTask.id ? eTask : task))); setTasks(tasks.map((task) => (task.id === eTask.id ? eTask : task)));
localStorage.setItem("tasks", JSON.stringify(tasks.map((task) => (task.id === eTask.id ? eTask : task)))); localStorage.setItem("tasks", JSON.stringify(tasks.map((task) => (task.id === eTask.id ? eTask : task))));
setTags({ first: "", second: "" }); setTags({ first: "", second: "", overdue: false });
}; };
const pt = { const pt = {
@@ -222,7 +236,7 @@ const ProfileCalendar: FunctionComponent = () => {
tagsList={example_tags} tagsList={example_tags}
value={tags} value={tags}
onClose={() => { onClose={() => {
setTags({ first: "", second: "" }); setTags({ first: "", second: "", overdue: false });
}} }}
onChange={setTags} onChange={setTags}
/> />
@@ -242,7 +256,7 @@ const ProfileCalendar: FunctionComponent = () => {
setIsEdit(false); setIsEdit(false);
setEditContent(null); setEditContent(null);
setIsEditModal(false); setIsEditModal(false);
setTags({ first: "", second: "" }); setTags({ first: "", second: "", overdue: false });
setCalendarDate(null); setCalendarDate(null);
}} }}
> >
@@ -345,7 +359,7 @@ const ProfileCalendar: FunctionComponent = () => {
})} })}
onClick={() => { onClick={() => {
if (!isEditModal) return; if (!isEditModal) return;
setTags({ first: editContent.tags[0], second: editContent.tags[1] }); setTags({ first: editContent.tags[0], second: editContent.tags[1], overdue: false });
setOpenModalTags(true); setOpenModalTags(true);
}} }}
> >

View File

@@ -4,6 +4,7 @@ import { UrlsTitle } from "@/enums/urls";
import { useAppContext } from "@/providers/AuthProvider"; import { useAppContext } from "@/providers/AuthProvider";
import { cn } from "@/utils/class-merge"; import { cn } from "@/utils/class-merge";
import { calculatePoints, getCurrentStatus } from "@/utils/status-system"; import { calculatePoints, getCurrentStatus } from "@/utils/status-system";
import { ArrowRightStartOnRectangleIcon, Cog8ToothIcon } from "@heroicons/react/24/outline";
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
import { useLocation } from "preact-iso"; import { useLocation } from "preact-iso";
import { useEffect, useState } from "preact/hooks"; import { useEffect, useState } from "preact/hooks";
@@ -32,9 +33,9 @@ const ProfileSettings: FunctionComponent = () => {
updateStatus(); updateStatus();
} }
}; };
window.addEventListener('storage', handleStorage); window.addEventListener("storage", handleStorage);
return () => window.removeEventListener('storage', handleStorage); return () => window.removeEventListener("storage", handleStorage);
}, []); }, []);
return ( return (
@@ -58,17 +59,18 @@ const ProfileSettings: FunctionComponent = () => {
<div class={classes.profile_container}> <div class={classes.profile_container}>
<div class={classes.settings_block}> <div class={classes.settings_block}>
<div class={classes.settings_block__buttons}> <div class={classes.settings_block__buttons}>
<Button>Сменить тему</Button> <Button className="flex flex-row items-center justify-center gap-2">
<Button>Настройки</Button> <Cog8ToothIcon class="size-8" /> Настройки
</Button>
<Button <Button
color="secondary" className="flex flex-row items-center justify-center gap-2 bg-[linear-gradient(180.00deg,rgba(246,255,211,0.7),rgba(195,229,253,0.7)_100%)]"
onClick={() => { onClick={() => {
isLoggedIn.value = false; isLoggedIn.value = false;
localStorage.setItem("loggedIn", "false"); localStorage.setItem("loggedIn", "false");
route("/login", true); route("/login", true);
}} }}
> >
Выйти <ArrowRightStartOnRectangleIcon class="size-8" /> Выйти
</Button> </Button>
</div> </div>
</div> </div>

View File

@@ -5,7 +5,7 @@
} }
.header { .header {
@apply mb-3 w-full text-3xl font-semibold md:mb-12 md:text-5xl; @apply mb-3 flex w-full flex-row items-center justify-between text-xl font-semibold sm:text-3xl md:mb-12 md:text-5xl;
} }
.tasks_container { .tasks_container {

View File

@@ -1,3 +1,4 @@
//! Файл большой, потому что было лень делить на компоненты
import Task from "@/components/task"; import Task from "@/components/task";
import ModalCalendar from "@/components/ModalCalendar"; import ModalCalendar from "@/components/ModalCalendar";
@@ -23,6 +24,7 @@ import {
} from "@heroicons/react/24/outline"; } from "@heroicons/react/24/outline";
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
import { useEffect, useMemo, useRef, useState } from "preact/hooks"; import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { Checkbox, CheckboxPassThroughMethodOptions } from "primereact/checkbox";
import { Nullable } from "primereact/ts-helpers"; import { Nullable } from "primereact/ts-helpers";
import { SubmitHandler, useForm } from "react-hook-form"; import { SubmitHandler, useForm } from "react-hook-form";
import { v4 as uuid } from "uuid"; import { v4 as uuid } from "uuid";
@@ -45,10 +47,10 @@ const ProfileTasks: FunctionComponent = () => {
const [isCreating, setIsCreating] = useState(false); // Включено создание задачи const [isCreating, setIsCreating] = useState(false); // Включено создание задачи
const [editContent, setEditContent] = useState<ITask | null>(null); // Содержимое редактируемой задачи const [editContent, setEditContent] = useState<ITask | null>(null); // Содержимое редактируемой задачи
const [calendarDate, setCalendarDate] = useState<Nullable<Date>>(); // Выбранная в календаре дата const [calendarDate, setCalendarDate] = useState<Nullable<Date>>(); // Выбранная в календаре дата
const [tags, setTags] = useState<ITags>({ first: "", second: "" }); const [tags, setTags] = useState<ITags>({ first: "", second: "", overdue: false });
const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const [searchQuery, setSearchQuery] = useState(""); // Текст поиска const [searchQuery, setSearchQuery] = useState(""); // Текст поиска
const [filterTags, setFilterTags] = useState<ITags>({ first: "", second: "" }); const [filterTags, setFilterTags] = useState<ITags>({ first: "", second: "", overdue: false });
const [openFirstList, setOpenFirstList] = useState(false); const [openFirstList, setOpenFirstList] = useState(false);
const [openSecondList, setOpenSecondList] = useState(false); const [openSecondList, setOpenSecondList] = useState(false);
const getDate = useMemo(() => { const getDate = useMemo(() => {
@@ -98,7 +100,7 @@ const ProfileTasks: FunctionComponent = () => {
if (isCreating) setTasks([...tasks, eTask]); if (isCreating) setTasks([...tasks, eTask]);
else setTasks(tasks.map((task) => (task.id === eTask.id ? eTask : task))); else setTasks(tasks.map((task) => (task.id === eTask.id ? eTask : task)));
if (isCreating) setIsOpen(false); if (isCreating) setIsOpen(false);
setTags({ first: "", second: "" }); setTags({ first: "", second: "", overdue: false });
}; };
useEffect(() => { useEffect(() => {
if (editContent) reset({ ...editContent, date: editContent.date.toISOString().slice(0, 16) }); if (editContent) reset({ ...editContent, date: editContent.date.toISOString().slice(0, 16) });
@@ -200,6 +202,7 @@ const ProfileTasks: FunctionComponent = () => {
); );
} }
filtered = filtered.filter((task) => (filterTags.overdue ? task.date < new Date() : task.date >= new Date()));
return filtered; return filtered;
}, [tasks, searchQuery, filterTags]); }, [tasks, searchQuery, filterTags]);
@@ -211,16 +214,18 @@ const ProfileTasks: FunctionComponent = () => {
return ( return (
<div class={classes.container}> <div class={classes.container}>
<ModalTags <ModalTags
zIndex={70}
isOpen={openModalTags} isOpen={openModalTags}
setIsOpen={setOpenModalTags} setIsOpen={setOpenModalTags}
tagsList={example_tags} tagsList={example_tags}
value={tags} value={tags}
onClose={() => { onClose={() => {
if (!isCreating) setTags({ first: "", second: "" }); if (!isCreating) setTags({ first: "", second: "", overdue: false });
}} }}
onChange={setTags} onChange={setTags}
/> />
<ModalCalendar <ModalCalendar
zIndex={80}
isOpen={openModalCalendar} isOpen={openModalCalendar}
setIsOpen={setOpenModalCalendar} setIsOpen={setOpenModalCalendar}
onClose={() => { onClose={() => {
@@ -230,6 +235,7 @@ const ProfileTasks: FunctionComponent = () => {
value={calendarDate!} value={calendarDate!}
/> />
<ModalWindow <ModalWindow
zIndex={60}
isOpen={openModal} isOpen={openModal}
setIsOpen={setIsOpen} setIsOpen={setIsOpen}
onClose={() => { onClose={() => {
@@ -237,7 +243,7 @@ const ProfileTasks: FunctionComponent = () => {
setEditContent(null); setEditContent(null);
setIsCreating(false); setIsCreating(false);
setIsEditModal(false); setIsEditModal(false);
setTags({ first: "", second: "" }); setTags({ first: "", second: "", overdue: false });
setCalendarDate(null); setCalendarDate(null);
}} }}
> >
@@ -253,7 +259,9 @@ const ProfileTasks: FunctionComponent = () => {
<div class="flex w-full flex-row items-start justify-between"> <div class="flex w-full flex-row items-start justify-between">
<div class="flex flex-1 flex-col gap-1 pe-2"> <div class="flex flex-1 flex-col gap-1 pe-2">
<input <input
class="w-full text-2xl outline-0" class={cn("w-full p-2 text-2xl outline-0", {
"rounded-md bg-gray-400/30 ring-1 ring-gray-400": isEditModal,
})}
disabled={!isEditModal} disabled={!isEditModal}
placeholder="Название" placeholder="Название"
{...register("name", { {...register("name", {
@@ -262,7 +270,9 @@ const ProfileTasks: FunctionComponent = () => {
})} })}
/> />
<textarea <textarea
class="h-[5rem] w-full resize-none outline-0" class={cn("h-[5rem] w-full resize-none p-2 outline-0", {
"rounded-md bg-gray-400/30 ring-1 ring-gray-400": isEditModal,
})}
disabled={!isEditModal} disabled={!isEditModal}
placeholder={isEditModal ? "Описание" : ""} placeholder={isEditModal ? "Описание" : ""}
{...register("description", { {...register("description", {
@@ -277,7 +287,7 @@ const ProfileTasks: FunctionComponent = () => {
/> />
<input type="checkbox" hidden {...register("checked")} /> <input type="checkbox" hidden {...register("checked")} />
</div> </div>
<div class="flex flex-row gap-4"> <div class="flex flex-col gap-4 md:flex-row">
<div <div
className="flex cursor-pointer flex-col items-center gap-3" className="flex cursor-pointer flex-col items-center gap-3"
onClick={() => { onClick={() => {
@@ -340,7 +350,7 @@ const ProfileTasks: FunctionComponent = () => {
})} })}
onClick={() => { onClick={() => {
if (!isEditModal) return; if (!isEditModal) return;
setTags({ first: editContent.tags[0], second: editContent.tags[1] }); setTags({ first: editContent.tags[0], second: editContent.tags[1], overdue: false });
setOpenModalTags(true); setOpenModalTags(true);
}} }}
> >
@@ -365,15 +375,15 @@ const ProfileTasks: FunctionComponent = () => {
}} }}
> >
<div class="flex w-full flex-1 flex-row items-start justify-between"> <div class="flex w-full flex-1 flex-row items-start justify-between">
<div class="me-4 flex h-full flex-1 flex-col gap-1"> <div class="flex flex-1 flex-col gap-1 pe-2">
<input <input
class="text-2xl outline-0" class="w-full rounded-md bg-gray-400/30 p-2 text-2xl ring-1 ring-gray-400 outline-0"
maxLength={20} maxLength={20}
placeholder="Название" placeholder="Название"
{...register("name", { required: "Заполните название" })} {...register("name", { required: "Заполните название" })}
/> />
<textarea <textarea
class="mb-10 w-full flex-1 resize-none outline-0" class="h-[5rem] w-full resize-none rounded-md bg-gray-400/30 p-2 ring-1 ring-gray-400 outline-0"
placeholder="Описание" placeholder="Описание"
maxLength={200} maxLength={200}
{...register("description")} {...register("description")}
@@ -386,15 +396,15 @@ const ProfileTasks: FunctionComponent = () => {
/> />
<input type="checkbox" checked={false} hidden {...register("checked")} /> <input type="checkbox" checked={false} hidden {...register("checked")} />
</div> </div>
<div class="flex flex-row gap-3 self-start"> <div class="flex flex-col gap-3 self-start md:flex-row">
<CalendarDaysIcon <CalendarDaysIcon
class="size-10 cursor-pointer" class="size-8 cursor-pointer"
onClick={() => { onClick={() => {
setOpenModalCalendar(true); setOpenModalCalendar(true);
setCalendarDate(calendarDate ?? new Date()); setCalendarDate(calendarDate ?? new Date());
}} }}
/> />
<BookmarkIcon class="ms-4 size-10 cursor-pointer" onClick={() => setOpenModalTags(true)} /> <BookmarkIcon class="size-8 cursor-pointer" onClick={() => setOpenModalTags(true)} />
</div> </div>
</div> </div>
{errors.name && <p class="text-red-500">{errors.name.message}</p>} {errors.name && <p class="text-red-500">{errors.name.message}</p>}
@@ -425,10 +435,36 @@ const ProfileTasks: FunctionComponent = () => {
confirmText="Удалить" confirmText="Удалить"
cancelText="Отмена" cancelText="Отмена"
/> />
{!searchQuery && !filterTags.first && !filterTags.second ? ( {!searchQuery && !filterTags.first && !filterTags.second && !filterTags.overdue ? (
filteredTasks.length > 0 ? ( filteredTasks.length > 0 ? (
<> <>
<div class={classes.header}>Сегодня: {getDate}</div> <div class={classes.header}>
Сегодня: {getDate}
<div class="flex flex-row items-center gap-2 md:hidden">
{!openSearchModal && (
<div
class="flex aspect-square h-12 cursor-pointer flex-col items-center justify-center rounded-full bg-[rgba(206,232,251,0.7)] text-xl text-gray-600 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] hover:bg-[rgba(206,232,251,0.9)]"
onClick={(e) => {
e.stopPropagation();
if (!openSearchModal) setOpenFilterModal(false);
setOpenSearchModal(!openSearchModal);
}}
>
<MagnifyingGlassIcon class="size-6" />
</div>
)}
<div class="flex aspect-square h-12 cursor-pointer flex-col items-center justify-center rounded-full bg-[rgba(206,232,251,0.7)] text-xl text-gray-600 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] hover:bg-[rgba(206,232,251,0.9)]">
<FunnelIcon
class="size-6"
onClick={(e) => {
e.stopPropagation();
if (!openFilterModal) setOpenSearchModal(false);
setOpenFilterModal(!openFilterModal);
}}
/>
</div>
</div>
</div>
<div class={classes.tasks_container}> <div class={classes.tasks_container}>
{groupTasksByDate.today.length > 0 ? ( {groupTasksByDate.today.length > 0 ? (
<div class="w-full"> <div class="w-full">
@@ -437,6 +473,7 @@ const ProfileTasks: FunctionComponent = () => {
name={task.name} name={task.name}
key={task.id} key={task.id}
checked={task.checked} checked={task.checked}
overdue={task.date < new Date()}
onClick={() => { onClick={() => {
setIsOpen(true); setIsOpen(true);
setIsEdit(true); setIsEdit(true);
@@ -501,8 +538,32 @@ const ProfileTasks: FunctionComponent = () => {
) )
) : ( ) : (
<div class={classes.tasks_container}> <div class={classes.tasks_container}>
<div class="mb-8 w-full text-3xl font-semibold md:text-5xl"> <div class="mb-8 flex w-full flex-row items-center justify-between text-xl font-semibold sm:text-3xl md:text-5xl">
{searchQuery ? "Результаты поиска" : "Результаты фильтрации"} {searchQuery ? "Результаты поиска" : "Результаты фильтрации"}
<div class="flex flex-row items-center gap-2 md:hidden">
{!openSearchModal && (
<div
class="flex aspect-square h-12 cursor-pointer flex-col items-center justify-center rounded-full bg-[rgba(206,232,251,0.7)] text-xl text-gray-600 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] hover:bg-[rgba(206,232,251,0.9)]"
onClick={(e) => {
e.stopPropagation();
if (!openSearchModal) setOpenFilterModal(false);
setOpenSearchModal(!openSearchModal);
}}
>
<MagnifyingGlassIcon class="size-6" />
</div>
)}
<div class="flex aspect-square h-12 cursor-pointer flex-col items-center justify-center rounded-full bg-[rgba(206,232,251,0.7)] text-xl text-gray-600 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] hover:bg-[rgba(206,232,251,0.9)]">
<FunnelIcon
class="size-6"
onClick={(e) => {
e.stopPropagation();
if (!openFilterModal) setOpenSearchModal(false);
setOpenFilterModal(!openFilterModal);
}}
/>
</div>
</div>
</div> </div>
{filteredTasks.length > 0 ? ( {filteredTasks.length > 0 ? (
filteredTasks.map((task) => ( filteredTasks.map((task) => (
@@ -510,6 +571,7 @@ const ProfileTasks: FunctionComponent = () => {
name={task.name} name={task.name}
key={task.id} key={task.id}
checked={task.checked} checked={task.checked}
overdue={task.date < new Date()}
onClick={() => { onClick={() => {
setIsOpen(true); setIsOpen(true);
setIsEdit(true); setIsEdit(true);
@@ -562,7 +624,7 @@ const ProfileTasks: FunctionComponent = () => {
</div> </div>
</div> </div>
{openSearchModal && ( {openSearchModal && (
<div class="absolute right-24 bottom-28 z-50 w-80 rounded-lg bg-white p-4 shadow-lg md:right-[24rem] md:bottom-28"> <div class="fixed bottom-28 z-50 w-full rounded-lg bg-white p-4 shadow-lg md:absolute md:right-[24rem] md:mx-0 md:w-80">
{/* Пофиксить разфокус при вводе */} {/* Пофиксить разфокус при вводе */}
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<MagnifyingGlassIcon class="size-6 text-gray-400" /> <MagnifyingGlassIcon class="size-6 text-gray-400" />
@@ -576,28 +638,69 @@ const ProfileTasks: FunctionComponent = () => {
setSearchQuery((e.target as HTMLInputElement).value); setSearchQuery((e.target as HTMLInputElement).value);
}} }}
/> />
{searchQuery && ( <XMarkIcon
<XMarkIcon class="size-5 cursor-pointer text-gray-400 hover:text-gray-600"
class="size-5 cursor-pointer text-gray-400 hover:text-gray-600" onClick={() => {
onClick={() => { setSearchQuery("");
setSearchQuery(""); setOpenSearchModal(false);
setOpenSearchModal(false); }}
}} />
/>
)}
</div> </div>
</div> </div>
)} )}
{openFilterModal && ( {openFilterModal && (
<div class="absolute right-24 bottom-28 z-50 w-80 rounded-lg bg-white p-4 shadow-lg md:right-[24rem] md:bottom-28"> <div class="fixed top-[50%] z-50 w-full rounded-[2rem] bg-white p-4 shadow-lg md:absolute md:top-auto md:right-[24rem] md:bottom-28 md:w-80">
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<div class="text-lg font-semibold">Фильтры</div> <div class="text-center text-lg font-semibold">Фильтры</div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<div class="flex flex-row gap-2">
<Checkbox
name="overdue"
checked={filterTags.overdue}
onChange={(e) => {
setFilterTags({ ...filterTags, overdue: e.target.checked! });
}}
pt={{
root: {
className: cn("cursor-pointer inline-flex relative select-none align-bottom", "w-6 h-6"),
},
input: {
className: cn(
"absolute appearance-none top-0 left-0 size-full p-0 m-0 opacity-0 z-10 outline-none cursor-pointer"
),
},
box: ({ props, context }: CheckboxPassThroughMethodOptions) => ({
className: cn(
"flex items-center justify-center",
"border-2 w-6 h-6 text-gray-600 rounded-lg transition-colors duration-200",
{
"border-gray-300 bg-white": !context.checked,
"border-blue-500 bg-blue-500": context.checked,
},
{
"hover:border-blue-500 focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)]":
!props.disabled,
"cursor-default opacity-60": props.disabled,
}
),
}),
icon: {
className: "w-4 h-4 transition-all duration-200 text-white text-base",
},
}}
></Checkbox>
<label htmlFor="overdue" class="cursor-pointer">
Просроченные
</label>
</div>
<div class="relative"> <div class="relative">
<div <div
class={cn("flex cursor-pointer items-center gap-2 rounded-lg bg-[rgba(206,232,251,0.7)] px-4 py-2", { class={cn(
"bg-[rgba(206,232,251,0.9)]": filterTags.first, "flex cursor-pointer items-center justify-center gap-2 rounded-lg bg-[rgba(206,232,251,0.7)] px-4 py-2",
})} {
"bg-[rgba(206,232,251,0.9)]": filterTags.first,
}
)}
onClick={() => { onClick={() => {
setOpenFirstList(!openFirstList); setOpenFirstList(!openFirstList);
setOpenSecondList(false); setOpenSecondList(false);
@@ -607,7 +710,7 @@ const ProfileTasks: FunctionComponent = () => {
<span>{filterTags.first || "Предмет"}</span> <span>{filterTags.first || "Предмет"}</span>
</div> </div>
{openFirstList && ( {openFirstList && (
<div class="absolute top-0 right-full z-50 mr-2 w-64 rounded-lg bg-white p-2 shadow-lg"> <div class="absolute top-full right-0 z-50 w-64 rounded-lg bg-white p-2 shadow-lg md:top-0 md:right-full md:mr-2">
{example_tags.first.map((tag) => ( {example_tags.first.map((tag) => (
<div <div
key={tag} key={tag}
@@ -634,9 +737,12 @@ const ProfileTasks: FunctionComponent = () => {
<div class="relative"> <div class="relative">
<div <div
class={cn("flex cursor-pointer items-center gap-2 rounded-lg bg-[rgba(206,232,251,0.7)] px-4 py-2", { class={cn(
"bg-[rgba(206,232,251,0.9)]": filterTags.second, "flex cursor-pointer items-center justify-center gap-2 rounded-lg bg-[rgba(206,232,251,0.7)] px-4 py-2",
})} {
"bg-[rgba(206,232,251,0.9)]": filterTags.second,
}
)}
onClick={() => { onClick={() => {
setOpenSecondList(!openSecondList); setOpenSecondList(!openSecondList);
setOpenFirstList(false); setOpenFirstList(false);
@@ -646,7 +752,7 @@ const ProfileTasks: FunctionComponent = () => {
<span>{filterTags.second || "Задача"}</span> <span>{filterTags.second || "Задача"}</span>
</div> </div>
{openSecondList && ( {openSecondList && (
<div class="absolute top-0 right-full z-50 mr-2 w-64 rounded-lg bg-white p-2 shadow-lg"> <div class="absolute top-full right-0 z-50 w-64 rounded-lg bg-white p-2 shadow-lg md:top-0 md:right-full md:mr-2">
{example_tags.second.map((tag) => ( {example_tags.second.map((tag) => (
<div <div
key={tag} key={tag}
@@ -671,11 +777,11 @@ const ProfileTasks: FunctionComponent = () => {
)} )}
</div> </div>
{(filterTags.first || filterTags.second) && ( {(filterTags.first || filterTags.second || filterTags.overdue) && (
<button <button
class="mt-2 w-full rounded-lg bg-red-100 px-4 py-2 text-red-600 hover:bg-red-200" class="mt-2 w-full rounded-lg bg-red-100 px-4 py-2 text-red-600 hover:bg-red-200"
onClick={() => { onClick={() => {
setFilterTags({ first: "", second: "" }); setFilterTags({ first: "", second: "", overdue: false });
setOpenFirstList(false); setOpenFirstList(false);
setOpenSecondList(false); setOpenSecondList(false);
}} }}