Compare commits
6 Commits
form
...
e8ded7f2ae
| Author | SHA1 | Date | |
|---|---|---|---|
| e8ded7f2ae | |||
| 320872ddc9 | |||
| 9841da8b88 | |||
| b091e8d20d | |||
| c1246939cd | |||
| eb12afe763 |
6
bun.lock
6
bun.lock
@@ -8,6 +8,7 @@
|
|||||||
"@preact/signals": "^2.0.2",
|
"@preact/signals": "^2.0.2",
|
||||||
"@tailwindcss/postcss": "^4.0.17",
|
"@tailwindcss/postcss": "^4.0.17",
|
||||||
"@tailwindcss/vite": "^4.0.17",
|
"@tailwindcss/vite": "^4.0.17",
|
||||||
|
"@types/uuid": "^10.0.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"preact": "^10.26.2",
|
"preact": "^10.26.2",
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
"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.0.17",
|
||||||
|
"uuid": "^11.1.0",
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.23.0",
|
"@eslint/js": "^9.23.0",
|
||||||
@@ -281,6 +283,8 @@
|
|||||||
|
|
||||||
"@types/react-transition-group": ["@types/react-transition-group@4.4.12", "", { "peerDependencies": { "@types/react": "*" } }, "sha512-8TV6R3h2j7a91c+1DXdJi3Syo69zzIZbz7Lg5tORM5LEJG7X/E6a1V3drRyBRZq7/utz7A+c4OgYLiLcYGHG6w=="],
|
"@types/react-transition-group": ["@types/react-transition-group@4.4.12", "", { "peerDependencies": { "@types/react": "*" } }, "sha512-8TV6R3h2j7a91c+1DXdJi3Syo69zzIZbz7Lg5tORM5LEJG7X/E6a1V3drRyBRZq7/utz7A+c4OgYLiLcYGHG6w=="],
|
||||||
|
|
||||||
|
"@types/uuid": ["@types/uuid@10.0.0", "", {}, "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ=="],
|
||||||
|
|
||||||
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.28.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.28.0", "@typescript-eslint/type-utils": "8.28.0", "@typescript-eslint/utils": "8.28.0", "@typescript-eslint/visitor-keys": "8.28.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-lvFK3TCGAHsItNdWZ/1FkvpzCxTHUVuFrdnOGLMa0GGCFIbCgQWVk3CzCGdA7kM3qGVc+dfW9tr0Z/sHnGDFyg=="],
|
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.28.0", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.28.0", "@typescript-eslint/type-utils": "8.28.0", "@typescript-eslint/utils": "8.28.0", "@typescript-eslint/visitor-keys": "8.28.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", "ts-api-utils": "^2.0.1" }, "peerDependencies": { "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-lvFK3TCGAHsItNdWZ/1FkvpzCxTHUVuFrdnOGLMa0GGCFIbCgQWVk3CzCGdA7kM3qGVc+dfW9tr0Z/sHnGDFyg=="],
|
||||||
|
|
||||||
"@typescript-eslint/parser": ["@typescript-eslint/parser@8.28.0", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.28.0", "@typescript-eslint/types": "8.28.0", "@typescript-eslint/typescript-estree": "8.28.0", "@typescript-eslint/visitor-keys": "8.28.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-LPcw1yHD3ToaDEoljFEfQ9j2xShY367h7FZ1sq5NJT9I3yj4LHer1Xd1yRSOdYy9BpsrxU7R+eoDokChYM53lQ=="],
|
"@typescript-eslint/parser": ["@typescript-eslint/parser@8.28.0", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.28.0", "@typescript-eslint/types": "8.28.0", "@typescript-eslint/typescript-estree": "8.28.0", "@typescript-eslint/visitor-keys": "8.28.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <5.9.0" } }, "sha512-LPcw1yHD3ToaDEoljFEfQ9j2xShY367h7FZ1sq5NJT9I3yj4LHer1Xd1yRSOdYy9BpsrxU7R+eoDokChYM53lQ=="],
|
||||||
@@ -735,6 +739,8 @@
|
|||||||
|
|
||||||
"uri-js": ["uri-js@4.4.1", "", { "dependencies": { "punycode": "^2.1.0" } }, "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg=="],
|
"uri-js": ["uri-js@4.4.1", "", { "dependencies": { "punycode": "^2.1.0" } }, "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg=="],
|
||||||
|
|
||||||
|
"uuid": ["uuid@11.1.0", "", { "bin": { "uuid": "dist/esm/bin/uuid" } }, "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A=="],
|
||||||
|
|
||||||
"varint": ["varint@6.0.0", "", {}, "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg=="],
|
"varint": ["varint@6.0.0", "", {}, "sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg=="],
|
||||||
|
|
||||||
"vite": ["vite@6.2.3", "", { "dependencies": { "esbuild": "^0.25.0", "postcss": "^8.5.3", "rollup": "^4.30.1" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-IzwM54g4y9JA/xAeBPNaDXiBF8Jsgl3VBQ2YQ/wOY6fyW3xMdSoltIV3Bo59DErdqdE6RxUfv8W69DvUorE4Eg=="],
|
"vite": ["vite@6.2.3", "", { "dependencies": { "esbuild": "^0.25.0", "postcss": "^8.5.3", "rollup": "^4.30.1" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "jiti": ">=1.21.0", "less": "*", "lightningcss": "^1.21.0", "sass": "*", "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-IzwM54g4y9JA/xAeBPNaDXiBF8Jsgl3VBQ2YQ/wOY6fyW3xMdSoltIV3Bo59DErdqdE6RxUfv8W69DvUorE4Eg=="],
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"@preact/signals": "^2.0.2",
|
"@preact/signals": "^2.0.2",
|
||||||
"@tailwindcss/postcss": "^4.0.17",
|
"@tailwindcss/postcss": "^4.0.17",
|
||||||
"@tailwindcss/vite": "^4.0.17",
|
"@tailwindcss/vite": "^4.0.17",
|
||||||
|
"@types/uuid": "^10.0.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"preact": "^10.26.2",
|
"preact": "^10.26.2",
|
||||||
@@ -22,7 +23,8 @@
|
|||||||
"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.0.17",
|
||||||
|
"uuid": "^11.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.23.0",
|
"@eslint/js": "^9.23.0",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { FunctionComponent } from "preact";
|
import { FunctionComponent } from "preact";
|
||||||
import { ErrorBoundary, lazy, LocationProvider, Route, Router, useLocation } from "preact-iso";
|
import { ErrorBoundary, lazy, LocationProvider, Route, Router, useLocation } from "preact-iso";
|
||||||
import "preact/debug";
|
|
||||||
import { ru } from "primelocale/js/ru.js";
|
import { ru } from "primelocale/js/ru.js";
|
||||||
import { addLocale, locale, PrimeReactProvider } from "primereact/api";
|
import { addLocale, locale, PrimeReactProvider } from "primereact/api";
|
||||||
import { useMountEffect } from "primereact/hooks";
|
import { useMountEffect } from "primereact/hooks";
|
||||||
@@ -26,8 +25,6 @@ export function App() {
|
|||||||
<PrimeReactProvider
|
<PrimeReactProvider
|
||||||
value={{
|
value={{
|
||||||
unstyled: true,
|
unstyled: true,
|
||||||
// pt: Tailwind,
|
|
||||||
// ptOptions: { mergeProps: true, mergeSections: true, classNameMergeFunction: cn },
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LocationProvider>
|
<LocationProvider>
|
||||||
|
|||||||
@@ -199,4 +199,6 @@ const ModalCalendar: FunctionComponent<ModalCalendarProps> = ({ isOpen, setIsOpe
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ModalCalendar.displayName = "AHModalCalendar";
|
||||||
|
|
||||||
export default ModalCalendar;
|
export default ModalCalendar;
|
||||||
|
|||||||
125
src/components/ModalTags.tsx
Normal file
125
src/components/ModalTags.tsx
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
import { cn } from "@/utils/class-merge";
|
||||||
|
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";
|
||||||
|
|
||||||
|
export interface ITags {
|
||||||
|
first: string;
|
||||||
|
second: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ModalTagsProps {
|
||||||
|
isOpen?: boolean;
|
||||||
|
setIsOpen?: Dispatch<StateUpdater<boolean>>;
|
||||||
|
onClose?: () => void;
|
||||||
|
value?: ITags;
|
||||||
|
onChange?: Dispatch<StateUpdater<ITags>>;
|
||||||
|
tagsList?: {
|
||||||
|
first: string[];
|
||||||
|
second: string[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const ModalTags: FunctionComponent<ModalTagsProps> = ({ isOpen, setIsOpen, onClose, onChange, value, tagsList }) => {
|
||||||
|
const [showFirstTags, setShowFirstTags] = useState(false);
|
||||||
|
const [showSecondTags, setShowSecondTags] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (showFirstTags && showSecondTags) setShowFirstTags(false);
|
||||||
|
}, [showSecondTags]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (showFirstTags && showSecondTags) setShowSecondTags(false);
|
||||||
|
}, [showFirstTags]);
|
||||||
|
return (
|
||||||
|
<ModalWindow
|
||||||
|
isOpen={isOpen}
|
||||||
|
setIsOpen={setIsOpen}
|
||||||
|
onClose={() => {
|
||||||
|
onClose!();
|
||||||
|
setShowFirstTags(false);
|
||||||
|
setShowSecondTags(false);
|
||||||
|
}}
|
||||||
|
className="relative h-[14rem] justify-between py-4 md:h-[14rem] md:w-[25rem]"
|
||||||
|
zIndex={70}
|
||||||
|
>
|
||||||
|
<p class="text-2xl font-semibold">Теги</p>
|
||||||
|
<div class="flex w-[85%] flex-col gap-2 md:w-full">
|
||||||
|
<Button
|
||||||
|
className="flex w-full flex-row items-center justify-center gap-1 text-[1rem]!"
|
||||||
|
onClick={() => setShowFirstTags(!showFirstTags)}
|
||||||
|
>
|
||||||
|
<BookOpenIcon class="size-6" />
|
||||||
|
{value?.first || "Предмет"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
className="flex w-full flex-row items-center justify-center gap-1 text-[1rem]! break-words"
|
||||||
|
onClick={() => setShowSecondTags(!showSecondTags)}
|
||||||
|
>
|
||||||
|
<DocumentDuplicateIcon class="size-6" />
|
||||||
|
{value?.second || "Тема"}
|
||||||
|
</Button>
|
||||||
|
{showFirstTags && (
|
||||||
|
<div class="absolute top-0 left-full ml-5 flex h-fit w-[18rem] flex-col items-center rounded-[4rem] bg-white px-8 py-4 text-xs">
|
||||||
|
<div class="flex h-fit max-h-[45vh] w-full flex-col gap-3 overflow-y-auto">
|
||||||
|
{tagsList?.first.map((tag) => (
|
||||||
|
<div
|
||||||
|
class="flex cursor-pointer flex-row gap-2"
|
||||||
|
onClick={() =>
|
||||||
|
onChange?.((prev) => {
|
||||||
|
return { ...prev, first: tag };
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class={cn(
|
||||||
|
"pointer-events-none flex aspect-square size-4 flex-col items-center justify-center rounded-full border-1 border-black text-white select-none",
|
||||||
|
{
|
||||||
|
"bg-black": value?.first === tag,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
✓
|
||||||
|
</div>
|
||||||
|
<p>{tag}</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{showSecondTags && (
|
||||||
|
<div class="absolute top-0 left-full ml-5 flex h-fit w-[18rem] rounded-[4rem] bg-white px-8 py-4 text-xs">
|
||||||
|
<div class="flex h-fit max-h-[45vh] w-full flex-col gap-3 overflow-y-auto">
|
||||||
|
{tagsList?.second.map((tag) => (
|
||||||
|
<div
|
||||||
|
class="flex cursor-pointer flex-row gap-2"
|
||||||
|
onClick={() =>
|
||||||
|
onChange?.((prev) => {
|
||||||
|
return { ...prev, second: tag };
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class={cn(
|
||||||
|
"pointer-events-none flex aspect-square size-4 flex-col items-center justify-center rounded-full border-1 border-black text-white select-none",
|
||||||
|
{
|
||||||
|
"bg-black": value?.second === tag,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
✓
|
||||||
|
</div>
|
||||||
|
<p>{tag}</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ModalWindow>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ModalTags.displayName = "AHModalTags";
|
||||||
|
|
||||||
|
export default ModalTags;
|
||||||
@@ -220,6 +220,9 @@ const BigCalendar: FunctionComponent<BigCalendarProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`flex w-full flex-col ${className}`}>
|
<div className={`flex w-full flex-col ${className}`}>
|
||||||
|
<div class="fixed top-0 right-[20rem] z-100 flex h-full w-full flex-col items-center justify-center bg-white">
|
||||||
|
Закрыто
|
||||||
|
</div>
|
||||||
<div className="mb-4 flex items-center justify-between px-2">
|
<div className="mb-4 flex items-center justify-between px-2">
|
||||||
<button
|
<button
|
||||||
onClick={handlePrevMonth}
|
onClick={handlePrevMonth}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { FunctionComponent } from "preact";
|
import { FunctionComponent } from "preact";
|
||||||
|
import { MouseEventHandler } from "preact/compat";
|
||||||
import { tv } from "tailwind-variants";
|
import { tv } from "tailwind-variants";
|
||||||
import classes from "./task.module.scss";
|
import classes from "./task.module.scss";
|
||||||
|
|
||||||
@@ -6,10 +7,11 @@ interface TaskProps {
|
|||||||
name: string;
|
name: string;
|
||||||
checked?: boolean;
|
checked?: boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
onMarkClick?: MouseEventHandler<HTMLParagraphElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskStyle = tv({
|
const taskStyle = tv({
|
||||||
base: "flex aspect-square h-full flex-col items-center justify-center rounded-full border",
|
base: "hover:scale-[1.1]active:scale-[1.1] flex aspect-square h-full flex-col items-center justify-center rounded-full border transition-[scale] duration-100 ease-in-out select-none",
|
||||||
variants: {
|
variants: {
|
||||||
checked: {
|
checked: {
|
||||||
true: "bg-black",
|
true: "bg-black",
|
||||||
@@ -28,18 +30,26 @@ const markStyle = tv({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {} }: TaskProps) => {
|
const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {}, onMarkClick = () => {} }) => {
|
||||||
return (
|
return (
|
||||||
// Временное действие для тестирования
|
// Временное действие для тестирования
|
||||||
<button onClick={onClick} class="w-[95%]">
|
<div class="w-[95%]">
|
||||||
<div class={classes.task}>
|
<div class={classes.task} onClick={onClick}>
|
||||||
<div class={taskStyle({ checked })}>
|
<div
|
||||||
|
class={taskStyle({ checked })}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
onMarkClick(e);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<p class={markStyle({ checked })}>✓</p>
|
<p class={markStyle({ checked })}>✓</p>
|
||||||
</div>
|
</div>
|
||||||
{name}
|
{name}
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Task.displayName = "AHTask";
|
||||||
|
|
||||||
export default Task;
|
export default Task;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FunctionComponent } from "preact";
|
import { forwardRef, HTMLProps } from "preact/compat";
|
||||||
import { tv } from "tailwind-variants";
|
import { tv } from "tailwind-variants";
|
||||||
import classes from "./Button.module.scss";
|
import classes from "./Button.module.scss";
|
||||||
const button = tv({
|
const button = tv({
|
||||||
@@ -12,25 +12,20 @@ const button = tv({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ButtonProps {
|
interface ButtonProps extends HTMLProps<HTMLButtonElement> {
|
||||||
color?: "primary" | "secondary" | "red";
|
color?: "primary" | "secondary" | "red";
|
||||||
onClick?: () => void;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
type?: "button" | "submit";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Button: FunctionComponent<ButtonProps> = ({
|
const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
||||||
children,
|
const { children, onClick = () => {}, color = "primary", className = "", type = "button" } = props;
|
||||||
onClick = () => {},
|
|
||||||
color = "primary",
|
|
||||||
className = "",
|
|
||||||
type = "button",
|
|
||||||
}) => {
|
|
||||||
return (
|
return (
|
||||||
<button type={type} class={button({ color: color, class: className })} onClick={onClick}>
|
<button ref={ref} type={type} class={button({ color: color, class: className })} onClick={onClick}>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
|
Button.displayName = "AHButton";
|
||||||
|
|
||||||
export default Button;
|
export default Button;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { useAppContext } from "@/providers/AuthProvider";
|
|||||||
import { FunctionComponent } from "preact";
|
import { FunctionComponent } from "preact";
|
||||||
import { useLocation } from "preact-iso";
|
import { useLocation } from "preact-iso";
|
||||||
import "preact/debug";
|
import "preact/debug";
|
||||||
import { useState } from "preact/hooks";
|
|
||||||
import { Controller, SubmitHandler, useForm } from "react-hook-form";
|
import { Controller, SubmitHandler, useForm } from "react-hook-form";
|
||||||
import { ILoginForm } from "./login.dto";
|
import { ILoginForm } from "./login.dto";
|
||||||
import classes from "./login.module.scss";
|
import classes from "./login.module.scss";
|
||||||
@@ -18,17 +17,6 @@ const testUser = {
|
|||||||
const LoginPage: FunctionComponent = () => {
|
const LoginPage: FunctionComponent = () => {
|
||||||
const { isLoggedIn } = useAppContext();
|
const { isLoggedIn } = useAppContext();
|
||||||
const { route } = useLocation();
|
const { route } = useLocation();
|
||||||
const [passwordError, setPasswordError] = useState("");
|
|
||||||
const login: SubmitHandler<ILoginForm> = async (data) => {
|
|
||||||
console.log(data);
|
|
||||||
if (data.login !== testUser.login || data.password !== testUser.password) {
|
|
||||||
setError("login", { message: "Неверный" }); //TODO: не показывает ошибку
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
isLoggedIn.value = true;
|
|
||||||
localStorage.setItem("loggedIn", "true");
|
|
||||||
route("/profile/tasks", true);
|
|
||||||
};
|
|
||||||
const { control, handleSubmit, formState, setError } = useForm({
|
const { control, handleSubmit, formState, setError } = useForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
login: "",
|
login: "",
|
||||||
@@ -36,12 +24,23 @@ const LoginPage: FunctionComponent = () => {
|
|||||||
},
|
},
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
});
|
});
|
||||||
|
const login: SubmitHandler<ILoginForm> = async (data) => {
|
||||||
|
console.log(data);
|
||||||
|
if (data.login !== testUser.login || data.password !== testUser.password) {
|
||||||
|
setError("login", { message: "Неверный логин или пароль" });
|
||||||
|
setError("password", { message: "Неверный логин или пароль" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isLoggedIn.value = true;
|
||||||
|
localStorage.setItem("loggedIn", "true");
|
||||||
|
route("/profile/tasks", true);
|
||||||
|
};
|
||||||
if (isLoggedIn.value) route("/profile/tasks", true);
|
if (isLoggedIn.value) route("/profile/tasks", true);
|
||||||
return !isLoggedIn.value ? (
|
return !isLoggedIn.value ? (
|
||||||
<div class={classes.login_container}>
|
<div class={classes.login_container}>
|
||||||
<div class={classes.login_card}>
|
<div class={classes.login_card}>
|
||||||
<p class={classes.login_card_name}>Антихвост</p>
|
<p class={classes.login_card_name}>Антихвост</p>
|
||||||
<form onSubmit={handleSubmit((data) => login(data))}>
|
<form onSubmit={handleSubmit(login)}>
|
||||||
<Controller
|
<Controller
|
||||||
name="login"
|
name="login"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -59,7 +58,13 @@ const LoginPage: FunctionComponent = () => {
|
|||||||
required: "Введите пароль",
|
required: "Введите пароль",
|
||||||
}}
|
}}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Input placeholder="Пароль" textAlign="center" type="password" error={passwordError} {...field} />
|
<Input
|
||||||
|
placeholder="Пароль"
|
||||||
|
textAlign="center"
|
||||||
|
type="password"
|
||||||
|
error={formState.errors.password?.message}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Button type="submit" color="secondary" className="w-full">
|
<Button type="submit" color="secondary" className="w-full">
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
export interface ITask {
|
export interface ITask {
|
||||||
id: number;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
date: Date;
|
date: Date;
|
||||||
description: string;
|
description: string;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
|
new?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ITaskForm extends Omit<ITask, "date"> {
|
||||||
|
date: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import Task from "@/components/task";
|
import Task from "@/components/task";
|
||||||
|
|
||||||
import ModalCalendar from "@/components/ModalCalendar";
|
import ModalCalendar from "@/components/ModalCalendar";
|
||||||
|
import ModalTags, { ITags } from "@/components/ModalTags";
|
||||||
import Button from "@/components/ui/Button";
|
import Button from "@/components/ui/Button";
|
||||||
import ModalWindow from "@/components/ui/Modal";
|
import ModalWindow from "@/components/ui/Modal";
|
||||||
import { withTitle } from "@/constructors/Component";
|
import { withTitle } from "@/constructors/Component";
|
||||||
import { UrlsTitle } from "@/enums/urls";
|
import { UrlsTitle } from "@/enums/urls";
|
||||||
|
import { cn } from "@/utils/class-merge";
|
||||||
import { PlusIcon } from "@heroicons/react/20/solid";
|
import { PlusIcon } from "@heroicons/react/20/solid";
|
||||||
import {
|
import {
|
||||||
BookmarkIcon,
|
BookmarkIcon,
|
||||||
@@ -12,75 +14,121 @@ import {
|
|||||||
CalendarDaysIcon,
|
CalendarDaysIcon,
|
||||||
DocumentDuplicateIcon,
|
DocumentDuplicateIcon,
|
||||||
FunnelIcon,
|
FunnelIcon,
|
||||||
|
InboxArrowDownIcon,
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
} 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, useState } from "preact/hooks";
|
||||||
import { Nullable } from "primereact/ts-helpers";
|
import { Nullable } from "primereact/ts-helpers";
|
||||||
import { ITask } from "./profile_tasks.dto";
|
import { SubmitHandler, useForm } from "react-hook-form";
|
||||||
|
import { v4 as uuid } from "uuid";
|
||||||
|
import { ITask, ITaskForm } from "./profile_tasks.dto";
|
||||||
import classes from "./profile_tasks.module.scss";
|
import classes from "./profile_tasks.module.scss";
|
||||||
|
|
||||||
const example_tasks: ITask[] = [
|
const example_tags: { first: string[]; second: string[] } = {
|
||||||
{
|
first: ["Программирование", "Информатика", "Физика", "Математика"],
|
||||||
checked: false,
|
second: ["Лабораторная работа", "Практическая работа", "Домашнее задание", "Экзамен"],
|
||||||
date: new Date(),
|
};
|
||||||
description: "test",
|
|
||||||
id: 1,
|
|
||||||
name: "test1",
|
|
||||||
tags: ["Программирование", "Лабораторная работа"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
checked: true,
|
|
||||||
date: new Date(2025, 6, 2),
|
|
||||||
description: "test2",
|
|
||||||
id: 3,
|
|
||||||
name: "test3",
|
|
||||||
tags: ["Информатика", "Практическая работа"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
checked: false,
|
|
||||||
date: new Date(2025, 5, 1),
|
|
||||||
description: "test3",
|
|
||||||
id: 2,
|
|
||||||
name: "test2",
|
|
||||||
tags: ["Математика", "Домашнее задание"],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const ProfileTasks: FunctionComponent = () => {
|
const ProfileTasks: FunctionComponent = () => {
|
||||||
|
const [openModal, setIsOpen] = useState(false); // Открыта модалка
|
||||||
|
const [openModalCalendar, setOpenModalCalendar] = useState(false); // Открыта модалка календаря
|
||||||
|
const [openModalTags, setOpenModalTags] = useState(false); // Открыта модалка тегов
|
||||||
|
const [isEdit, setIsEdit] = useState(false); // Открыта задача
|
||||||
|
const [isEditModal, setIsEditModal] = useState(false); // Включено редактирование задачи
|
||||||
|
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 getDate = useMemo(() => {
|
const getDate = useMemo(() => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const formatter = new Intl.DateTimeFormat("ru-RU", { month: "long", day: "numeric" });
|
const formatter = new Intl.DateTimeFormat("ru-RU", { month: "long", day: "numeric" });
|
||||||
return formatter.format(date);
|
return formatter.format(date);
|
||||||
}, []);
|
}, []);
|
||||||
const init_tasks: ITask[] = localStorage.getItem("tasks")
|
const init_tasks: ITask[] = localStorage.getItem("tasks") ? JSON.parse(localStorage.getItem("tasks") as string) : [];
|
||||||
? JSON.parse(localStorage.getItem("tasks") as string)
|
let clear = false;
|
||||||
: example_tasks;
|
|
||||||
init_tasks.forEach((task) => {
|
init_tasks.forEach((task) => {
|
||||||
|
clear = clear || (task.new == undefined ? true : false);
|
||||||
|
if (!clear) task.new = true;
|
||||||
task.date = new Date(task.date);
|
task.date = new Date(task.date);
|
||||||
});
|
});
|
||||||
const [tasks, setTasks] = useState<ITask[]>(init_tasks);
|
const [tasks, setTasks] = useState<ITask[]>(clear ? [] : init_tasks);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
localStorage.setItem("tasks", JSON.stringify(tasks));
|
localStorage.setItem("tasks", JSON.stringify(tasks));
|
||||||
}, [tasks]);
|
}, [tasks]);
|
||||||
const [openModal, setIsOpen] = useState(false);
|
|
||||||
const [openModalCalendar, setOpenModalCalendar] = useState(false);
|
const {
|
||||||
const [isEdit, setIsEdit] = useState(false);
|
handleSubmit,
|
||||||
const [isCreating, setIsCreating] = useState(false);
|
register,
|
||||||
const [editContent, setEditContent] = useState<ITask | null>(null);
|
reset,
|
||||||
const taskNameRef = useRef<HTMLInputElement>(null);
|
setError,
|
||||||
const taskDescriptionRef = useRef<HTMLTextAreaElement>(null);
|
formState: { errors },
|
||||||
const [calendarDate, setCalendarDate] = useState<Nullable<Date>>();
|
} = useForm<ITaskForm>({
|
||||||
|
defaultValues: {
|
||||||
|
tags: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const saveTask: SubmitHandler<ITaskForm> = (data) => {
|
||||||
|
if (!calendarDate) {
|
||||||
|
setError("date", { message: "Выберите дату" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(tags);
|
||||||
|
if ((!editContent?.tags[0] || !editContent.tags[1]) && (!tags.first || !tags.second)) {
|
||||||
|
setError("tags", { message: "Выберите теги" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const eTask: ITask = {
|
||||||
|
...data,
|
||||||
|
date: calendarDate,
|
||||||
|
tags: editContent?.tags.length ? editContent.tags : [tags.first, tags.second],
|
||||||
|
new: true,
|
||||||
|
};
|
||||||
|
if (isCreating) setTasks([...tasks, eTask]);
|
||||||
|
else setTasks(tasks.map((task) => (task.id === eTask.id ? eTask : task)));
|
||||||
|
if (isCreating) setIsOpen(false);
|
||||||
|
setTags({ first: "", second: "" });
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
if (editContent) reset({ ...editContent, date: editContent.date.toISOString().slice(0, 16) });
|
||||||
|
else reset();
|
||||||
|
}, [editContent]);
|
||||||
|
useEffect(() => {
|
||||||
|
reset({
|
||||||
|
name: "",
|
||||||
|
description: "",
|
||||||
|
date: "",
|
||||||
|
tags: [],
|
||||||
|
checked: false,
|
||||||
|
});
|
||||||
|
}, [isCreating]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!editContent) return;
|
||||||
|
const newEditContent = editContent;
|
||||||
|
if (tags.first) newEditContent.tags = [tags.first, newEditContent.tags[1]];
|
||||||
|
if (tags.second) newEditContent.tags = [newEditContent.tags[0], tags.second];
|
||||||
|
setEditContent(newEditContent);
|
||||||
|
}, [tags]);
|
||||||
return (
|
return (
|
||||||
<div class={classes.container}>
|
<div class={classes.container}>
|
||||||
|
<ModalTags
|
||||||
|
isOpen={openModalTags}
|
||||||
|
setIsOpen={setOpenModalTags}
|
||||||
|
tagsList={example_tags}
|
||||||
|
value={tags}
|
||||||
|
onClose={() => {
|
||||||
|
if (!isCreating) setTags({ first: "", second: "" });
|
||||||
|
}}
|
||||||
|
onChange={setTags}
|
||||||
|
/>
|
||||||
<ModalCalendar
|
<ModalCalendar
|
||||||
isOpen={openModalCalendar}
|
isOpen={openModalCalendar}
|
||||||
setIsOpen={setOpenModalCalendar}
|
setIsOpen={setOpenModalCalendar}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
if (isEdit) setCalendarDate(null);
|
if (isEdit && !isEditModal) setCalendarDate(null);
|
||||||
}}
|
}}
|
||||||
onChange={(e) => isCreating && setCalendarDate(e.value)}
|
onChange={(e) => (isCreating || isEditModal) && setCalendarDate(e.value)}
|
||||||
value={calendarDate!}
|
value={calendarDate!}
|
||||||
/>
|
/>
|
||||||
<ModalWindow
|
<ModalWindow
|
||||||
@@ -90,25 +138,81 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
setIsEdit(false);
|
setIsEdit(false);
|
||||||
setEditContent(null);
|
setEditContent(null);
|
||||||
setIsCreating(false);
|
setIsCreating(false);
|
||||||
|
setIsEditModal(false);
|
||||||
|
setTags({ first: "", second: "" });
|
||||||
setCalendarDate(null);
|
setCalendarDate(null);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isEdit && editContent && (
|
{isEdit && editContent && (
|
||||||
<div class="flex h-full w-full flex-col items-start justify-between">
|
<form
|
||||||
|
class="flex h-full w-full flex-col items-start justify-between"
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (isEditModal) handleSubmit(saveTask)();
|
||||||
|
else setIsEditModal(!isEditModal);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<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-col">
|
<div class="flex flex-1 flex-col gap-1 pe-2">
|
||||||
<p class="text-2xl">{editContent.name}</p>
|
<input
|
||||||
<p>{editContent.description}</p>
|
class="w-full text-2xl outline-0"
|
||||||
|
disabled={!isEditModal}
|
||||||
|
placeholder="Название"
|
||||||
|
{...register("name", {
|
||||||
|
required: "Заполните название",
|
||||||
|
maxLength: { value: 20, message: "Максимум 20 символов в названии" },
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<textarea
|
||||||
|
class="h-[5rem] w-full resize-none outline-0"
|
||||||
|
disabled={!isEditModal}
|
||||||
|
placeholder={isEditModal ? "Описание" : ""}
|
||||||
|
{...register("description", {
|
||||||
|
maxLength: { value: 200, message: "Максимум 200 символов в описании" },
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
value={calendarDate ? calendarDate.toISOString().slice(0, 16) : ""}
|
||||||
|
hidden
|
||||||
|
{...register("date")}
|
||||||
|
/>
|
||||||
|
<input type="checkbox" hidden {...register("checked")} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex cursor-pointer flex-col items-center gap-3">
|
<div
|
||||||
|
className="flex cursor-pointer flex-col items-center gap-3"
|
||||||
|
onClick={() => {
|
||||||
|
if (isEditModal) {
|
||||||
|
handleSubmit(saveTask)();
|
||||||
|
setIsEditModal(!isEditModal);
|
||||||
|
} else setIsEditModal(!isEditModal);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isEditModal ? (
|
||||||
|
<>
|
||||||
|
<InboxArrowDownIcon class="size-6" />
|
||||||
|
<p class="text-[0.7rem]">Сохранить</p>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{" "}
|
||||||
<PencilIcon class="size-6" />
|
<PencilIcon class="size-6" />
|
||||||
<p class="text-[0.7rem]">Редактировать</p>
|
<p class="text-[0.7rem]">Редактировать</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{errors.name && <p class="text-red-500">{errors.name.message}</p>}
|
||||||
|
{errors.description && <p class="text-red-500">{errors.description.message}</p>}
|
||||||
|
{errors.date && <p class="text-red-500">{errors.date.message}</p>}
|
||||||
|
{errors.tags && <p class="text-red-500">{errors.tags.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="flex h-full flex-row items-center gap-1 rounded-2xl bg-[rgba(251,194,199,0.38)] px-2 py-1"
|
class={cn("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,
|
||||||
|
})}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (!isEditModal) return;
|
||||||
setOpenModalCalendar(true);
|
setOpenModalCalendar(true);
|
||||||
setCalendarDate(editContent.date);
|
setCalendarDate(editContent.date);
|
||||||
}}
|
}}
|
||||||
@@ -121,10 +225,19 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
year: "numeric",
|
year: "numeric",
|
||||||
hour: "2-digit",
|
hour: "2-digit",
|
||||||
minute: "2-digit",
|
minute: "2-digit",
|
||||||
}).format(editContent.date)}
|
}).format(calendarDate!)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex h-full flex-col items-start gap-1 rounded-2xl bg-[rgba(251,194,199,0.38)] px-4 py-2">
|
<div
|
||||||
|
class={cn("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,
|
||||||
|
})}
|
||||||
|
onClick={() => {
|
||||||
|
if (!isEditModal) return;
|
||||||
|
setTags({ first: editContent.tags[0], second: editContent.tags[1] });
|
||||||
|
setOpenModalTags(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<p class="flex flex-row gap-2">
|
<p class="flex flex-row gap-2">
|
||||||
<BookOpenIcon class="size-5" />
|
<BookOpenIcon class="size-5" />
|
||||||
{editContent.tags[0]}
|
{editContent.tags[0]}
|
||||||
@@ -135,20 +248,39 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
)}
|
)}
|
||||||
{isCreating && (
|
{isCreating && (
|
||||||
<div class="flex h-full w-full flex-col items-start justify-between">
|
<form
|
||||||
<div class="flex w-full flex-row items-start justify-between">
|
class="flex h-full w-full flex-col items-start justify-between"
|
||||||
<div class="me-4 flex flex-1 flex-col gap-1">
|
onSubmit={(e) => {
|
||||||
<input class="text-2xl outline-0" maxLength={20} placeholder="Название" ref={taskNameRef} />
|
e.preventDefault();
|
||||||
<textarea
|
handleSubmit((data) => saveTask({ ...data, id: uuid() }))();
|
||||||
class="h-[5rem] w-full resize-none outline-0"
|
}}
|
||||||
maxLength={200}
|
>
|
||||||
placeholder="Описание"
|
<div class="flex w-full flex-1 flex-row items-start justify-between">
|
||||||
ref={taskDescriptionRef}
|
<div class="me-4 flex h-full flex-1 flex-col gap-1">
|
||||||
|
<input
|
||||||
|
class="text-2xl outline-0"
|
||||||
|
maxLength={20}
|
||||||
|
placeholder="Название"
|
||||||
|
{...register("name", { required: "Заполните название" })}
|
||||||
/>
|
/>
|
||||||
|
<textarea
|
||||||
|
class="mb-10 w-full flex-1 resize-none outline-0"
|
||||||
|
placeholder="Описание"
|
||||||
|
maxLength={200}
|
||||||
|
{...register("description")}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="datetime-local"
|
||||||
|
value={calendarDate ? calendarDate.toISOString().slice(0, 16) : ""}
|
||||||
|
hidden
|
||||||
|
{...register("date")}
|
||||||
|
/>
|
||||||
|
<input type="checkbox" checked={false} hidden {...register("checked")} />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-row gap-3 self-start">
|
||||||
<CalendarDaysIcon
|
<CalendarDaysIcon
|
||||||
class="size-10 cursor-pointer"
|
class="size-10 cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -156,9 +288,13 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
setCalendarDate(calendarDate ?? new Date());
|
setCalendarDate(calendarDate ?? new Date());
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<BookmarkIcon class="ms-4 size-10 cursor-pointer" />
|
<BookmarkIcon class="ms-4 size-10 cursor-pointer" onClick={() => setOpenModalTags(true)} />
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-8 flex h-16 flex-col items-center gap-6 self-center md:mb-0 md:flex-row">
|
</div>
|
||||||
|
{errors.name && <p class="text-red-500">{errors.name.message}</p>}
|
||||||
|
{errors.date && <p class="text-red-500">{errors.date.message}</p>}
|
||||||
|
{errors.tags && <p class="text-red-500">{errors.tags.message}</p>}
|
||||||
|
<div className="mb-8 flex h-16 flex-col items-center gap-6 self-center md:mb-0 md:flex-row md:self-start">
|
||||||
<Button
|
<Button
|
||||||
className="text-sm"
|
className="text-sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -167,36 +303,11 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
>
|
>
|
||||||
Отмена
|
Отмена
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button color="red" type="submit">
|
||||||
color="red"
|
|
||||||
onClick={() => {
|
|
||||||
if (taskNameRef.current && taskDescriptionRef.current) {
|
|
||||||
if (!taskNameRef.current.value || !taskDescriptionRef.current.value) {
|
|
||||||
alert("Заполните все поля");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!calendarDate) {
|
|
||||||
alert("Заполните дату и время");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const task: ITask = {
|
|
||||||
id: tasks.length + 1,
|
|
||||||
name: taskNameRef.current.value,
|
|
||||||
description: taskDescriptionRef.current.value,
|
|
||||||
date: calendarDate,
|
|
||||||
checked: false,
|
|
||||||
tags: ["Математика", "Домашнее задание"],
|
|
||||||
};
|
|
||||||
setTasks([...tasks, task]);
|
|
||||||
setIsOpen(false);
|
|
||||||
setCalendarDate(null);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Добавить задачу
|
Добавить задачу
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
)}
|
)}
|
||||||
</ModalWindow>
|
</ModalWindow>
|
||||||
{tasks.length > 0 ? (
|
{tasks.length > 0 ? (
|
||||||
@@ -214,11 +325,15 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
setIsOpen(true);
|
setIsOpen(true);
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
setEditContent(task);
|
setEditContent(task);
|
||||||
|
setCalendarDate(task.date);
|
||||||
|
}}
|
||||||
|
onMarkClick={() => {
|
||||||
|
setTasks(tasks.map((t) => (t.id === task.id ? { ...t, checked: !t.checked } : t)));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div class="group fixed right-[22rem] bottom-4 hidden flex-row items-center justify-start space-x-3 overflow-x-hidden py-2 md:flex">
|
<div class="group fixed right-1 bottom-16 flex flex-row items-center justify-start space-x-3 overflow-x-hidden py-2 md:right-[22rem] md:bottom-4">
|
||||||
<div
|
<div
|
||||||
class="flex aspect-square h-20 cursor-pointer items-center justify-center rounded-full bg-[rgb(251,194,199,0.53)] text-9xl text-white shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] transition-all duration-300 ease-out group-hover:ml-[12rem] hover:bg-[rgb(251,194,199,0.7)]"
|
class="flex aspect-square h-20 cursor-pointer items-center justify-center rounded-full bg-[rgb(251,194,199,0.53)] text-9xl text-white shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] transition-all duration-300 ease-out group-hover:ml-[12rem] hover:bg-[rgb(251,194,199,0.7)]"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -228,7 +343,7 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
>
|
>
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute left-0 my-auto flex flex-row space-x-3 opacity-0 transition-opacity duration-100 group-hover:opacity-100">
|
<div class="absolute left-0 my-auto hidden flex-row space-x-3 opacity-0 transition-opacity duration-100 group-hover:opacity-100 md:flex">
|
||||||
<div class="pointer-events-none flex aspect-square h-20 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)] group-hover:pointer-events-auto hover:bg-[rgba(206,232,251,0.9)]">
|
<div class="pointer-events-none flex aspect-square h-20 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)] group-hover:pointer-events-auto hover:bg-[rgba(206,232,251,0.9)]">
|
||||||
<MagnifyingGlassIcon class="size-12" />
|
<MagnifyingGlassIcon class="size-12" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user