Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into main #50

Merged
merged 317 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
317 commits
Select commit Hold shift + click to select a range
d4deb1d
Экран окончания игры
Timur233 Sep 29, 2024
9daba7e
Правки ревью k0ndratov
Timur233 Sep 30, 2024
8be6f1b
[SOK-27] fix: lives
shamemask Sep 30, 2024
f2af052
[SOK-27] fix: изьавился от default
shamemask Sep 30, 2024
4e0b9b3
[SOK-27] fix: изменил работу handleKey функций
shamemask Sep 30, 2024
ed29145
[SOK-27] fix: Настроил сравнение с canvas
shamemask Sep 30, 2024
959c1b4
[SOK-27] fix: Настроил движение и проверку колизии с объектом в одной…
shamemask Sep 30, 2024
11532f6
[SOK-27] fix: Настроил fps игры
shamemask Sep 30, 2024
a61b010
added: profile page, change password page, from component, input comp…
VladToby Sep 30, 2024
f9a4f97
added: profile page, change password page, from component, input comp…
VladToby Sep 30, 2024
61ab747
Merge branch 'develop' of https://github.com/Timur233/falcon-tanks in…
Timur233 Sep 30, 2024
0d46090
fix profile page layout, fix styles
VladToby Oct 1, 2024
6b32d3a
[SOK-27] fix: hasCollision
shamemask Oct 1, 2024
4b02ce2
[SOK-27] fix: +hasCollision ограничение количества проверок коллизий
shamemask Oct 1, 2024
caf795a
[SOK-27] fix: убрал не нужный комментарий о завершении игры
shamemask Oct 1, 2024
0fbd8c9
Добавил состояние для загрузки спрайта иконок
Timur233 Oct 1, 2024
e7499c0
[SOK-27] fix: настроил запуск игры
shamemask Oct 1, 2024
057aab9
[SOK-16]
gloginov Sep 27, 2024
cf1f851
[SOK-16]
gloginov Sep 27, 2024
d993cc1
[SOK-16]
gloginov Sep 27, 2024
9960d7c
[SOK-16]
gloginov Oct 1, 2024
0234024
[SOK-16]
gloginov Oct 1, 2024
7b59c39
fix avatar component, fix profile page layout, fix default form class…
VladToby Oct 1, 2024
dff7926
Fix input, fix change password page, fix page & styles
VladToby Oct 2, 2024
3cb9e99
Fix profile page background images
VladToby Oct 2, 2024
6dcb54e
[SOK-16]
gloginov Oct 2, 2024
94da985
[SOK-16]
gloginov Oct 2, 2024
2def654
Merge pull request #8 from Timur233/SOK-16_authorization
gloginov Oct 2, 2024
b39dbb2
Merge with develop
VladToby Oct 2, 2024
64eb487
[SOK-27] fix: настроил переход на страницу поражения
shamemask Oct 2, 2024
af63551
Merge branch 'develop' into SOK-27_game-prototype
shamemask Oct 2, 2024
a37af9c
[SOK-16]
gloginov Oct 2, 2024
ee6ad2b
Merge with develop
VladToby Oct 2, 2024
bd06de6
Fix form erros, rework user reducer, fix avatar src
VladToby Oct 2, 2024
eef02e0
Input max width
VladToby Oct 3, 2024
c3d32aa
Added overlay colors to vars
VladToby Oct 3, 2024
7bfdf3b
delete comments
VladToby Oct 3, 2024
af09e99
Merge pull request #13 from Timur233/SOK-22_user_profile_page
VladToby Oct 3, 2024
e745411
Правки:
Timur233 Oct 3, 2024
98289b3
Merge branch 'develop' of https://github.com/Timur233/falcon-tanks in…
Timur233 Oct 3, 2024
1ea0f72
Linter Format
Timur233 Oct 3, 2024
2b4debc
Merge pull request #11 from Timur233/SOK-21_start-game-page
Timur233 Oct 3, 2024
6e1251c
Merge branch 'SOK-21_start-game-page' of https://github.com/Timur233/…
Timur233 Oct 3, 2024
f5937d3
Merge pull request #12 from Timur233/SOK-24_game-over-page
Timur233 Oct 3, 2024
a4d9bbb
[SOK-27] fix: переделал настройки игрока под переменную PLAYER_DEFAUL…
shamemask Oct 3, 2024
89b8535
[SOK-27] fix: переделал resetPlayerPosition
shamemask Oct 3, 2024
6860baf
login page
VladToby Oct 3, 2024
0eb6e00
Merge branch 'develop' into SOK-15_login_page
VladToby Oct 3, 2024
5ca48a9
registration page
VladToby Oct 3, 2024
c279fdb
change registartion page background image
VladToby Oct 3, 2024
8572f09
[SOK-27] fix: передал цвет кнопки из переменной
shamemask Oct 4, 2024
5e59bf3
Merge remote-tracking branch 'origin/SOK-27_game-prototype' into SOK-…
shamemask Oct 4, 2024
024063b
[SOK-27] fix: убрал избыточное зацикливание
shamemask Oct 4, 2024
6e5a0cb
[SOK-27] fix: убрал состояния из цикла
shamemask Oct 4, 2024
5bcb231
Merge branch 'develop' into SOK-27_game-prototype
shamemask Oct 7, 2024
0168aa7
Подружил игру и страницу игры
Timur233 Oct 8, 2024
7def987
[SOK-17] forum (#16)
k0ndratov Oct 8, 2024
e2fd186
Merge remote-tracking branch 'refs/remotes/origin/develop' into SOK-2…
shamemask Oct 8, 2024
b9dfd18
Merge pull request #9 from Timur233/SOK-27_game-prototype
shamemask Oct 8, 2024
e293e45
feat: add fullscrean mode for game page
k0ndratov Oct 8, 2024
60b619c
[SOK-32]
gloginov Oct 8, 2024
40e79d7
added service worker
VladToby Oct 8, 2024
cbf937a
[SOK-32]
gloginov Oct 9, 2024
e85d9e0
delete update method, fix main.tsx chache url
VladToby Oct 9, 2024
723d177
[SOK-32]
gloginov Oct 10, 2024
ac57a77
[SOK-30] Sprites (#20)
k0ndratov Oct 10, 2024
ab99772
fix cache urls
VladToby Oct 10, 2024
30c155d
fix cache types, code improvements
VladToby Oct 10, 2024
fde4655
Merge pull request #19 from Timur233/SOK-31_service_worker
VladToby Oct 10, 2024
37b1fd4
delete unused query, fix login error name
VladToby Oct 10, 2024
a54e23e
Merge pull request #14 from Timur233/SOK-15_login_page
VladToby Oct 10, 2024
83e98f4
Merge branch 'SOK-15_login_page' into SOK-19_registration_page
VladToby Oct 10, 2024
233371f
Merge pull request #15 from Timur233/SOK-19_registration_page
VladToby Oct 10, 2024
b706fe6
Правки:
Timur233 Oct 11, 2024
336d951
Баг
Timur233 Oct 11, 2024
bedf831
[SOK-32]
gloginov Oct 11, 2024
266d3a9
Состояние управлением игрой
Timur233 Oct 11, 2024
ef9ab0e
Добавил защиту от повторного запуска цикла игры
Timur233 Oct 11, 2024
be9d52e
Добавил защиту от залипания клавиш, при потери фокуса со страницы
Timur233 Oct 11, 2024
aabd4b7
Добавил обработку паузы на нажатие клавиши Escape
Timur233 Oct 11, 2024
7ffcacf
Добавил прелоадер в privateLayout
Timur233 Oct 11, 2024
10e3557
Добавил вин скрин
Timur233 Oct 11, 2024
cedc17a
Орефакторил код, по исправлял ошибки
Timur233 Oct 11, 2024
21450d0
Merge branch 'develop' of https://github.com/Timur233/falcon-tanks in…
Timur233 Oct 11, 2024
2624ff9
Merge branch 'develop' of https://github.com/Timur233/falcon-tanks in…
Timur233 Oct 11, 2024
ef3fc74
added game map, change enemy logic, added player position
VladToby Oct 11, 2024
415ad80
Merge pull request #18 from Timur233/SOK-32_HOC-auth
gloginov Oct 11, 2024
05c5899
[SOK-41] Player movement (#21)
k0ndratov Oct 11, 2024
6d40b1a
fix enemies params, fix collision occurred, fix draw obstacles, fix f…
VladToby Oct 11, 2024
97d8b74
Merge pull request #23 from Timur233/SOK-40_game_map
VladToby Oct 11, 2024
388c713
hide login button on main page when user is logged in
VladToby Oct 11, 2024
e781d49
[SOK-36] refactor: перенес движения игрока в gameloop
shamemask Oct 11, 2024
682d1c2
[SOK-36] refactor: преобразовал интерфейс врага и игрока в абстрактны…
shamemask Oct 11, 2024
5e2f486
[SOK-36] feat: создал пули, настроил выстрелы пользователем
shamemask Oct 11, 2024
4ccd716
[SOK-36] feat: настроил попадание пулей и выпуск по одной
shamemask Oct 11, 2024
28eaadf
[SOK-36] fix: настроил ограничение по скорости выстрелов
shamemask Oct 11, 2024
ebe6c70
[SOK-36] feat: настроил движение врагов конём, а также поворот спрайтов
shamemask Oct 11, 2024
c6ab430
[SOK-36] feat: настроил выстрелы врагов
shamemask Oct 11, 2024
9727692
[SOK-36] fix: исправил репаун и коллизию врагов друг с другом
shamemask Oct 11, 2024
e55a0ac
[SOK-36] fix: настроил распределение препятствий, а также их разрушение
shamemask Oct 11, 2024
bf77d72
[SOK-36] fix: внедрил наработку компании
shamemask Oct 12, 2024
db6b3aa
Правки по ревью
Timur233 Oct 12, 2024
7e4a653
Правки по ревью
Timur233 Oct 12, 2024
c6fe79b
Merge branch 'SOK-29_game-start-end-state' of https://github.com/Timu…
Timur233 Oct 12, 2024
e725927
Добавил анмицию движения танка
Timur233 Oct 12, 2024
2b714b2
Lint & Format
Timur233 Oct 12, 2024
5ea21e7
Добавил спрайт снаряда
Timur233 Oct 12, 2024
afe203f
Доработки:
Timur233 Oct 15, 2024
e4ffaa3
Change README.md
VladToby Oct 15, 2024
a6128a4
Merge pull request #27 from Timur233/no-task_readme
VladToby Oct 15, 2024
8faf210
Merge pull request #25 from Timur233/SOK-36_game_mechanics_editing
shamemask Oct 15, 2024
08482b5
Merge remote-tracking branch 'refs/remotes/origin/SOK-37_animations' …
shamemask Oct 15, 2024
b920a5d
Merge pull request #24 from Timur233/no-task_hide_login_button
VladToby Oct 15, 2024
edeb50c
[SOK-23] doc: Написал документацию к прототипу игры
shamemask Oct 15, 2024
bf3e5b2
redesigned the fullscreen button to fit the overall design
VladToby Oct 15, 2024
aadc114
fix buttons padding
VladToby Oct 15, 2024
ec74cce
Merge pull request #17 from Timur233/SOK-33_fullscrean-api
VladToby Oct 15, 2024
d69d9f6
[SOK-23] doc: добавил ссылку в основной readme
shamemask Oct 15, 2024
686acac
Merge branch 'develop' into SOK-23_game_docs
shamemask Oct 15, 2024
43031a6
Merge
Timur233 Oct 15, 2024
72ef412
Merge pull request #28 from Timur233/SOK-23_game_docs
shamemask Oct 15, 2024
27430da
Merge branch 'develop' of https://github.com/Timur233/falcon-tanks in…
Timur233 Oct 15, 2024
4cf4bd1
go
Timur233 Oct 15, 2024
6d5ae88
Merge branch 'develop' of https://github.com/Timur233/falcon-tanks in…
Timur233 Oct 15, 2024
695ab18
linter & format
Timur233 Oct 15, 2024
148da43
Merge pull request #22 from Timur233/SOK-29_game-start-end-state
Timur233 Oct 15, 2024
6bab2c5
Merge remote-tracking branch 'refs/remotes/origin/SOK-37_animations' …
shamemask Oct 15, 2024
48620c4
Merge remote-tracking branch 'origin/develop' into develop
shamemask Oct 15, 2024
39f9c5f
feat: добавил отображение убийств
shamemask Oct 15, 2024
4353365
Добавил лоадер
Timur233 Oct 15, 2024
19877d3
Кнопки начать компанию
Timur233 Oct 15, 2024
8a91262
add link to video
VladToby Oct 16, 2024
440005a
Merge pull request #29 from Timur233/no-task_add_video_link_to_readme
VladToby Oct 16, 2024
549f56d
docs: remove UML diagram
k0ndratov Oct 16, 2024
70ff02b
Правки
Timur233 Oct 16, 2024
8aec5db
PLAYER_DEFAULT_PARAMS
Timur233 Oct 16, 2024
53fc934
PLAYER_DEFAULT_PARAMS
Timur233 Oct 16, 2024
403ad23
feat: добавил fps в игровой цикл
shamemask Oct 22, 2024
c0182b5
[SOK-58]
gloginov Oct 25, 2024
629a5c3
Нашел и вернул на место утеренные пули
Oct 27, 2024
f7dfbec
[SOK-58]
gloginov Oct 31, 2024
20244cb
feat: отключил friendly fire sok-48
shamemask Oct 31, 2024
cb1e7cd
feat: настроил коллизию пули с пулей sok-48
shamemask Oct 31, 2024
a07a1d0
[SOK-58]
gloginov Nov 1, 2024
bfa2302
Merge pull request #32 from Timur233/SOK-58_ssr
gloginov Nov 1, 2024
e8a27bf
feat: настроил скавн врагов, чтобы не попадали в препядствия sok-45
shamemask Nov 1, 2024
e1ab7a6
[SOK-59] ssr redux (#37)
k0ndratov Nov 2, 2024
89900b9
feat: настроил скавн врагов, чтобы не попадали в препядствия sok-45
shamemask Nov 5, 2024
2fdabfa
Merge branch 'refs/heads/develop' into SOK-48_frendli-fair-ne-zashchi…
shamemask Nov 5, 2024
530da69
Merge branch 'refs/heads/develop' into SOK-47_fps
shamemask Nov 5, 2024
1f429a5
Merge branch 'refs/heads/develop' into SOK-45_spavn-ihrokov-i-protivn…
shamemask Nov 5, 2024
5767fa4
fix: настроил очистку пуль при запуске игры, а также выяснил причину …
shamemask Nov 5, 2024
fbbbfb6
feat: переписал объекты player, enemies, obstacle. Теперь это св-ва g…
shamemask Nov 5, 2024
d1f3672
Merge pull request #38 from Timur233/SOK-45_spavn-ihrokov-i-protivnik…
shamemask Nov 6, 2024
f09935e
Merge branch 'SOK-42_daniil-pravki-po-itohu-5-6-sprinta' into SOK-46-…
shamemask Nov 6, 2024
1a3d758
Merge pull request #39 from Timur233/SOK-46-reshit-s-pulyami
shamemask Nov 6, 2024
d6cfada
Merge pull request #35 from Timur233/SOK-47_fps
shamemask Nov 6, 2024
ec48360
Merge branch 'refs/heads/SOK-42_daniil-pravki-po-itohu-5-6-sprinta' i…
shamemask Nov 6, 2024
f110670
merge: Обновил данные с ветки sok-42 sok-48
shamemask Nov 6, 2024
0e29aec
Merge pull request #34 from Timur233/SOK-48_frendli-fair-ne-zashchiti…
shamemask Nov 6, 2024
56aad43
Merge pull request #40 from Timur233/SOK-42_daniil-pravki-po-itohu-5-…
shamemask Nov 7, 2024
540b376
feat: добавил работу с Notification API в игру, а также звуки через б…
shamemask Nov 10, 2024
a7ed77d
fix: переместил permission.tsx в отдельную папку sok-62
shamemask Nov 11, 2024
b18e0d8
fix: исправление транслита sok-62
shamemask Nov 11, 2024
14ce5c8
fix types, medals
VladToby Nov 11, 2024
0319d6f
fix types, medals
VladToby Nov 2, 2024
f04aaa0
Merge pull request #36 from Timur233/SOK-61_leaderbord_api
VladToby Nov 11, 2024
37c2f28
fix: перенастроил работу с Howl на работу с отдельной функцией адапте…
shamemask Nov 11, 2024
e3b18f8
fix: вынес константы sok-62
shamemask Nov 11, 2024
7afc03a
fix: вынес подсчеты в отдельные функции sok-62
shamemask Nov 11, 2024
709487d
Merge branch 'refs/heads/develop' into SOK-62_game-sound
shamemask Nov 11, 2024
3eb6582
Merge pull request #41 from Timur233/SOK-62_game-sound
shamemask Nov 11, 2024
813e0dd
added backed emoji basic logic
VladToby Nov 13, 2024
fb228c2
git ignore
VladToby Nov 13, 2024
c840c0f
fix lint
VladToby Nov 13, 2024
14d2c2f
fix lint
VladToby Nov 13, 2024
1711ee3
Добавил сервис для авторизации Yandex
Nov 15, 2024
cc73968
Добавил верстку кнопок
Nov 15, 2024
076f344
Merge pull request #42 from Timur233/SOK-65_emoji_backend
VladToby Nov 15, 2024
fce82d6
Merge remote-tracking branch 'origin/develop' into SOK-60_oauth
Nov 15, 2024
00253f5
Merge pull request #43 from Timur233/SOK-60_oauth
Timur233 Nov 15, 2024
3b44a5a
feat: настроил функциональность форума: посмотреть все топики, так же…
shamemask Nov 15, 2024
f9ab9aa
feat: настроил функциональность форума: создать новый топик sok-66
shamemask Nov 15, 2024
1a01390
feat: настроил функциональность форума: написать комментарий, так же …
shamemask Nov 15, 2024
aa3d15e
Merge branch 'refs/heads/develop' into SOK-66_podderzhat-api-foruma-n…
shamemask Nov 15, 2024
6ffbeb9
fix: сделал мердж с develop, добавились реакции sok-66
shamemask Nov 15, 2024
6b8f201
added emoji picker, change test user for real
VladToby Nov 16, 2024
8fb4fab
[SOK-64]
gloginov Nov 17, 2024
421aab0
Merge pull request #44 from Timur233/SOK-66_podderzhat-api-foruma-na-…
shamemask Nov 17, 2024
fa5a61f
Merge pull request #45 from Timur233/SOK-67_emoji-client
VladToby Nov 17, 2024
ab08ed0
[SOK-64]
gloginov Nov 17, 2024
ef543d9
[SOK-64]
gloginov Nov 18, 2024
675b9b7
[SOK-64]
gloginov Nov 18, 2024
9afc65b
[SOK-64]
gloginov Nov 18, 2024
ea221dd
Merge pull request #46 from Timur233/SOK-64
gloginov Nov 18, 2024
1565c49
Добавил API тем пользователей
Nov 18, 2024
feb8d5b
Добавил компилируемые файлы и игнор
Nov 19, 2024
47ddccb
Удалил tsconfig.server.tsbuildinfo, что бы начала действовать ignore
Nov 19, 2024
9395d4e
Добавил еще файлы в gitignore
Nov 19, 2024
db729a5
Вынес асинхронный запрос в useEffect
Nov 19, 2024
115530e
Добавил АПИ для работы с темами
Nov 19, 2024
73ecf5d
Добавил редюсер
Nov 20, 2024
1a10ac1
Поработал с лайоутами
Nov 20, 2024
80ae5ec
Добавил тогл переключения тем
Nov 20, 2024
6585f75
Добавил новогоднюю тему
Nov 20, 2024
3fc2a21
Merge pull request #47 from Timur233/SOK-68_toggle-theme-BE
Timur233 Nov 20, 2024
23de8de
Merge pull request #49 from Timur233/SOK-69_toggle-theme-FE
Timur233 Nov 20, 2024
b4f756a
feat: add sequelize orm, forum api
k0ndratov Nov 20, 2024
ccc5a07
chore: configured the folder for the compiled server files
k0ndratov Nov 21, 2024
eee15ca
chore: ad message for prod environment
k0ndratov Nov 21, 2024
983bd88
fix: use middleware only on topics and comments endpoints
k0ndratov Nov 21, 2024
e3897b1
Merge pull request #48 from Timur233/SOK-70_forum-api
Timur233 Nov 21, 2024
d477fb8
[SOK-ci]
gloginov Nov 22, 2024
5c05b85
[SOK-ci]
gloginov Nov 22, 2024
c470f2a
[SOK-ci]
gloginov Nov 22, 2024
f2595c2
[SOK-ci]
gloginov Nov 22, 2024
a53469a
coockie test
VladToby Nov 22, 2024
473a382
doc: дополнил описания для windows
shamemask Nov 22, 2024
2ecf51c
Подправил сервер, и пытался решить вопрос с scss
Nov 24, 2024
7adc62f
Лоадер при загрузке страницы сср
Nov 24, 2024
8a83a16
Поправил theme toggle
Nov 24, 2024
2d83f4a
Поправил стили тут и там
Nov 24, 2024
eb60f5b
Merge branch 'develop' into SOK-54_missing-bullets
Nov 24, 2024
4601550
Merge pull request #52 from Timur233/SOK-80_bug-fix
Timur233 Nov 25, 2024
e4fa9e1
Merge pull request #33 from Timur233/SOK-54_missing-bullets
Timur233 Nov 25, 2024
763fe6f
[SOK-fix-docker]
gloginov Nov 22, 2024
80aa50f
final forum fixes
VladToby Nov 26, 2024
84f7fdd
Merge pull request #51 from Timur233/SOK-71_forum_fix
VladToby Nov 29, 2024
6ba2087
[SOK-18]
gloginov Dec 3, 2024
4799ace
[SOK]
gloginov Dec 3, 2024
3555d56
[SOK-18]
gloginov Dec 3, 2024
0403f08
[SOK-18]
gloginov Dec 3, 2024
9c2111e
Merge pull request #54 from Timur233/SOK-18
gloginov Dec 3, 2024
a474412
[SOK]
gloginov Dec 3, 2024
8bb7ba9
fix: копирование .env.sample в том случае если нет .env
shamemask Dec 3, 2024
53db484
fix: убрал монтирование проекта
shamemask Dec 3, 2024
20f926b
fix: перенес команды билдинга на этап base
shamemask Dec 3, 2024
ce3188e
fix: вернул yarn build на место
shamemask Dec 3, 2024
36f7033
fix: настроил получение ссылки на хост сервера из .env localApi
shamemask Dec 5, 2024
a490642
fix: дополнительные настройки для CORS
shamemask Dec 5, 2024
3444d9e
feat: docker file target for prod
k0ndratov Dec 5, 2024
4650dad
fix linter
k0ndratov Dec 6, 2024
fd160d2
wip
k0ndratov Dec 6, 2024
93203ad
Пофиксил кнопку на главно
Dec 10, 2024
190725d
fix: добавил условие в Dockerfile, для обхода ошибки в линте с .env
shamemask Dec 11, 2024
188a17e
fix: убрал условие, немного изменил предыдущее, для обхода ошибки в л…
shamemask Dec 11, 2024
5818287
fix: ещё попытка обхода ошибки в линте с .env
shamemask Dec 11, 2024
cd8871c
Merge pull request #55 from Timur233/dockerfile-target-for-prod
shamemask Dec 11, 2024
e9a1a85
Merge pull request #57 from Timur233/SOK-81_fixes
shamemask Dec 11, 2024
e8f021e
doc: актуализировал документацию игры
shamemask Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add sequelize orm, forum api
wip
  • Loading branch information
k0ndratov committed Nov 21, 2024
commit b4f756a056a34c121439091e0ffa18dd421412b9
27 changes: 14 additions & 13 deletions packages/client/src/pages/Forum/Forum.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { useEffect, useState } from 'react'
import { fetchThreads } from '@/api/forumApi'
import { Thread } from '@/types/forum'
import PromoLogo from '@/assets/images/svg/FT-promo.svg'
import { Button } from '@/components/ui/Button/Button'
import { Card } from '@/components/ui/Card/Card'
import { PageTitle } from '@/components/ui/PageTitle/PageTitle'
import { Pagination } from '@/components/ui/Pagination/Pagination'
import { Thread } from '@/types/forum'
import { useEffect, useState } from 'react'
import { Link, useNavigate } from 'react-router-dom'
import './Forum.scss'
import { mockForumThreads } from '../../../mocks/Forum'
import './Forum.scss'

const THREADS_COUNT = 10

Expand All @@ -21,15 +20,17 @@ export const Forum = () => {

useEffect(() => {
const loadThreads = async () => {
try {
const data = await fetchThreads(currentPage, THREADS_COUNT)
setThreads(data.threads)
setTotalPages(data.totalPages)
} catch (err) {
console.error('Ошибка загрузки тем форума:', err)
setError('Не удалось загрузить темы. Отображаются заглушки.')
setThreads(mockForumThreads) // Используем заглушки
}
setThreads(mockForumThreads) // Используем заглушки

// try {
// const data = await fetchThreads(currentPage, THREADS_COUNT)
// setThreads(data.threads)
// setTotalPages(data.totalPages)
// } catch (err) {
// console.error('Ошибка загрузки тем форума:', err)
// setError('Не удалось загрузить темы. Отображаются заглушки.')
// setThreads(mockForumThreads) // Используем заглушки
// }
}

loadThreads()
Expand Down
42 changes: 42 additions & 0 deletions packages/server/controllers/sequelize/comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Request, Response } from 'express'
import { Comment } from '../../models/sequelize/Comment'
import { Reaction } from '../../models/sequelize/Reaction'
import { buildCommentTree } from '../../utils/buildComponentTree'

export const getCommentsByTopicId = async (req: Request, res: Response) => {
const { topicId } = req.params

try {
const comments = await Comment.findAll({
where: { topicId },
order: [['id', 'ASC']],
include: [
{
model: Reaction,
attributes: ['userId', 'emojiCode'],
},
],
})

const commentsTree = buildCommentTree(comments)

res.status(200).json(commentsTree)
} catch (e) {
res.status(500).json(e)
}
}

export const createComment = async (req: Request, res: Response) => {
const { text } = req.body
const { topicId, commentId } = req.params
try {
const newComment = await Comment.create({
text,
topicId: parseInt(topicId),
parentCommentId: commentId ? parseInt(commentId) : null,
})
res.status(201).json(newComment)
} catch (e) {
res.status(500).json(e)
}
}
20 changes: 20 additions & 0 deletions packages/server/controllers/sequelize/reaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { RequestHandler } from 'express'
import { Reaction } from '../../models/sequelize/Reaction'

export const addReactionToComment: RequestHandler = async (req, res) => {
const commentId = parseInt(req.params.commentId)
const emojiCode = req.body.emojiCode
const userId = parseInt(req.body.userId)

try {
const reaction = await Reaction.create({
commentId,
emojiCode,
userId,
})

res.status(201).json(reaction)
} catch (e) {
res.status(500).json(e)
}
}
33 changes: 33 additions & 0 deletions packages/server/controllers/sequelize/topic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Request, Response } from 'express'
import { Topic } from '../../models/sequelize/Topic'

export const getTopics = async (req: Request, res: Response) => {
try {
const topics = await Topic.findAll()
res.status(200).json(topics)
} catch (e) {
res.status(500).json(e)
}
}

export const getTopicById = async (req: Request, res: Response) => {
try {
const topic = await Topic.findByPk(parseInt(req.params.id))
if (!topic) {
return res.status(404).json({ message: 'Topic not found' })
}
res.status(200).json(topic)
} catch (e) {
res.status(500).json(e)
}
}

export const createTopic = async (req: Request, res: Response) => {
const { title } = req.body
try {
const newTopic = await Topic.create({ title })
res.status(201).json(newTopic)
} catch (e) {
res.status(500).json(e)
}
}
30 changes: 28 additions & 2 deletions packages/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import cookieParser from 'cookie-parser'
import cors from 'cors'
import dotenv from 'dotenv'
import type { RequestHandler } from 'express'
import express from 'express'
import fs from 'fs'
import path from 'path'
import serialize from 'serialize-javascript'
import { createServer as createViteServer, ViteDevServer } from 'vite'
import { createClientAndConnect } from './db'
import { ReactionModel } from './models/reaction'
import { UserThemeModel } from './models/user_theme'
import { ReactionController } from './controllers/reaction'
import { createClientAndConnect } from './db'
import { sequelize } from './instances/sequelize'
import { UserThemeController } from './controllers/user_theme'
import './relationships'
import commentRoutes from './routes/comment'
import topicRoutes from './routes/topic'

dotenv.config()

Expand All @@ -26,11 +32,12 @@ async function createServer() {
})
)
app.use(express.json())

app.use(cookieParser())
app.use((req, _res, next) => {
console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`, {
body: req.body,
params: req.params,
cookies: req.cookies,
})
next()
})
Expand All @@ -45,6 +52,25 @@ async function createServer() {

await createClientAndConnect()

try {
await sequelize.authenticate()
await sequelize.sync()
console.log('Connection has been established successfully.')
} catch (error) {
console.error('Unable to connect to the database:', error)
}

const isUserLoggedInMiddleware: RequestHandler = (req, res, next) => {
if (req.cookies.authCookie) {
next()
} else {
res.status(403).json({ message: 'Forbidden' })
}
}

app.use('/api', isUserLoggedInMiddleware, topicRoutes)
app.use('/api', isUserLoggedInMiddleware, commentRoutes)

app.post('/api/topics/:topicId/reactions', (req, res) =>
ReactionController.toggleReaction(req, res)
)
Expand Down
11 changes: 11 additions & 0 deletions packages/server/instances/sequelize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Sequelize } from 'sequelize'

export const sequelize = new Sequelize(
process.env.POSTGRES_DB as string,
process.env.POSTGRES_USER as string,
process.env.POSTGRES_PASSWORD,
{
host: process.env.POSTGRES_HOST,
dialect: 'postgres',
}
)
47 changes: 47 additions & 0 deletions packages/server/models/sequelize/Comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as Sequelize from 'sequelize'
import { sequelize } from '../../instances/sequelize'

export type CommentCreationAttributes = Sequelize.Optional<
CommentAttributes,
'id'
>

export type CommentAttributes = {
id: number
text: string
topicId: number | null
parentCommentId: number | null
}

export class Comment extends Sequelize.Model<
CommentAttributes,
CommentCreationAttributes
> {
declare id: number
declare text: string
declare topicId: number | null
declare parentCommentId: number | null
}

Comment.init(
{
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
},
text: {
type: Sequelize.STRING,
allowNull: false,
},
topicId: {
type: Sequelize.INTEGER,
allowNull: true,
},
parentCommentId: {
type: Sequelize.INTEGER,
allowNull: true,
},
},
{ sequelize }
)
47 changes: 47 additions & 0 deletions packages/server/models/sequelize/Reaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as Sequelize from 'sequelize'
import { sequelize } from '../../instances/sequelize'

export type ReactionAttributes = {
id: number
emojiCode: string
commentId: number
userId: number
}

export type ReactionCreateAttributes = Sequelize.Optional<
ReactionAttributes,
'id'
>

export class Reaction extends Sequelize.Model<
ReactionAttributes,
ReactionCreateAttributes
> {
declare id: number
declare emojiCode: string
declare commentId: number
declare userId: number
}

Reaction.init(
{
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
},
emojiCode: {
type: Sequelize.STRING,
allowNull: false,
},
commentId: {
type: Sequelize.INTEGER,
allowNull: false,
},
userId: {
type: Sequelize.INTEGER,
allowNull: false,
},
},
{ sequelize }
)
32 changes: 32 additions & 0 deletions packages/server/models/sequelize/Topic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as Sequelize from 'sequelize'
import { sequelize } from '../../instances/sequelize'

export type TopicAttributes = {
id: number
title: string
}

export type TopicCreationAttributes = Sequelize.Optional<TopicAttributes, 'id'>

export class Topic extends Sequelize.Model<
TopicAttributes,
TopicCreationAttributes
> {
declare id: number
declare title: string
}

Topic.init(
{
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
primaryKey: true,
},
title: {
type: Sequelize.STRING,
allowNull: false,
},
},
{ sequelize }
)
6 changes: 5 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
"test": "jest ."
},
"dependencies": {
"@types/cookie-parser": "^1.4.7",
"axios": "^1.7.7",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
"dotenv": "^16.0.2",
"eslint-config-prettier": "^8.5.0",
"express": "^4.18.1",
"pg": "^8.8.0",
"prettier": "^2.7.1"
"prettier": "^2.7.1",
"sequelize": "^6.37.5"
},
"devDependencies": {
"@types/cors": "^2.8.12",
Expand Down
24 changes: 24 additions & 0 deletions packages/server/relationships.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Comment } from './models/sequelize/Comment'
import { Reaction } from './models/sequelize/Reaction'
import { Topic } from './models/sequelize/Topic'

Topic.hasMany(Comment, {
foreignKey: 'topicId',
as: 'comments',
})
Comment.belongsTo(Topic, {
foreignKey: 'topicId',
as: 'topic',
})

Comment.hasMany(Comment, {
foreignKey: 'parentId',
as: 'replies',
})
Comment.belongsTo(Comment, {
foreignKey: 'parentId',
as: 'parent',
})

Comment.hasMany(Reaction, { foreignKey: 'commentId' })
Reaction.belongsTo(Comment, { foreignKey: 'commentId' })
8 changes: 8 additions & 0 deletions packages/server/routes/comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Router } from 'express'
import { addReactionToComment } from '../controllers/sequelize/reaction'

const router = Router()

router.post('/comments/:commentId/reactions', addReactionToComment)

export default router
Loading