Skip to content

Commit 7e20fd6

Browse files
authored
Merge pull request #12 from LexaFrontDev/dev
Dev
2 parents 8afd651 + 142a26b commit 7e20fd6

46 files changed

Lines changed: 660 additions & 13523 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
**/*.log
2+
**/*.md
3+
**/*.php~
4+
**/*.dist.php
5+
**/*.dist
6+
**/*.cache
7+
**/._*
8+
**/.dockerignore
9+
**/.DS_Store
10+
**/.git/
11+
**/.gitattributes
12+
**/.gitignore
13+
**/.gitmodules
14+
**/docker-compose.*.yaml
15+
**/docker-compose.*.yml
16+
**/docker-compose.yaml
17+
**/docker-compose.yml
18+
**/Dockerfile
19+
**/Thumbs.db
20+
.github/
21+
.idea/
22+
data/
23+
docs/
24+
public/bundles/
25+
tests/
26+
var/
27+
vendor/
28+
.editorconfig
29+
#.env.*.local
30+
#.env.local
31+
#.env.local.php
32+
#.env.test

.env

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
APP_ENV=prod
2-
APP_SECRET=
1+
APP_ENV=dev
2+
APP_SECRET=25aeff0645dafb0ce3dc54218fd03bed
3+
4+
DATABASE_URL="pgsql://TimerAppUser:user123@db:5432/TimerAppDatabase?serverVersion=13&charset=utf8"
5+
36

4-
DB_USER=your-database_user_name
5-
DB_PASS=your-database_password
6-
DB_HOST=your-database_host
7-
DB_NAME=Time
87

98
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
109

@@ -20,12 +19,12 @@ MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
2019
###> lexik/jwt-authentication-bundle ###
2120
JWT_PRIVATE_KEY_PATH=%kernel.project_dir%/config/jwt/private.pem
2221
JWT_PUBLIC_KEY_PATH=%kernel.project_dir%/config/jwt/public.pem
23-
JWT_PASSPHRASE=
22+
JWT_PASSPHRASE=e357a5e49f1839042101695a96c07c9edfdf4939d4e91b1368d5c177153a71bc
2423
###< lexik/jwt-authentication-bundle ###
2524

26-
VITE_CACHE_DB_NAME=
27-
VITE_CACHE_STORE_NAME=
28-
VITE_GOOGLE_CLIENT_ID=
29-
VITE_GOOGLE_REDIRECT_URI=
30-
VITE_PUSH_PUBLIC_KEY=
31-
VITE_PUSH_PRIVATE_KEY=
25+
VITE_CACHE_DB_NAME=HabitAiCacheDev
26+
VITE_CACHE_STORE_NAME=cache
27+
VITE_GOOGLE_CLIENT_ID=643971601411-8n1r7vok0pk4v4q250dfpr4ibs17jfms.apps.googleusercontent.com
28+
VITE_GOOGLE_REDIRECT_URI=http://localhost:8000/api/auth/google/callback
29+
VITE_PUSH_PUBLIC_KEY=BGFRrWJKC5fnlb_eLwOIqa4bWlbBqRUIFvlDYQ1GX56Hl5Kv4KNopAIqZ2Tq6ohG4hIdLJoim4313yKUyNevXgo
30+
VITE_PUSH_PRIVATE_KEY=EE9lQvPuHsWctURErU3bC4VG9wLguK-JcLI5iTo7G94

