Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Tea 63 forum topics list #17

Merged
merged 34 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6276262
add ssr
EkaterinaBelonosova Dec 4, 2022
7717161
настроен express
EkaterinaBelonosova Dec 6, 2022
2d55a33
Merge branch 'main' into feature/TEA-39-redux-and-router-in-SSR
EkaterinaBelonosova Dec 6, 2022
056c8b5
Добавила OAuth авторизацию
KosilovaDaria Dec 8, 2022
3a2294f
Настроено dev-окружение для SSR
EkaterinaBelonosova Dec 7, 2022
2fccbd8
Добавил ключ к списку строк в таблице
romatou Dec 18, 2022
4175f8a
Добавил команду serve для сборки и запуски продакшн-проекта
romatou Dec 18, 2022
25b8313
Добавил ключ к списку строк в таблице
romatou Dec 18, 2022
e2ea4e5
Добавлен пакет cross-env для поддержки env в Windows
romatou Dec 18, 2022
e32881a
Перенес css из файла в index.html из-за SSR
romatou Dec 18, 2022
15462e7
Поправил оформление кнопки Начать игру
romatou Dec 18, 2022
a3d09bd
Merge main
KosilovaDaria Dec 20, 2022
e0372a7
Fix marks
KosilovaDaria Dec 20, 2022
216c566
Fix bugs
KosilovaDaria Dec 20, 2022
ffe7c81
Настроен docker-контейнер для работы с базой данных
romatou Dec 20, 2022
7e3bf1d
Добавлено окружение бд с pgadmin через docker compose
romatou Dec 23, 2022
c043796
Правки настроек сервера
romatou Dec 24, 2022
528cea5
test forum api
EkaterinaBelonosova Dec 28, 2022
59eb911
add in bd
EkaterinaBelonosova Dec 28, 2022
c2172ad
edit
EkaterinaBelonosova Dec 28, 2022
15003a6
add создание темы
EkaterinaBelonosova Dec 28, 2022
eb6e52b
Поправил конфигурацию vite для сборки проекта
romatou Dec 29, 2022
23027a5
добавление топика и загрузка страницы
EkaterinaBelonosova Jan 4, 2023
241e326
Merge branch 'feature/TEA-64-add-topic' of https://github.com/romatou…
EkaterinaBelonosova Jan 4, 2023
50e038e
добавление нового
EkaterinaBelonosova Jan 4, 2023
a1a2077
изменено модальное окно добавление топика
EkaterinaBelonosova Jan 4, 2023
7849087
Поправила верстку на странице топика
KosilovaDaria Jan 7, 2023
f965b3c
Мердж ветки с OAuth-авторизацией
KosilovaDaria Jan 7, 2023
7cc8627
Добавила проверку авторизации на старницах форума, профиля и игры
KosilovaDaria Jan 9, 2023
b8422fb
Merge branch 'main' into TEA-63-forum-topics-list
KosilovaDaria Jan 9, 2023
9d62517
Поправила ForumSlice (builder)
KosilovaDaria Jan 10, 2023
c3ab184
Merge branch 'TEA-63-forum-topics-list' of https://github.com/romatou…
KosilovaDaria Jan 10, 2023
d05642a
Fixed bugs
KosilovaDaria Jan 10, 2023
32288d0
Merge conflict
KosilovaDaria Jan 11, 2023
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
84 changes: 84 additions & 0 deletions packages/client/src/components/ModalThemeNew/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { useEffect } from 'react'
import * as RB from '@mui/material'
import { useForm, FormProvider } from 'react-hook-form'
import { forumThemeType } from '../../pages/forum/types'
import { useAppDispatch, useAppSelector } from '../../store/index'
import { fetchUser } from '../../store/actions/ProfileActionCreators'
import { selectProfileData } from '../../store/slices/ProfileSlice'

const ModalThemeNew = (props: any) => {
const dispatch = useAppDispatch()
const { userData } = useAppSelector(selectProfileData)

useEffect(() => {
dispatch(fetchUser())
}, [])

const methods = useForm<forumThemeType>({
defaultValues: {
title: '',
description: '',
userId: userData.id,
userLogin: userData.login,
},
mode: 'onBlur',
})
const { register, handleSubmit, reset } = methods

useEffect(() => {
reset({
title: '',
description: '',
userId: userData.id,
userLogin: userData.login,
})
}, [userData])

return (
<RB.Container sx={{ display: 'flex', flexDirection: 'column' }}>
<RB.Dialog open={props.isopen} onClose={props.handleClose}>
<RB.DialogTitle>Создать тему</RB.DialogTitle>
<FormProvider {...methods}>
<form
onSubmit={handleSubmit(data => {
props.onSubmitTheme(data)
reset()
})}>
<RB.DialogContent>
<RB.Grid
container
direction="column"
justifyContent="center"
alignItems="center"
spacing={2}>
<RB.Grid item xs={12}>
<RB.TextField
type="text"
{...register('title')}
label="Название"
size="small"
/>
</RB.Grid>
<RB.Grid item xs={12}>
<RB.TextField
type="text"
{...register('description')}
label="Описание"
size="small"
/>
</RB.Grid>
</RB.Grid>
</RB.DialogContent>
<RB.DialogActions>
<RB.Button size="small" type="submit" onClick={props.handleClose}>
Добавить
</RB.Button>
</RB.DialogActions>
</form>
</FormProvider>
</RB.Dialog>
</RB.Container>
)
}

