Compare commits
12 Commits
form
...
5c13774e63
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c13774e63 | |||
| 5c0a7a1b5c | |||
| 5086b64200 | |||
| a2fe9bcfd7 | |||
| ef4d1be2bc | |||
| 4ff0b441f3 | |||
| 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",
|
||||||
|
|||||||
678
repomix-output.xml
Normal file
678
repomix-output.xml
Normal file
@@ -0,0 +1,678 @@
|
|||||||
|
This file is a merged representation of a subset of the codebase, containing files not matching ignore patterns, combined into a single document by Repomix.
|
||||||
|
|
||||||
|
<file_summary>
|
||||||
|
This section contains a summary of this file.
|
||||||
|
|
||||||
|
<purpose>
|
||||||
|
This file contains a packed representation of the entire repository's contents.
|
||||||
|
It is designed to be easily consumable by AI systems for analysis, code review,
|
||||||
|
or other automated processes.
|
||||||
|
</purpose>
|
||||||
|
|
||||||
|
<file_format>
|
||||||
|
The content is organized as follows:
|
||||||
|
1. This summary section
|
||||||
|
2. Repository information
|
||||||
|
3. Directory structure
|
||||||
|
4. Repository files, each consisting of:
|
||||||
|
- File path as an attribute
|
||||||
|
- Full contents of the file
|
||||||
|
</file_format>
|
||||||
|
|
||||||
|
<usage_guidelines>
|
||||||
|
- This file should be treated as read-only. Any changes should be made to the
|
||||||
|
original repository files, not this packed version.
|
||||||
|
- When processing this file, use the file path to distinguish
|
||||||
|
between different files in the repository.
|
||||||
|
- Be aware that this file may contain sensitive information. Handle it with
|
||||||
|
the same level of security as you would the original repository.
|
||||||
|
</usage_guidelines>
|
||||||
|
|
||||||
|
<notes>
|
||||||
|
- Some files may have been excluded based on .gitignore rules and Repomix's configuration
|
||||||
|
- Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files
|
||||||
|
- Files matching these patterns are excluded: bun.lock, node_modules/, .vscode/
|
||||||
|
- Files matching patterns in .gitignore are excluded
|
||||||
|
- Files matching default ignore patterns are excluded
|
||||||
|
- Files are sorted by Git change count (files with more changes are at the bottom)
|
||||||
|
</notes>
|
||||||
|
|
||||||
|
<additional_info>
|
||||||
|
|
||||||
|
</additional_info>
|
||||||
|
|
||||||
|
</file_summary>
|
||||||
|
|
||||||
|
<directory_structure>
|
||||||
|
public/
|
||||||
|
vite.svg
|
||||||
|
src/
|
||||||
|
assets/
|
||||||
|
preact.svg
|
||||||
|
components/
|
||||||
|
ui/
|
||||||
|
Button.module.scss
|
||||||
|
Button.tsx
|
||||||
|
Input.module.scss
|
||||||
|
Input.tsx
|
||||||
|
layout.tsx
|
||||||
|
menu.module.scss
|
||||||
|
menu.tsx
|
||||||
|
pages/
|
||||||
|
login.module.scss
|
||||||
|
login.tsx
|
||||||
|
profile.module.scss
|
||||||
|
profile.tsx
|
||||||
|
providers/
|
||||||
|
AuthProvider.tsx
|
||||||
|
utils/
|
||||||
|
class-merge.ts
|
||||||
|
app.module.scss
|
||||||
|
app.tsx
|
||||||
|
index.scss
|
||||||
|
main.tsx
|
||||||
|
vite-env.d.ts
|
||||||
|
.gitattributes
|
||||||
|
.gitignore
|
||||||
|
.prettierrc
|
||||||
|
eslint.config.mjs
|
||||||
|
index.html
|
||||||
|
package.json
|
||||||
|
postcss.config.mts
|
||||||
|
tsconfig.app.json
|
||||||
|
tsconfig.json
|
||||||
|
tsconfig.node.json
|
||||||
|
vite.config.ts
|
||||||
|
</directory_structure>
|
||||||
|
|
||||||
|
<files>
|
||||||
|
This section contains the contents of the repository's files.
|
||||||
|
|
||||||
|
<file path="src/providers/AuthProvider.tsx">
|
||||||
|
import { signal, Signal } from "@preact/signals";
|
||||||
|
import { createContext, JSX } from "preact";
|
||||||
|
import { useContext } from "preact/hooks";
|
||||||
|
|
||||||
|
interface AppContextValue {
|
||||||
|
isLoggedIn: Signal<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppContext = createContext<AppContextValue>({
|
||||||
|
isLoggedIn: signal(false),
|
||||||
|
});
|
||||||
|
|
||||||
|
const AppProvider = ({ children }: { children: JSX.Element }) => {
|
||||||
|
const value: AppContextValue = {
|
||||||
|
isLoggedIn: signal(false),
|
||||||
|
};
|
||||||
|
|
||||||
|
return <AppContext.Provider value={value}>{children}</AppContext.Provider>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const useAppContext = () => {
|
||||||
|
const context = useContext(AppContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("useAppContext must be used within AppProvider");
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { AppProvider, useAppContext };
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="public/vite.svg">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/assets/preact.svg">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="27.68" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 296"><path fill="#673AB8" d="m128 0l128 73.9v147.8l-128 73.9L0 221.7V73.9z"></path><path fill="#FFF" d="M34.865 220.478c17.016 21.78 71.095 5.185 122.15-34.704c51.055-39.888 80.24-88.345 63.224-110.126c-17.017-21.78-71.095-5.184-122.15 34.704c-51.055 39.89-80.24 88.346-63.224 110.126Zm7.27-5.68c-5.644-7.222-3.178-21.402 7.573-39.253c11.322-18.797 30.541-39.548 54.06-57.923c23.52-18.375 48.303-32.004 69.281-38.442c19.922-6.113 34.277-5.075 39.92 2.148c5.644 7.223 3.178 21.403-7.573 39.254c-11.322 18.797-30.541 39.547-54.06 57.923c-23.52 18.375-48.304 32.004-69.281 38.441c-19.922 6.114-34.277 5.076-39.92-2.147Z"></path><path fill="#FFF" d="M220.239 220.478c17.017-21.78-12.169-70.237-63.224-110.126C105.96 70.464 51.88 53.868 34.865 75.648c-17.017 21.78 12.169 70.238 63.224 110.126c51.055 39.889 105.133 56.485 122.15 34.704Zm-7.27-5.68c-5.643 7.224-19.998 8.262-39.92 2.148c-20.978-6.437-45.761-20.066-69.28-38.441c-23.52-18.376-42.74-39.126-54.06-57.923c-10.752-17.851-13.218-32.03-7.575-39.254c5.644-7.223 19.999-8.261 39.92-2.148c20.978 6.438 45.762 20.067 69.281 38.442c23.52 18.375 42.739 39.126 54.06 57.923c10.752 17.85 13.218 32.03 7.574 39.254Z"></path><path fill="#FFF" d="M127.552 167.667c10.827 0 19.603-8.777 19.603-19.604c0-10.826-8.776-19.603-19.603-19.603c-10.827 0-19.604 8.777-19.604 19.603c0 10.827 8.777 19.604 19.604 19.604Z"></path></svg>
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/layout.tsx">
|
||||||
|
import { useAppContext } from "@/providers/AuthProvider";
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import { Route, Router, useLocation } from "preact-iso";
|
||||||
|
import { useEffect } from "preact/hooks";
|
||||||
|
import Menu from "./menu";
|
||||||
|
|
||||||
|
const Layout: FunctionComponent = () => {
|
||||||
|
const { isLoggedIn } = useAppContext();
|
||||||
|
const location = useLocation();
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(isLoggedIn.value);
|
||||||
|
}, [isLoggedIn]);
|
||||||
|
return (
|
||||||
|
<div class="flex min-w-screen flex-row justify-between">
|
||||||
|
<div class="w-full overflow-x-auto">
|
||||||
|
<Router>
|
||||||
|
<Route
|
||||||
|
path="/"
|
||||||
|
component={() => {
|
||||||
|
// location.route("/settings");
|
||||||
|
return <h1>Home</h1>;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Route path="/settings" component={() => <h1>Test</h1>} />
|
||||||
|
<Route path="/tasks" component={() => <h1>Test2</h1>} />
|
||||||
|
<Route default component={() => <h1>404</h1>} />
|
||||||
|
</Router>
|
||||||
|
</div>
|
||||||
|
<Menu />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Layout;
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/pages/profile.module.scss">
|
||||||
|
@reference "../index.scss";
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/pages/profile.tsx">
|
||||||
|
import Layout from "@/components/layout";
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
|
||||||
|
const ProfilePage: FunctionComponent = () => {
|
||||||
|
return <Layout />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProfilePage;
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/utils/class-merge.ts">
|
||||||
|
import { ClassValue, clsx } from "clsx";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
|
export function cn(...inputs: ClassValue[]) {
|
||||||
|
return twMerge(clsx(...inputs));
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/app.module.scss">
|
||||||
|
@reference "./index.scss";
|
||||||
|
|
||||||
|
.text {
|
||||||
|
@apply text-9xl text-red-500;
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/main.tsx">
|
||||||
|
import { render } from "preact";
|
||||||
|
import { App } from "./app.tsx";
|
||||||
|
import "./index.scss";
|
||||||
|
|
||||||
|
render(<App />, document.getElementById("app")!);
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/vite-env.d.ts">
|
||||||
|
/// <reference types="vite/client" />
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path=".gitattributes">
|
||||||
|
* text=auto
|
||||||
|
bun.lock binary
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path=".gitignore">
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/settings.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="eslint.config.mjs">
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
import eslint from "@eslint/js";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
|
||||||
|
export default tseslint.config({
|
||||||
|
extends: [eslint.configs.recommended, tseslint.configs.recommended],
|
||||||
|
ignores: ["*.d.ts"],
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
sourceType: "module",
|
||||||
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es6: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="postcss.config.mts">
|
||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
"@tailwindcss/postcss": {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="tsconfig.app.json">
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
"target": "ES2020",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"module": "ESNext",
|
||||||
|
"lib": [
|
||||||
|
"ES2020",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"paths": {
|
||||||
|
"react": [
|
||||||
|
"./node_modules/preact/compat/"
|
||||||
|
],
|
||||||
|
"react-dom": [
|
||||||
|
"./node_modules/preact/compat/"
|
||||||
|
],
|
||||||
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"jsxImportSource": "preact",
|
||||||
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedSideEffectImports": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="tsconfig.json">
|
||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{ "path": "./tsconfig.app.json" },
|
||||||
|
{ "path": "./tsconfig.node.json" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="tsconfig.node.json">
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
"target": "ES2022",
|
||||||
|
"lib": ["ES2023"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
|
||||||
|
/* Bundler mode */
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noUncheckedSideEffectImports": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts"]
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="vite.config.ts">
|
||||||
|
import preact from '@preact/preset-vite';
|
||||||
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import tsConfigPaths from 'vite-tsconfig-paths';
|
||||||
|
|
||||||
|
// https://vite.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [preact(), tailwindcss(), tsConfigPaths()],
|
||||||
|
});
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/ui/Button.module.scss">
|
||||||
|
@reference '../../index.scss';
|
||||||
|
|
||||||
|
.button {
|
||||||
|
@apply rounded-2xl border-2 py-3 font-semibold text-white transition-colors hover:cursor-pointer;
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/ui/Button.tsx">
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import { tv } from "tailwind-variants";
|
||||||
|
import classes from "./Button.module.scss";
|
||||||
|
const button = tv({
|
||||||
|
base: classes.button,
|
||||||
|
variants: {
|
||||||
|
color: {
|
||||||
|
primary: "bg-blue-400 hover:bg-blue-500",
|
||||||
|
secondary: "bg-red-400 hover:bg-red-500",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const Button: FunctionComponent<{ onClick: () => void }> = (props) => {
|
||||||
|
return (
|
||||||
|
<button type="button" class={button({ color: "primary" })} onClick={props.onClick}>
|
||||||
|
{props.children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Button;
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/ui/Input.tsx">
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import { tv } from "tailwind-variants";
|
||||||
|
import classes from "./Input.module.scss";
|
||||||
|
|
||||||
|
const input = tv({
|
||||||
|
base: classes.input_field,
|
||||||
|
variants: {
|
||||||
|
"text-align": {
|
||||||
|
center: "text-center",
|
||||||
|
left: "text-left",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
"text-align": "left",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface InputProps {
|
||||||
|
isPassword?: boolean;
|
||||||
|
placeholder?: string;
|
||||||
|
textAlign?: "center" | "left";
|
||||||
|
}
|
||||||
|
|
||||||
|
const Input: FunctionComponent<InputProps> = ({ isPassword = false, placeholder = "", textAlign }: InputProps) => {
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
type={isPassword ? "password" : "text"}
|
||||||
|
class={input({ "text-align": textAlign })}
|
||||||
|
placeholder={placeholder}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Input;
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/menu.module.scss">
|
||||||
|
@reference "../index.scss";
|
||||||
|
|
||||||
|
.menu_container {
|
||||||
|
@apply flex min-h-8 min-w-screen flex-col items-center gap-4 border-l border-l-gray-500 px-5 pt-5 md:min-h-screen md:min-w-[300px];
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu_item {
|
||||||
|
@apply w-full cursor-pointer rounded-md px-6 py-2 text-center hover:bg-gray-200;
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/menu.tsx">
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import { useLocation } from "preact-iso";
|
||||||
|
import { tv } from "tailwind-variants";
|
||||||
|
import classes from "./menu.module.scss";
|
||||||
|
|
||||||
|
interface MenuItemProps {
|
||||||
|
title: string;
|
||||||
|
link: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MenuItem: FunctionComponent<MenuItemProps> = ({ title, link }: MenuItemProps) => {
|
||||||
|
const location = useLocation();
|
||||||
|
const active = location.path === link;
|
||||||
|
const menuItemClasses = tv({
|
||||||
|
base: classes.menu_item,
|
||||||
|
variants: {
|
||||||
|
activity: {
|
||||||
|
active: "bg-gray-200",
|
||||||
|
inactive: "bg-gray-100",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
activity: "inactive",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div class={menuItemClasses({ activity: active ? "active" : "inactive" })} onClick={() => location.route(link)}>
|
||||||
|
{title}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface MenuItems {
|
||||||
|
title: string;
|
||||||
|
link: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Menu: FunctionComponent = () => {
|
||||||
|
const menu_items: MenuItems[] = [
|
||||||
|
{
|
||||||
|
title: "Профиль",
|
||||||
|
link: "/profile",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Задачи",
|
||||||
|
link: "/tasks",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Календарь",
|
||||||
|
link: "/calendar",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<div class={classes.menu_container}>
|
||||||
|
{menu_items.map(({ title, link }) => (
|
||||||
|
<MenuItem title={title} link={link} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Menu;
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/pages/login.module.scss">
|
||||||
|
@reference "../index.scss";
|
||||||
|
|
||||||
|
.login_container {
|
||||||
|
@apply flex min-h-screen flex-col items-center justify-center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login_card {
|
||||||
|
@apply flex w-[95%] min-w-[300px] flex-col justify-center gap-2 rounded-md border-gray-400 p-5 shadow-md md:w-[350px];
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/pages/login.tsx">
|
||||||
|
import Button from "@/components/ui/Button";
|
||||||
|
import Input from "@/components/ui/Input";
|
||||||
|
import { useAppContext } from "@/providers/AuthProvider";
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import { useLocation } from "preact-iso";
|
||||||
|
import classes from "./login.module.scss";
|
||||||
|
const LoginPage: FunctionComponent = () => {
|
||||||
|
const { isLoggedIn } = useAppContext();
|
||||||
|
const location = useLocation();
|
||||||
|
return (
|
||||||
|
<div class={classes.login_container}>
|
||||||
|
<div class={classes.login_card}>
|
||||||
|
<Input placeholder="Login" textAlign="center" />
|
||||||
|
<Input isPassword placeholder="Password" textAlign="center" />
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
isLoggedIn.value = true;
|
||||||
|
location.route("/profile/settings");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LoginPage;
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/index.scss">
|
||||||
|
@import "tailwindcss";
|
||||||
|
@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
|
||||||
|
:root {
|
||||||
|
font-family: "Montserrat", sans-serif;
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="index.html">
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Антихвост</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/components/ui/Input.module.scss">
|
||||||
|
@reference "../../index.scss";
|
||||||
|
|
||||||
|
.input_field {
|
||||||
|
@apply rounded-md border border-gray-300 p-2 placeholder:transition focus:outline-0 focus:placeholder:opacity-25;
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="src/app.tsx">
|
||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import { ErrorBoundary, lazy, LocationProvider, Route, Router, useLocation } from "preact-iso";
|
||||||
|
import "preact/debug";
|
||||||
|
import LoginPage from "./pages/login";
|
||||||
|
import { AppProvider } from "./providers/AuthProvider";
|
||||||
|
|
||||||
|
const HomePage: FunctionComponent = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
location.route("/login");
|
||||||
|
return <div>Redirecting to login...</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function App() {
|
||||||
|
return (
|
||||||
|
<AppProvider>
|
||||||
|
<LocationProvider>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<Router>
|
||||||
|
<Route path="/" component={HomePage} />
|
||||||
|
<Route path="/login" component={LoginPage} />
|
||||||
|
<Route path="/profile/*" component={lazy(() => import("./pages/profile"))} />
|
||||||
|
</Router>
|
||||||
|
</ErrorBoundary>
|
||||||
|
</LocationProvider>
|
||||||
|
</AppProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path=".prettierrc">
|
||||||
|
{
|
||||||
|
"tabWidth": 2,
|
||||||
|
"printWidth": 120,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"singleQuote": false,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"useTabs": false,
|
||||||
|
"semi": true,
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"plugins": ["prettier-plugin-tailwindcss"],
|
||||||
|
"tailwindFunctions": ["tv"]
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<file path="package.json">
|
||||||
|
{
|
||||||
|
"name": "anti-hvost",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "tsc -b && vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@preact/signals": "^2.0.2",
|
||||||
|
"@tailwindcss/postcss": "^4.0.17",
|
||||||
|
"@tailwindcss/vite": "^4.0.17",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"postcss": "^8.5.3",
|
||||||
|
"preact": "^10.26.2",
|
||||||
|
"preact-iso": "^2.9.1",
|
||||||
|
"tailwind-merge": "^3.0.2",
|
||||||
|
"tailwind-variants": "^1.0.0",
|
||||||
|
"tailwindcss": "^4.0.17"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.23.0",
|
||||||
|
"@preact/preset-vite": "^2.10.1",
|
||||||
|
"@typescript-eslint/parser": "^8.28.0",
|
||||||
|
"eslint": "^9.23.0",
|
||||||
|
"eslint-config-prettier": "^10.1.1",
|
||||||
|
"prettier": "^3.5.3",
|
||||||
|
"prettier-eslint": "^16.3.0",
|
||||||
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||||
|
"sass-embedded": "^1.86.0",
|
||||||
|
"typescript": "~5.7.2",
|
||||||
|
"typescript-eslint": "^8.28.0",
|
||||||
|
"vite": "^6.2.0",
|
||||||
|
"vite-tsconfig-paths": "^5.1.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</file>
|
||||||
|
|
||||||
|
</files>
|
||||||
@@ -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-full left-0 mt-3 ml-2 flex h-fit w-[18rem] flex-col items-center rounded-[4rem] bg-white px-8 py-4 text-xs md:top-0 md:left-full md:mt-0 md:ml-5">
|
||||||
|
<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-full left-0 mt-3 ml-2 flex h-fit w-[18rem] flex-col items-center rounded-[4rem] bg-white px-8 py-4 text-xs md:top-0 md:left-full md:mt-0 md:ml-5">
|
||||||
|
<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}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { FunctionComponent, h } from "preact";
|
|||||||
import { useLocation } from "preact-iso";
|
import { useLocation } from "preact-iso";
|
||||||
import { tv } from "tailwind-variants";
|
import { tv } from "tailwind-variants";
|
||||||
import classes from "./menu.module.scss";
|
import classes from "./menu.module.scss";
|
||||||
|
import { calculatePoints, getCurrentStatus } from "@/utils/status-system";
|
||||||
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
interface MenuItemProps {
|
interface MenuItemProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -34,9 +36,33 @@ const MenuItem: FunctionComponent<MenuItemProps> = ({ title, link, icon }: MenuI
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const Avatar: FunctionComponent = () => {
|
const Avatar: FunctionComponent = () => {
|
||||||
|
const [status, setStatus] = useState("");
|
||||||
const { route, path } = useLocation();
|
const { route, path } = useLocation();
|
||||||
//TODO: Move styles to scss module
|
|
||||||
|
useEffect(() => {
|
||||||
|
const updateStatus = () => {
|
||||||
|
const tasks = JSON.parse(localStorage.getItem("tasks") || "[]");
|
||||||
|
const completedTasks = tasks.filter((task: { checked: boolean }) => task.checked).length;
|
||||||
|
const points = calculatePoints(completedTasks);
|
||||||
|
setStatus(getCurrentStatus(points));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial update
|
||||||
|
updateStatus();
|
||||||
|
|
||||||
|
// Update when tasks change
|
||||||
|
const handleStorage = (e: StorageEvent) => {
|
||||||
|
if (e.key === "tasks") {
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('storage', handleStorage);
|
||||||
|
return () => window.removeEventListener('storage', handleStorage);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
onClick={() => route("/profile/settings")}
|
onClick={() => route("/profile/settings")}
|
||||||
@@ -52,7 +78,7 @@ const Avatar: FunctionComponent = () => {
|
|||||||
<div class="my-5 aspect-square h-full rounded-full bg-white"></div>
|
<div class="my-5 aspect-square h-full rounded-full bg-white"></div>
|
||||||
<div class="flex flex-col items-center justify-center">
|
<div class="flex flex-col items-center justify-center">
|
||||||
<p class="text-3xl font-semibold">никнейм</p>
|
<p class="text-3xl font-semibold">никнейм</p>
|
||||||
<div class="rounded-[1rem] bg-white px-5 leading-5 font-light italic">статус</div>
|
<div class="rounded-[1rem] bg-white px-5 leading-5 font-light italic">{status}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -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,25 @@ const markStyle = tv({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {} }: TaskProps) => {
|
const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {}, onMarkClick = () => {} }) => {
|
||||||
return (
|
return (
|
||||||
// Временное действие для тестирования
|
<div class="w-[95%]">
|
||||||
<button onClick={onClick} class="w-[95%]">
|
<div class={classes.task} onClick={onClick}>
|
||||||
<div class={classes.task}>
|
<div
|
||||||
<div class={taskStyle({ checked })}>
|
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;
|
||||||
|
|||||||
52
src/components/ui/Dialog.tsx
Normal file
52
src/components/ui/Dialog.tsx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import { FunctionComponent } from "preact";
|
||||||
|
import Button from "./Button";
|
||||||
|
|
||||||
|
interface DialogProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
setIsOpen: (isOpen: boolean) => void;
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
onConfirm: () => void;
|
||||||
|
confirmText?: string;
|
||||||
|
cancelText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Dialog: FunctionComponent<DialogProps> = ({
|
||||||
|
isOpen,
|
||||||
|
setIsOpen,
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
onConfirm,
|
||||||
|
confirmText = "Подтвердить",
|
||||||
|
cancelText = "Отмена",
|
||||||
|
}) => {
|
||||||
|
if (!isOpen) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="fixed inset-0 z-50 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>
|
||||||
|
<div class="flex justify-end gap-4">
|
||||||
|
<Button
|
||||||
|
onClick={() => setIsOpen(false)}
|
||||||
|
className="bg-gray-200 text-gray-800 hover:bg-gray-300"
|
||||||
|
>
|
||||||
|
{cancelText}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
onConfirm();
|
||||||
|
setIsOpen(false);
|
||||||
|
}}
|
||||||
|
color="red"
|
||||||
|
>
|
||||||
|
{confirmText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Dialog;
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
|
@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
|
||||||
:root {
|
:root {
|
||||||
|
color: black;
|
||||||
|
background-color: white;
|
||||||
font-family: "Montserrat", sans-serif;
|
font-family: "Montserrat", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,15 +1,408 @@
|
|||||||
import BigCalendar from "@/components/calendar";
|
|
||||||
import { withTitle } from "@/constructors/Component";
|
import { withTitle } from "@/constructors/Component";
|
||||||
import { UrlsTitle } from "@/enums/urls";
|
import { UrlsTitle } from "@/enums/urls";
|
||||||
import { FunctionComponent } from "preact";
|
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 {
|
||||||
|
PencilIcon,
|
||||||
|
InboxArrowDownIcon,
|
||||||
|
CalendarDaysIcon,
|
||||||
|
BookOpenIcon,
|
||||||
|
DocumentDuplicateIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from "@heroicons/react/24/outline";
|
||||||
|
import Dialog from "@/components/ui/Dialog";
|
||||||
|
|
||||||
|
const example_tags: { first: string[]; second: string[] } = {
|
||||||
|
first: ["Программирование", "Информатика", "Физика", "Математика"],
|
||||||
|
second: ["Лабораторная работа", "Практическая работа", "Домашнее задание", "Экзамен"],
|
||||||
|
};
|
||||||
|
|
||||||
|
const calendarStyles = {
|
||||||
|
root: "inline-flex w-full relative",
|
||||||
|
input: "font-sans text-base text-gray-600 bg-white p-3",
|
||||||
|
panel: "bg-white min-w-full p-2",
|
||||||
|
header: "flex items-center justify-between p-2 text-gray-700 font-semibold m-0 mb-4",
|
||||||
|
title: "leading-8 mx-auto text-xl",
|
||||||
|
previousButton: "flex items-center justify-center cursor-pointer w-8 h-8 text-gray-600",
|
||||||
|
nextButton: "flex items-center justify-center cursor-pointer w-8 h-8 text-gray-600",
|
||||||
|
table: "border-collapse w-full",
|
||||||
|
tableHeaderCell: "p-2 text-center",
|
||||||
|
weekDay: "text-gray-600 font-normal pb-4",
|
||||||
|
monthTitle: "text-gray-700 font-semibold mr-2",
|
||||||
|
yearTitle: "text-gray-700 font-semibold",
|
||||||
|
monthPicker: "grid grid-cols-3 gap-2",
|
||||||
|
yearPicker: "grid grid-cols-2 gap-2",
|
||||||
|
month:
|
||||||
|
"p-2 text-center cursor-pointer rounded-lg hover:bg-[rgba(251,194,199,0.1)] [&.p-highlight]:bg-[rgba(251,194,199,0.2)]",
|
||||||
|
year: "p-2 text-center cursor-pointer rounded-lg hover:bg-[rgba(251,194,199,0.1)] [&.p-highlight]:bg-[rgba(251,194,199,0.2)]",
|
||||||
|
};
|
||||||
|
|
||||||
const ProfileCalendar: FunctionComponent = () => {
|
const ProfileCalendar: FunctionComponent = () => {
|
||||||
const onDateSelect = (date: Date) => {
|
const [currentDate, setCurrentDate] = useState(new Date());
|
||||||
console.log(date);
|
const [tasks, setTasks] = useState<ITask[]>([]);
|
||||||
|
const [selectedTasks, setSelectedTasks] = useState<ITask[]>([]);
|
||||||
|
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 [editContent, setEditContent] = useState<ITask | null>(null);
|
||||||
|
const [calendarDate, setCalendarDate] = useState<Nullable<Date>>();
|
||||||
|
const [tags, setTags] = useState<ITags>({ first: "", second: "" });
|
||||||
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
register,
|
||||||
|
reset,
|
||||||
|
setError,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<ITaskForm>({
|
||||||
|
defaultValues: {
|
||||||
|
tags: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const storedTasks = localStorage.getItem("tasks");
|
||||||
|
if (storedTasks) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const parsedTasks: ITask[] = JSON.parse(storedTasks).map((task: any) => ({
|
||||||
|
...task,
|
||||||
|
date: new Date(task.date),
|
||||||
|
}));
|
||||||
|
setTasks(parsedTasks);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
const handleDeleteTask = () => {
|
||||||
|
if (!editContent) return;
|
||||||
|
setTasks(tasks.filter((task) => task.id !== editContent.id));
|
||||||
|
setIsOpen(false);
|
||||||
|
setShowDeleteDialog(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!currentDate) return;
|
||||||
|
|
||||||
|
const tasksForDate = tasks.filter((task) => {
|
||||||
|
const taskDate = task.date;
|
||||||
|
return (
|
||||||
|
taskDate.getDate() === currentDate.getDate() &&
|
||||||
|
taskDate.getMonth() === currentDate.getMonth() &&
|
||||||
|
taskDate.getFullYear() === currentDate.getFullYear()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
setSelectedTasks(tasksForDate);
|
||||||
|
}, [currentDate, tasks]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (editContent) reset({ ...editContent, date: editContent.date.toISOString().slice(0, 16) });
|
||||||
|
else reset();
|
||||||
|
}, [editContent]);
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem("tasks", JSON.stringify(tasks));
|
||||||
|
}, [tasks]);
|
||||||
|
|
||||||
|
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]);
|
||||||
|
|
||||||
|
const hasTasksOnDate = (date: CalendarDateTemplateEvent) => {
|
||||||
|
return tasks.some((task) => {
|
||||||
|
const taskDate = task.date;
|
||||||
|
return (
|
||||||
|
taskDate.getDate() === date.day && taskDate.getMonth() === date.month && taskDate.getFullYear() === date.year
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const dateTemplate = (date: CalendarDateTemplateEvent) => {
|
||||||
|
const isHighlighted = hasTasksOnDate(date);
|
||||||
|
const isSelected =
|
||||||
|
currentDate &&
|
||||||
|
currentDate.getDate() === date.day &&
|
||||||
|
currentDate.getMonth() === date.month &&
|
||||||
|
currentDate.getFullYear() === date.year;
|
||||||
|
const isToday =
|
||||||
|
new Date().getDate() === date.day &&
|
||||||
|
new Date().getMonth() === date.month &&
|
||||||
|
new Date().getFullYear() === date.year;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"relative flex h-20 w-full cursor-pointer items-start justify-start rounded-lg p-2",
|
||||||
|
"hover:bg-[rgba(251,194,199,0.1)]",
|
||||||
|
{
|
||||||
|
"bg-[rgba(251,194,199,0.4)]": isSelected,
|
||||||
|
"bg-[rgba(251,194,199,0.2)]": isToday && !isSelected,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span>{date.day}</span>
|
||||||
|
{isHighlighted && <span className="absolute top-2 right-2 h-2 w-2 rounded-full bg-pink-400" />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTaskCheck = (taskId: string) => {
|
||||||
|
const updatedTasks = tasks.map((task) => (task.id === taskId ? { ...task, checked: !task.checked } : task));
|
||||||
|
setTasks(updatedTasks);
|
||||||
|
localStorage.setItem("tasks", JSON.stringify(updatedTasks));
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (date: Date) => {
|
||||||
|
return new Intl.DateTimeFormat("ru-RU", {
|
||||||
|
day: "numeric",
|
||||||
|
month: "long",
|
||||||
|
year: "numeric",
|
||||||
|
}).format(date);
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveTask = (data: ITaskForm) => {
|
||||||
|
if (!calendarDate) {
|
||||||
|
setError("date", { message: "Выберите дату" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
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: "" });
|
||||||
|
};
|
||||||
|
|
||||||
|
const pt = {
|
||||||
|
root: { className: calendarStyles.root },
|
||||||
|
input: { root: { className: calendarStyles.input } },
|
||||||
|
panel: { className: calendarStyles.panel },
|
||||||
|
header: { className: calendarStyles.header },
|
||||||
|
title: { className: calendarStyles.title },
|
||||||
|
previousButton: { className: calendarStyles.previousButton },
|
||||||
|
nextButton: { className: calendarStyles.nextButton },
|
||||||
|
table: { className: calendarStyles.table },
|
||||||
|
tableHeaderCell: { className: calendarStyles.tableHeaderCell },
|
||||||
|
weekDay: { className: calendarStyles.weekDay },
|
||||||
|
monthTitle: { className: calendarStyles.monthTitle },
|
||||||
|
yearTitle: { className: calendarStyles.yearTitle },
|
||||||
|
monthPicker: { className: calendarStyles.monthPicker },
|
||||||
|
yearPicker: { className: calendarStyles.yearPicker },
|
||||||
|
month: { className: calendarStyles.month },
|
||||||
|
year: { className: calendarStyles.year },
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="flex w-full flex-col items-center">
|
<div class="flex w-full flex-col items-center">
|
||||||
<BigCalendar onDateSelect={onDateSelect} />
|
<ModalTags
|
||||||
|
isOpen={openModalTags}
|
||||||
|
setIsOpen={setOpenModalTags}
|
||||||
|
tagsList={example_tags}
|
||||||
|
value={tags}
|
||||||
|
onClose={() => {
|
||||||
|
setTags({ first: "", second: "" });
|
||||||
|
}}
|
||||||
|
onChange={setTags}
|
||||||
|
/>
|
||||||
|
<ModalCalendar
|
||||||
|
isOpen={openModalCalendar}
|
||||||
|
setIsOpen={setOpenModalCalendar}
|
||||||
|
onClose={() => {
|
||||||
|
if (isEdit && !isEditModal) setCalendarDate(null);
|
||||||
|
}}
|
||||||
|
onChange={(e) => isEditModal && setCalendarDate(e.value)}
|
||||||
|
value={calendarDate!}
|
||||||
|
/>
|
||||||
|
<ModalWindow
|
||||||
|
isOpen={openModal}
|
||||||
|
setIsOpen={setIsOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsEdit(false);
|
||||||
|
setEditContent(null);
|
||||||
|
setIsEditModal(false);
|
||||||
|
setTags({ first: "", second: "" });
|
||||||
|
setCalendarDate(null);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isEdit && editContent && (
|
||||||
|
<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 flex-1 flex-col gap-1 pe-2">
|
||||||
|
<input
|
||||||
|
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 class="flex flex-row gap-4">
|
||||||
|
<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" />
|
||||||
|
<p class="text-[0.7rem]">Редактировать</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="flex cursor-pointer flex-col items-center gap-3"
|
||||||
|
onClick={() => setShowDeleteDialog(true)}
|
||||||
|
>
|
||||||
|
<TrashIcon class="size-6" />
|
||||||
|
<p class="text-[0.7rem]">Удалить</p>
|
||||||
|
</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={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={() => {
|
||||||
|
if (!isEditModal) return;
|
||||||
|
setOpenModalCalendar(true);
|
||||||
|
setCalendarDate(editContent.date);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CalendarDaysIcon class="size-10" />
|
||||||
|
<p>
|
||||||
|
{Intl.DateTimeFormat("ru-RU", {
|
||||||
|
day: "2-digit",
|
||||||
|
month: "2-digit",
|
||||||
|
year: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
}).format(calendarDate!)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<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">
|
||||||
|
<BookOpenIcon class="size-5" />
|
||||||
|
{editContent.tags[0]}
|
||||||
|
</p>
|
||||||
|
<p class="flex flex-row gap-2">
|
||||||
|
<DocumentDuplicateIcon class="size-5" />
|
||||||
|
{editContent.tags[1]}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</ModalWindow>
|
||||||
|
<Dialog
|
||||||
|
isOpen={showDeleteDialog}
|
||||||
|
setIsOpen={setShowDeleteDialog}
|
||||||
|
title="Удаление задачи"
|
||||||
|
content="Вы уверены, что хотите удалить эту задачу?"
|
||||||
|
onConfirm={handleDeleteTask}
|
||||||
|
confirmText="Удалить"
|
||||||
|
cancelText="Отмена"
|
||||||
|
/>
|
||||||
|
<Calendar
|
||||||
|
value={currentDate}
|
||||||
|
onChange={(e) => setCurrentDate(e ? e.value! : new Date())}
|
||||||
|
inline
|
||||||
|
pt={pt}
|
||||||
|
dateTemplate={dateTemplate}
|
||||||
|
className="[&_.p-datepicker]:!border-0 [&_.p-datepicker-calendar]:border-separate [&_.p-datepicker-calendar]:border-spacing-2 [&_td]:rounded-lg [&_td]:border [&_td]:border-[rgba(251,194,199,0.38)]"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="mt-8 w-full px-4">
|
||||||
|
<h2 class="mb-4 text-2xl font-semibold">Задачи на {formatDate(currentDate)}</h2>
|
||||||
|
{selectedTasks.length > 0 ? (
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
{selectedTasks.map((task) => (
|
||||||
|
<Task
|
||||||
|
key={task.id}
|
||||||
|
name={task.name}
|
||||||
|
checked={task.checked}
|
||||||
|
onClick={() => {
|
||||||
|
setIsOpen(true);
|
||||||
|
setIsEdit(true);
|
||||||
|
setEditContent(task);
|
||||||
|
setCalendarDate(task.date);
|
||||||
|
}}
|
||||||
|
onMarkClick={() => handleTaskCheck(task.id)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div class="rounded-lg bg-[rgba(251,194,199,0.2)] p-4 text-center">На этот день задач нет</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,22 +3,47 @@ import { withTitle } from "@/constructors/Component";
|
|||||||
import { UrlsTitle } from "@/enums/urls";
|
import { UrlsTitle } from "@/enums/urls";
|
||||||
import { useAppContext } from "@/providers/AuthProvider";
|
import { useAppContext } from "@/providers/AuthProvider";
|
||||||
import { cn } from "@/utils/class-merge";
|
import { cn } from "@/utils/class-merge";
|
||||||
|
import { calculatePoints, getCurrentStatus } from "@/utils/status-system";
|
||||||
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 classes from "./profile_settings.module.scss";
|
import classes from "./profile_settings.module.scss";
|
||||||
|
|
||||||
const ProfileSettings: FunctionComponent = () => {
|
const ProfileSettings: FunctionComponent = () => {
|
||||||
const { isLoggedIn } = useAppContext();
|
const { isLoggedIn } = useAppContext();
|
||||||
const { route } = useLocation();
|
const { route } = useLocation();
|
||||||
const status = 12;
|
const [status, setStatus] = useState(0);
|
||||||
const maxStatus = 100;
|
const maxStatus = 100;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const updateStatus = () => {
|
||||||
|
const tasks = JSON.parse(localStorage.getItem("tasks") || "[]");
|
||||||
|
const completedTasks = tasks.filter((task: { checked: boolean }) => task.checked).length;
|
||||||
|
const points = calculatePoints(completedTasks);
|
||||||
|
setStatus(points);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial update
|
||||||
|
updateStatus();
|
||||||
|
|
||||||
|
// Update when tasks change
|
||||||
|
const handleStorage = (e: StorageEvent) => {
|
||||||
|
if (e.key === "tasks") {
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('storage', handleStorage);
|
||||||
|
return () => window.removeEventListener('storage', handleStorage);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={classes.container}>
|
<div class={classes.container}>
|
||||||
<div class="flex w-full flex-col items-center rounded-[4rem] bg-[linear-gradient(180.00deg,rgb(251,194,199),rgba(206,232,251,0.72)_100%)] px-7 py-5 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] md:flex-row">
|
<div class="flex w-full flex-col items-center rounded-[4rem] bg-[linear-gradient(180.00deg,rgb(251,194,199),rgba(206,232,251,0.72)_100%)] px-7 py-5 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] md:flex-row">
|
||||||
<div id={classes.avatar}>Аватар</div>
|
<div id={classes.avatar}>Аватар</div>
|
||||||
<div class={classes.header_block__name}>
|
<div class={classes.header_block__name}>
|
||||||
<p class="text-4xl font-semibold">Никнейм</p>
|
<p class="text-4xl font-semibold">Никнейм</p>
|
||||||
<p class="text-2xl font-light">Статус</p>
|
<p class="text-2xl font-light">{getCurrentStatus(status)}</p>
|
||||||
<div class="h-1.5 w-full overflow-hidden rounded-2xl bg-white">
|
<div class="h-1.5 w-full overflow-hidden rounded-2xl bg-white">
|
||||||
<div
|
<div
|
||||||
class={cn("relative top-0 left-0 h-2 bg-black")}
|
class={cn("relative top-0 left-0 h-2 bg-black")}
|
||||||
|
|||||||
@@ -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,13 @@
|
|||||||
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 Dialog from "@/components/ui/Dialog";
|
||||||
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 +15,182 @@ import {
|
|||||||
CalendarDaysIcon,
|
CalendarDaysIcon,
|
||||||
DocumentDuplicateIcon,
|
DocumentDuplicateIcon,
|
||||||
FunnelIcon,
|
FunnelIcon,
|
||||||
|
InboxArrowDownIcon,
|
||||||
MagnifyingGlassIcon,
|
MagnifyingGlassIcon,
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
|
TrashIcon,
|
||||||
} 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 [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
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]);
|
||||||
|
|
||||||
|
const groupTasksByDate = useMemo(() => {
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
const tomorrow = new Date(today);
|
||||||
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
|
|
||||||
|
const groupedTasks = {
|
||||||
|
today: [] as ITask[],
|
||||||
|
tomorrow: [] as ITask[],
|
||||||
|
future: [] as { date: Date; tasks: ITask[] }[],
|
||||||
|
};
|
||||||
|
|
||||||
|
tasks.forEach((task) => {
|
||||||
|
const taskDate = new Date(task.date);
|
||||||
|
taskDate.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
if (taskDate.getTime() === today.getTime()) {
|
||||||
|
groupedTasks.today.push(task);
|
||||||
|
} else if (taskDate.getTime() === tomorrow.getTime()) {
|
||||||
|
groupedTasks.tomorrow.push(task);
|
||||||
|
} else if (taskDate > tomorrow) {
|
||||||
|
const existingGroup = groupedTasks.future.find((group) => group.date.getTime() === taskDate.getTime());
|
||||||
|
|
||||||
|
if (existingGroup) {
|
||||||
|
existingGroup.tasks.push(task);
|
||||||
|
} else {
|
||||||
|
groupedTasks.future.push({ date: taskDate, tasks: [task] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sort tasks within each group
|
||||||
|
groupedTasks.today.sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||||
|
groupedTasks.tomorrow.sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||||
|
groupedTasks.future.sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||||
|
groupedTasks.future.forEach((group) => {
|
||||||
|
group.tasks.sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||||
|
});
|
||||||
|
|
||||||
|
return groupedTasks;
|
||||||
|
}, [tasks]);
|
||||||
|
|
||||||
|
const formatDate = (date: Date) => {
|
||||||
|
return new Intl.DateTimeFormat("ru-RU", {
|
||||||
|
day: "numeric",
|
||||||
|
month: "long",
|
||||||
|
year: "numeric",
|
||||||
|
}).format(date);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteTask = () => {
|
||||||
|
if (!editContent) return;
|
||||||
|
setTasks(tasks.filter((task) => task.id !== editContent.id));
|
||||||
|
setIsOpen(false);
|
||||||
|
setShowDeleteDialog(false);
|
||||||
|
};
|
||||||
|
|
||||||
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 +200,89 @@ 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 class="flex flex-row gap-4">
|
||||||
<PencilIcon class="size-6" />
|
<div
|
||||||
<p class="text-[0.7rem]">Редактировать</p>
|
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" />
|
||||||
|
<p class="text-[0.7rem]">Редактировать</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="flex cursor-pointer flex-col items-center gap-3"
|
||||||
|
onClick={() => setShowDeleteDialog(true)}
|
||||||
|
>
|
||||||
|
<TrashIcon class="size-6" />
|
||||||
|
<p class="text-[0.7rem]">Удалить</p>
|
||||||
|
</div>
|
||||||
</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 +295,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,30 +318,53 @@ 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 class="flex flex-row gap-3 self-start">
|
||||||
|
<CalendarDaysIcon
|
||||||
|
class="size-10 cursor-pointer"
|
||||||
|
onClick={() => {
|
||||||
|
setOpenModalCalendar(true);
|
||||||
|
setCalendarDate(calendarDate ?? new Date());
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<BookmarkIcon class="ms-4 size-10 cursor-pointer" onClick={() => setOpenModalTags(true)} />
|
||||||
</div>
|
</div>
|
||||||
<CalendarDaysIcon
|
|
||||||
class="size-10 cursor-pointer"
|
|
||||||
onClick={() => {
|
|
||||||
setOpenModalCalendar(true);
|
|
||||||
setCalendarDate(calendarDate ?? new Date());
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<BookmarkIcon class="ms-4 size-10 cursor-pointer" />
|
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-8 flex h-16 flex-col items-center gap-6 self-center md:mb-0 md:flex-row">
|
{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,58 +373,92 @@ 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>
|
||||||
|
<Dialog
|
||||||
|
isOpen={showDeleteDialog}
|
||||||
|
setIsOpen={setShowDeleteDialog}
|
||||||
|
title="Удаление задачи"
|
||||||
|
content="Вы уверены, что хотите удалить эту задачу?"
|
||||||
|
onConfirm={handleDeleteTask}
|
||||||
|
confirmText="Удалить"
|
||||||
|
cancelText="Отмена"
|
||||||
|
/>
|
||||||
{tasks.length > 0 ? (
|
{tasks.length > 0 ? (
|
||||||
<>
|
<>
|
||||||
<div class={classes.header}>Сегодня: {getDate}</div>
|
<div class={classes.header}>Сегодня: {getDate}</div>
|
||||||
<div class={classes.tasks_container}>
|
<div class={classes.tasks_container}>
|
||||||
{tasks
|
{groupTasksByDate.today.length > 0 ? (
|
||||||
.sort((a, b) => b.date.getTime() - a.date.getTime())
|
<div class="w-full">
|
||||||
.map((task) => (
|
{groupTasksByDate.today.map((task) => (
|
||||||
<Task
|
<Task
|
||||||
name={task.name}
|
name={task.name}
|
||||||
key={task.id}
|
key={task.id}
|
||||||
checked={task.checked}
|
checked={task.checked}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
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 class="w-full text-center text-xl">Задач на сегодня нет</div>
|
||||||
|
)}
|
||||||
|
{groupTasksByDate.tomorrow.length > 0 && (
|
||||||
|
<div class="flex w-full flex-col gap-3 md:gap-10">
|
||||||
|
<div class="w-full text-3xl font-semibold md:text-5xl">Завтра</div>
|
||||||
|
{groupTasksByDate.tomorrow.map((task) => (
|
||||||
|
<Task
|
||||||
|
name={task.name}
|
||||||
|
key={task.id}
|
||||||
|
checked={task.checked}
|
||||||
|
onClick={() => {
|
||||||
|
setIsOpen(true);
|
||||||
|
setIsEdit(true);
|
||||||
|
setEditContent(task);
|
||||||
|
setCalendarDate(task.date);
|
||||||
|
}}
|
||||||
|
onMarkClick={() => {
|
||||||
|
setTasks(tasks.map((t) => (t.id === task.id ? { ...t, checked: !t.checked } : t)));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{groupTasksByDate.future.map((group) => (
|
||||||
|
<div class="flex w-full flex-col gap-3 md:gap-10" key={group.date.getTime()}>
|
||||||
|
<div class="w-full text-3xl font-semibold md:text-5xl">{formatDate(group.date)}</div>
|
||||||
|
{group.tasks.map((task) => (
|
||||||
|
<Task
|
||||||
|
name={task.name}
|
||||||
|
key={task.id}
|
||||||
|
checked={task.checked}
|
||||||
|
onClick={() => {
|
||||||
|
setIsOpen(true);
|
||||||
|
setIsEdit(true);
|
||||||
|
setEditContent(task);
|
||||||
|
setCalendarDate(task.date);
|
||||||
|
}}
|
||||||
|
onMarkClick={() => {
|
||||||
|
setTasks(tasks.map((t) => (t.id === task.id ? { ...t, checked: !t.checked } : t)));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</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 +468,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>
|
||||||
@@ -241,7 +481,7 @@ const ProfileTasks: FunctionComponent = () => {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div class="flex w-full flex-1 flex-col items-center justify-center text-2xl">Начни уже сегодня!</div>
|
<div class="flex w-full flex-1 flex-col items-center justify-center text-2xl">Начни уже сегодня!</div>
|
||||||
<div class="fixed right-[22rem] bottom-4 hidden flex-row items-center justify-start 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 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 hover:bg-[rgb(251,194,199,0.7)]"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
26
src/utils/status-system.ts
Normal file
26
src/utils/status-system.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
export interface StatusLevel {
|
||||||
|
name: string;
|
||||||
|
minPoints: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const STATUS_LEVELS: StatusLevel[] = [
|
||||||
|
{ name: "Завтра точно начну", minPoints: 0 },
|
||||||
|
{ name: "Всё по плану (плана нет)", minPoints: 25 },
|
||||||
|
{ name: "Гений прокрастинации (но всё сделал)", minPoints: 50 },
|
||||||
|
{ name: "Хвостоуничтожитель 3000", minPoints: 75 },
|
||||||
|
{ name: "Легенда планирования", minPoints: 90 }
|
||||||
|
];
|
||||||
|
|
||||||
|
const POINTS_PER_TASK = 5;
|
||||||
|
|
||||||
|
export const calculatePoints = (completedTasks: number): number => {
|
||||||
|
return Math.min(completedTasks * POINTS_PER_TASK, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCurrentStatus = (points: number): string => {
|
||||||
|
const status = STATUS_LEVELS
|
||||||
|
.slice()
|
||||||
|
.reverse()
|
||||||
|
.find(level => points >= level.minPoints);
|
||||||
|
return status?.name || STATUS_LEVELS[0].name;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user