Makefile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Executables (local)
2+
DOCKER_COMP = docker compose
3+
4+
# Docker containers
5+
PHP_CONT = $(DOCKER_COMP) exec -e COMPOSER_MEMORY_LIMIT=-1 php
6+
7+
# Executables
8+
PHP = $(PHP_CONT) php -d memory_limit=-1
9+
COMPOSER = $(PHP_CONT) composer
10+
SYMFONY = $(PHP) bin/console
11+
PHPUNIT = $(PHP) bin/phpunit
12+
13+
# Misc
14+
.DEFAULT_GOAL = help
15+
.PHONY : help build up start down logs sh composer vendor sf cc
16+
17+
## —— 🎵 🐳 The Symfony Docker Makefile 🐳 🎵 ——————————————————————————————————
18+
help: ## Outputs this help screen
19+
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
20+
21+
## —— Docker 🐳 ————————————————————————————————————————————————————————————————
22+
build: ## Builds the Docker images
23+
@$(DOCKER_COMP) -f docker-compose.yml -f docker-compose.dev.yml build #--pull --no-cache
24+
25+
up: ## Start the docker hub in detached mode (no logs)
26+
@$(DOCKER_COMP) -f docker-compose.yml -f docker-compose.dev.yml up --detach
27+
28+
up-build: ## Start the docker hub in detached mode (no logs)
29+
@$(DOCKER_COMP) -f docker-compose.yml -f docker-compose.dev.yml up --build --detach
30+
31+
up-prod: ## Start the docker hub in detached mode (no logs)
32+
@$(DOCKER_COMP) -f docker-compose.yml -f docker-compose.prod.yml up --detach
33+
34+
up-prod-build: ## Start the docker hub in detached mode (no logs)
35+
@$(DOCKER_COMP) -f docker-compose.yml -f docker-compose.prod.yml up --build --detach
36+
37+
start: build up ## Build and start the containers
38+
39+
stop: ## Stop the docker hub
40+
@$(DOCKER_COMP) stop
41+
42+
down: ## Stop the docker hub
43+
@$(DOCKER_COMP) down --remove-orphans
44+
45+
logs: ## Show live logs
46+
@$(DOCKER_COMP) logs --tail=0 --follow
47+
48+
sh: ## Connect to the PHP FPM container
49+
@$(PHP_CONT) sh
50+
51+
perms: ## Connect to the PHP FPM container
52+
@$(PHP_CONT) chown www-data ./var/cache -R
53+
@$(PHP_CONT) chmod 0777 ./var/cache -R
54+
55+
remove-cache: ## Connect to the PHP FPM container
56+
@$(PHP_CONT) rm -rf ./var/cache/dev
57+
@$(PHP_CONT) rm -rf ./var/cache/prod
58+
59+
## —— Composer 🧙 ——————————————————————————————————————————————————————————————
60+
composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req symfony/orm-pack'
61+
@$(eval c ?=)
62+
@$(COMPOSER) $(c)
63+
64+
vendor: ## Install vendors according to the current composer.lock file
65+
vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
66+
vendor: composer
67+
68+
## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
69+
phpunit: ## List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about
70+
@$(PHPUNIT)
71+
72+
## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
73+
sf: ## List all Symfony commands or pass the parameter "c=" to run a given command, example: make sf c=about
74+
@$(eval c ?=)
75+
@$(SYMFONY) $(c)
76+
77+
cc: c=c:c ## Clear the cache
78+
cc: sf

assets/react/App.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