export default ModalThemeNew
13 changes: 12 additions & 1 deletion packages/client/src/components/YandexIcon/YandexIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import icon from '@assets/RU.svg'
import { SvgIcon } from '@mui/material';
export const YandexIcon = () => {
<<<<<<< HEAD
return (
<SvgIcon viewBox="0 0 44 44" sx={{ width: "24", height: "24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }}>
<rect width="44" height="44" rx="22" fill="#FC3F1D" />
<path d="M25.2438 12.3208H23.0173C19.2005 12.3208 17.292 14.2292 17.292 17.0919C17.292 20.2726 18.5643 21.863 21.427 23.7714L23.6535 25.3618L17.292 35.222H12.2029L18.2463 26.316C14.7475 23.7714 12.839 21.5449 12.839 17.41C12.839 12.3208 16.3378 8.82202 23.0173 8.82202H29.6969V35.222H25.2438V12.3208Z" fill="white" />
</SvgIcon>
);
}

=======
return <img src={icon} />
}
>>>>>>> main
2 changes: 2 additions & 0 deletions packages/client/src/entry-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare global {
}
}


window.addEventListener('load', () => {
if ('serviceWorker' in navigator) {
navigator.serviceWorker
Expand All @@ -30,6 +31,7 @@ window.addEventListener('load', () => {
}
})


ReactDOM.hydrateRoot(
document.getElementById('root') as HTMLElement,
<React.StrictMode>
Expand Down
9 changes: 5 additions & 4 deletions packages/client/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const useAuth = () => {
const navigate = useNavigate()

return () => {
user.userData.id
? navigate('/game/start')
: dispatch(fetchUser()).then(res => {
if (res.type === '/user/fetchUser/rejected') {
if (!user.id) {
dispatch(fetchUser()).then(res => {
if (res.type === 'auth/fetch/rejected') {
return navigate('/auth')
}
})
}
return
}
}
42 changes: 16 additions & 26 deletions packages/client/src/hooks/useOAuth.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
import location from 'location-href'
import { REDIRECT_URI } from '../services/BaseApi'
import { fetchUser, oauthYandex } from '../store/actions/AuthActionCreators'
import { useAppDispatch } from '../store/index'
import { OauthData } from '../store/types'

export const useOAuth = () => {
try {
const dispatch = useAppDispatch()

const url = location()

if (url) {
const code = url.split('=').pop()

return () => {
if (/code/.test(url)) {
dispatch(
oauthYandex({
code: code,
redirect_uri: REDIRECT_URI,
} as OauthData)
).then(res => {
if (res.payload === 'OK') {
dispatch(fetchUser())
}
})
const REDIRECT_URI = 'http://localhost:3001'
const dispatch = useAppDispatch()
const url = document.location.href
const code = url.split('=').pop()
return () => {
if (/code/.test(url)) {
dispatch(
oauthYandex({
code: code,
redirect_uri: REDIRECT_URI,
} as OauthData)
).then(res => {
if (res.payload === 'OK') {
dispatch(fetchUser())
}
}
})
}
} catch (e) {
console.log(e)
}
}
}
8 changes: 4 additions & 4 deletions packages/client/src/hooks/useServiceId.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { REDIRECT_URI } from '../services/BaseApi'
import { getServiceId } from '../store/actions/AuthActionCreators'
import { useAppDispatch } from '../store/index'
import { getServiceId } from '@store/actions/AuthActionCreators'
import { useAppDispatch } from '@store/index'

export const useServiceId = () => {
const dispatch = useAppDispatch()

const REDIRECT_URI = 'http://localhost:3001'
// const REDIRECT_URI =`http://localhost:${__CLIENT_PORT__}`
return () => {
dispatch(getServiceId()).then(res => {
if (res.payload.service_id) {
Expand Down
16 changes: 7 additions & 9 deletions packages/client/src/pages/LoginPage/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { Link, useNavigate } from 'react-router-dom'
import { LoginData } from '../../store/types'
import { useLogin } from '../../hooks/useLogin'
import { useUser } from '../../hooks/useUser'
import { fetchUser } from '../../store/actions/UserActionCreators'
import { useAppDispatch } from '../../store/index'
import { styled } from '@mui/material/styles'
import { fetchUser } from '@store/actions/AuthActionCreators'
import { useAppDispatch } from '@store/index'
import { YandexIcon } from '@components/YandexIcon/YandexIcon'
import { useServiceId } from '../../hooks/useServiceId'

export default function Login() {
Expand All @@ -24,6 +24,7 @@ export default function Login() {
const location = useServiceId()

const YandexIdButton = styled(Button)({
margin: '12px 0',
color: ' white',
width: '100%',
height: '44px',
Expand Down Expand Up @@ -52,7 +53,6 @@ export default function Login() {
} as LoginData
login(authData)
}


return (
<Box color="primary">
Expand Down Expand Up @@ -101,17 +101,15 @@ export default function Login() {
Войти
</Button>
<Typography
component="p"
sx={{ textAlign: 'center', fontSize: '12px' }}>
sx={{ textAlign: 'center' }}>
или
</Typography>
<YandexIdButton
onClick={() => location()}
// startIcon={<YandexIcon/>}
>
startIcon={<YandexIcon/>}>
Войти c Яндекс ID
</YandexIdButton>
<Stack spacing={2} sx={{ textAlign: 'center' }}>
<Stack spacing={1} sx={{ textAlign: 'center' }}>
<Typography>Еще не зарегистрированы?</Typography>
<Typography
to="/register"
Expand Down
Loading