11 Commits

12 changed files with 251 additions and 90 deletions

View File

@@ -18,7 +18,7 @@
"react-hook-form": "^7.56.1",
"tailwind-merge": "^3.0.2",
"tailwind-variants": "^1.0.0",
"tailwindcss": "^4.0.17",
"tailwindcss": "^4.1.5",
"uuid": "^11.1.0",
},
"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=="],
"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=="],
@@ -767,6 +767,12 @@
"@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/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",
"tailwind-merge": "^3.0.2",
"tailwind-variants": "^1.0.0",
"tailwindcss": "^4.0.17",
"tailwindcss": "^4.1.5",
"uuid": "^11.1.0"
},
"devDependencies": {

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
@reference "../index.scss";
.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 {
name: string;
checked?: boolean;
overdue?: boolean;
onClick?: () => void;
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 (
<div class="w-[95%]">
<div class={classes.task} onClick={onClick}>
@@ -44,6 +51,7 @@ const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = (
<p class={markStyle({ checked })}></p>
</div>
{name}
{overdue && <span class="absolute top-2 right-16 text-xs text-red-500">Просрочено</span>}
</div>
</div>
);

View File

@@ -23,15 +23,12 @@ const Dialog: FunctionComponent<DialogProps> = ({
if (!isOpen) return null;
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">
<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">
<Button
onClick={() => setIsOpen(false)}
className="bg-gray-200 text-gray-800 hover:bg-gray-300"
>
<Button onClick={() => setIsOpen(false)} className="bg-gray-200 text-gray-800 hover:bg-gray-300">
{cancelText}
</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 { Dispatch, StateUpdater, useEffect } from "preact/hooks";
interface ModalWindowProps {
export interface ModalWindowProps {
isOpen?: boolean;
setIsOpen?: Dispatch<StateUpdater<boolean>>;
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 ModalTags, { ITags } from "@/components/ModalTags";
import { useForm } from "react-hook-form";
import { ITaskForm } from "./profile_tasks.dto";
import { Nullable } from "primereact/ts-helpers";
import Task from "@/components/task";
import Dialog from "@/components/ui/Dialog";
import ModalWindow from "@/components/ui/Modal";
import { withTitle } from "@/constructors/Component";
import { UrlsTitle } from "@/enums/urls";
import { cn } from "@/utils/class-merge";
import {
PencilIcon,
InboxArrowDownIcon,
CalendarDaysIcon,
BookOpenIcon,
CalendarDaysIcon,
DocumentDuplicateIcon,
InboxArrowDownIcon,
PencilIcon,
TrashIcon,
} 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[] } = {
first: ["Программирование", "Информатика", "Физика", "Математика"],
@@ -58,10 +57,9 @@ const ProfileCalendar: FunctionComponent = () => {
const [isEditModal, setIsEditModal] = useState(false);
const [editContent, setEditContent] = useState<ITask | null>(null);
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 {
handleSubmit,
register,
@@ -123,6 +121,15 @@ const ProfileCalendar: FunctionComponent = () => {
setEditContent(newEditContent);
}, [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) => {
return tasks.some((task) => {
const taskDate = task.date;
@@ -134,6 +141,7 @@ const ProfileCalendar: FunctionComponent = () => {
const dateTemplate = (date: CalendarDateTemplateEvent) => {
const isHighlighted = hasTasksOnDate(date);
const countT = tasksCount(date);
const isSelected =
currentDate &&
currentDate.getDate() === date.day &&
@@ -143,7 +151,6 @@ const ProfileCalendar: FunctionComponent = () => {
new Date().getDate() === date.day &&
new Date().getMonth() === date.month &&
new Date().getFullYear() === date.year;
return (
<div
className={cn(
@@ -156,7 +163,14 @@ const ProfileCalendar: FunctionComponent = () => {
)}
>
<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>
);
};
@@ -192,7 +206,7 @@ const ProfileCalendar: FunctionComponent = () => {
};
setTasks(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 = {
@@ -222,7 +236,7 @@ const ProfileCalendar: FunctionComponent = () => {
tagsList={example_tags}
value={tags}
onClose={() => {
setTags({ first: "", second: "" });
setTags({ first: "", second: "", overdue: false });
}}
onChange={setTags}
/>
@@ -242,7 +256,7 @@ const ProfileCalendar: FunctionComponent = () => {
setIsEdit(false);
setEditContent(null);
setIsEditModal(false);
setTags({ first: "", second: "" });
setTags({ first: "", second: "", overdue: false });
setCalendarDate(null);
}}
>
@@ -345,7 +359,7 @@ const ProfileCalendar: FunctionComponent = () => {
})}
onClick={() => {
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);
}}
>

View File

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

View File

@@ -5,7 +5,7 @@
}
.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 {

View File

@@ -1,3 +1,4 @@
//! Файл большой, потому что было лень делить на компоненты
import Task from "@/components/task";
import ModalCalendar from "@/components/ModalCalendar";
@@ -23,6 +24,7 @@ import {
} from "@heroicons/react/24/outline";
import { FunctionComponent } from "preact";
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { Checkbox, CheckboxPassThroughMethodOptions } from "primereact/checkbox";
import { Nullable } from "primereact/ts-helpers";
import { SubmitHandler, useForm } from "react-hook-form";
import { v4 as uuid } from "uuid";
@@ -45,10 +47,10 @@ const ProfileTasks: FunctionComponent = () => {
const [isCreating, setIsCreating] = useState(false); // Включено создание задачи
const [editContent, setEditContent] = useState<ITask | null>(null); // Содержимое редактируемой задачи
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 [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 [openSecondList, setOpenSecondList] = useState(false);
const getDate = useMemo(() => {
@@ -98,7 +100,7 @@ const ProfileTasks: FunctionComponent = () => {
if (isCreating) setTasks([...tasks, eTask]);
else setTasks(tasks.map((task) => (task.id === eTask.id ? eTask : task)));
if (isCreating) setIsOpen(false);
setTags({ first: "", second: "" });
setTags({ first: "", second: "", overdue: false });
};
useEffect(() => {
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;
}, [tasks, searchQuery, filterTags]);
@@ -211,16 +214,18 @@ const ProfileTasks: FunctionComponent = () => {
return (
<div class={classes.container}>
<ModalTags
zIndex={70}
isOpen={openModalTags}
setIsOpen={setOpenModalTags}
tagsList={example_tags}
value={tags}
onClose={() => {
if (!isCreating) setTags({ first: "", second: "" });
if (!isCreating) setTags({ first: "", second: "", overdue: false });
}}
onChange={setTags}
/>
<ModalCalendar
zIndex={80}
isOpen={openModalCalendar}
setIsOpen={setOpenModalCalendar}
onClose={() => {
@@ -230,6 +235,7 @@ const ProfileTasks: FunctionComponent = () => {
value={calendarDate!}
/>
<ModalWindow
zIndex={60}
isOpen={openModal}
setIsOpen={setIsOpen}
onClose={() => {
@@ -237,7 +243,7 @@ const ProfileTasks: FunctionComponent = () => {
setEditContent(null);
setIsCreating(false);
setIsEditModal(false);
setTags({ first: "", second: "" });
setTags({ first: "", second: "", overdue: false });
setCalendarDate(null);
}}
>
@@ -253,7 +259,9 @@ const ProfileTasks: FunctionComponent = () => {
<div class="flex w-full flex-row items-start justify-between">
<div class="flex flex-1 flex-col gap-1 pe-2">
<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}
placeholder="Название"
{...register("name", {
@@ -262,7 +270,9 @@ const ProfileTasks: FunctionComponent = () => {
})}
/>
<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}
placeholder={isEditModal ? "Описание" : ""}
{...register("description", {
@@ -277,7 +287,7 @@ const ProfileTasks: FunctionComponent = () => {
/>
<input type="checkbox" hidden {...register("checked")} />
</div>
<div class="flex flex-row gap-4">
<div class="flex flex-col gap-4 md:flex-row">
<div
className="flex cursor-pointer flex-col items-center gap-3"
onClick={() => {
@@ -340,7 +350,7 @@ const ProfileTasks: FunctionComponent = () => {
})}
onClick={() => {
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);
}}
>
@@ -365,15 +375,15 @@ const ProfileTasks: FunctionComponent = () => {
}}
>
<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
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}
placeholder="Название"
{...register("name", { required: "Заполните название" })}
/>
<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="Описание"
maxLength={200}
{...register("description")}
@@ -386,15 +396,15 @@ const ProfileTasks: FunctionComponent = () => {
/>
<input type="checkbox" checked={false} hidden {...register("checked")} />
</div>
<div class="flex flex-row gap-3 self-start">
<div class="flex flex-col gap-3 self-start md:flex-row">
<CalendarDaysIcon
class="size-10 cursor-pointer"
class="size-8 cursor-pointer"
onClick={() => {
setOpenModalCalendar(true);
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>
{errors.name && <p class="text-red-500">{errors.name.message}</p>}
@@ -425,10 +435,36 @@ const ProfileTasks: FunctionComponent = () => {
confirmText="Удалить"
cancelText="Отмена"
/>
{!searchQuery && !filterTags.first && !filterTags.second ? (
{!searchQuery && !filterTags.first && !filterTags.second && !filterTags.overdue ? (
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}>
{groupTasksByDate.today.length > 0 ? (
<div class="w-full">
@@ -437,6 +473,7 @@ const ProfileTasks: FunctionComponent = () => {
name={task.name}
key={task.id}
checked={task.checked}
overdue={task.date < new Date()}
onClick={() => {
setIsOpen(true);
setIsEdit(true);
@@ -501,8 +538,32 @@ const ProfileTasks: FunctionComponent = () => {
)
) : (
<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 ? "Результаты поиска" : "Результаты фильтрации"}
<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>
{filteredTasks.length > 0 ? (
filteredTasks.map((task) => (
@@ -510,6 +571,7 @@ const ProfileTasks: FunctionComponent = () => {
name={task.name}
key={task.id}
checked={task.checked}
overdue={task.date < new Date()}
onClick={() => {
setIsOpen(true);
setIsEdit(true);
@@ -562,7 +624,7 @@ const ProfileTasks: FunctionComponent = () => {
</div>
</div>
{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">
<MagnifyingGlassIcon class="size-6 text-gray-400" />
@@ -576,25 +638,69 @@ const ProfileTasks: FunctionComponent = () => {
setSearchQuery((e.target as HTMLInputElement).value);
}}
/>
{searchQuery && (
<XMarkIcon
class="size-5 cursor-pointer text-gray-400 hover:text-gray-600"
onClick={() => setSearchQuery("")}
/>
)}
<XMarkIcon
class="size-5 cursor-pointer text-gray-400 hover:text-gray-600"
onClick={() => {
setSearchQuery("");
setOpenSearchModal(false);
}}
/>
</div>
</div>
)}
{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="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-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={cn("flex cursor-pointer items-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,
})}
class={cn(
"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={() => {
setOpenFirstList(!openFirstList);
setOpenSecondList(false);
@@ -604,7 +710,7 @@ const ProfileTasks: FunctionComponent = () => {
<span>{filterTags.first || "Предмет"}</span>
</div>
{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) => (
<div
key={tag}
@@ -631,9 +737,12 @@ const ProfileTasks: FunctionComponent = () => {
<div class="relative">
<div
class={cn("flex cursor-pointer items-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,
})}
class={cn(
"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={() => {
setOpenSecondList(!openSecondList);
setOpenFirstList(false);
@@ -643,7 +752,7 @@ const ProfileTasks: FunctionComponent = () => {
<span>{filterTags.second || "Задача"}</span>
</div>
{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) => (
<div
key={tag}
@@ -668,11 +777,11 @@ const ProfileTasks: FunctionComponent = () => {
)}
</div>
{(filterTags.first || filterTags.second) && (
{(filterTags.first || filterTags.second || filterTags.overdue) && (
<button
class="mt-2 w-full rounded-lg bg-red-100 px-4 py-2 text-red-600 hover:bg-red-200"
onClick={() => {
setFilterTags({ first: "", second: "" });
setFilterTags({ first: "", second: "", overdue: false });
setOpenFirstList(false);
setOpenSecondList(false);
}}