assets/react/Router.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const RouterDom = () => {
2020
const location = useLocation();
2121
const navigate = useNavigate();
2222

23-
// Сохраняем последнюю защищённую страницу
23+
2424
useEffect(() => {
2525
const allowedPages = [
2626
'/tasks',
@@ -40,6 +40,8 @@ const RouterDom = () => {
4040
const checkAuth = async () => {
4141
try {
4242
const res = await fetch('/api/auth/check');
43+
const data = await res.json();
44+
console.log(data);
4345
const ok = res.ok;
4446
setIsAuthenticated(ok);
4547

assets/react/index.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>React SPA</title>
6+
7+
<!-- Bootstrap CSS -->
8+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
9+
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
10+
<link href="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.10.0/dist/css/bootstrap-datepicker.min.css" rel="stylesheet">
11+
12+
<!-- Собственные стили через Vite -->
13+
<link rel="stylesheet" href="/styles/app.css">
14+
<link rel="stylesheet" href="/styles/Main/main.css">
15+
<!-- если есть Vite сборка -->
16+
17+
<!-- react-toastify стили -->
18+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/react-toastify/dist/ReactToastify.css">
19+
</head>
20+
<body>
21+
<div id="react-root"></div>
22+
23+
24+
<script type="module" src="./main.tsx"></script>
25+
26+
<!-- Дополнительно сторонние скрипты -->
27+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
28+
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
29+
<script src="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.10.0/dist/js/bootstrap-datepicker.min.js"></script>
30+
</body>
31+
</html>

assets/react/main.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// index.tsx
21
import React from 'react';
32
import ReactDOM from 'react-dom/client';
43
import './Services/Library/i18n';
@@ -7,12 +6,6 @@ import { I18nextProvider } from 'react-i18next';
76
import i18n from './Services/Library/i18n';
87
import 'react-toastify/dist/ReactToastify.css';
98

10-
if ('serviceWorker' in navigator) {
11-
navigator.serviceWorker.register('/serviceWorker/ServiceWorker.js')
12-
.then(registration => console.log('Service Worker зарегистрирован:', registration))
13-
.catch(err => console.error('Не удалось зарегистрировать Service Worker:', err));
14-
}
15-
169

1710
// @ts-ignore
1811
const root = ReactDOM.createRoot(document.getElementById('react-root'));

assets/react/pages/Tasks/TasksPage.tsx

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const TasksPage: React.FC = () => {
4949
}
5050
});
5151
const [tasks, setTasks] = useState<Task[]>([]);
52+
const [allTasks, setAllTasks] = useState<Task[]>([]);
5253
const [editingTask, setEditingTask] = useState<Task | null>(null);
5354
const [showEditModal, setShowEditModal] = useState<boolean>(false);
5455
const [loading, setLoading] = useState<boolean>(false);
@@ -136,30 +137,42 @@ const TasksPage: React.FC = () => {
136137
};
137138

138139
useEffect(() => {
139-
const fetchTasks = async () => {
140+
const fetchAllTasks = async () => {
140141
try {
141142
setLoading(true);
142-
if (activePeriod === 'all') {
143-
const tasks = await tasksService.getTasksAll();
144-
if(!tasks) setTasks([]);
145-
console.log(tasks);
146-
// @ts-ignore
147-
setTasks(tasks || []);
148-
} else {
149-
const date = getActiveDate();
150-
const tasks = await tasksService.getTasksFor(date);
151-
setTasks(tasks || []);
152-
}
143+
const allTasksResult = await tasksService.getTasksAll();
144+
setAllTasks(Array.isArray(allTasksResult) ? allTasksResult : []);
145+
console.log(allTasks)
153146
} catch (err: any) {
154147
setError(err.message);
155-
setTasks([]);
148+
setAllTasks([]);
156149
} finally {
157150
setLoading(false);
158151
}
159152
};
160153

161-
fetchTasks();
162-
}, [activePeriod]);
154+
fetchAllTasks();
155+
}, []);
156+
157+
useEffect(() => {
158+
if (activePeriod === 'all') {
159+
setTasks(allTasks);
160+
} else {
161+
const activeDate = getActiveDate();
162+
const filtered = allTasks.filter(task => {
163+
if (!task.timeData?.date) return false;
164+
const taskDate = new Date(task.timeData.date);
165+
const taskDateStr = taskDate.toISOString().slice(0, 10).replace(/-/g, '');
166+
return taskDateStr === activeDate;
167+
});
168+
setTasks(filtered);
169+
}
170+
}, [activePeriod, allTasks]);
171+
172+
173+
174+
175+
163176

164177
const handlePeriodChange = async (period: Period, id: number) => {
165178
setActiveId(id)
@@ -173,9 +186,13 @@ const TasksPage: React.FC = () => {
173186
const getTasks = async (period: 'today' | 'tomorrow' | 'nextWeek' | 'nextMonth' | 'all') => {
174187
try {
175188
setLoading(true);
176-
const allTasks = await tasksService.getTasksAll();
177-
// @ts-ignore
178-
setTasks(allTasks || []);
189+
if (allTasks.length === 0) {
190+
const fetchedTasks = await tasksService.getTasksAll();
191+
const tasksArray: Task[] = Array.isArray(fetchedTasks) ? fetchedTasks : [];
192+
setAllTasks(tasksArray);
193+
}
194+
195+
setTasks(allTasks);
179196
setActivePeriod(period);
180197
} catch (err: any) {
181198
setError(err.message || t('tasks.mistakeGetAllTasks'));

0 commit comments

Comments
 (0)