Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #44 from exortme1ster/websockets-fix
Browse files Browse the repository at this point in the history
Fixed bugs, added responsive profile
  • Loading branch information
nmashchenko committed Jul 1, 2023
2 parents d8531d6 + 6e73d56 commit 05412ec
Show file tree
Hide file tree
Showing 154 changed files with 4,273 additions and 2,354 deletions.
3 changes: 3 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import { Toaster } from 'react-hot-toast'
import { BrowserRouter as Router } from 'react-router-dom'
import { GoogleOAuthProvider } from '@react-oauth/google'

import { useLoadSocket } from './api/hooks/socket/useLoadSocket'
import { useRoutes } from './routes/routes'

function App() {
const routes = useRoutes()

useLoadSocket()

return (
<>
<GoogleOAuthProvider clientId={process.env.REACT_APP_GOOGLE_API_OAUTH_TOKEN}>
Expand Down
55 changes: 0 additions & 55 deletions client/src/api/endpoints/registration-auth.js

This file was deleted.

36 changes: 0 additions & 36 deletions client/src/api/endpoints/submission.js

This file was deleted.

88 changes: 0 additions & 88 deletions client/src/api/endpoints/team.js

This file was deleted.

36 changes: 0 additions & 36 deletions client/src/api/endpoints/tournament.js

This file was deleted.

39 changes: 0 additions & 39 deletions client/src/api/endpoints/users.js

This file was deleted.

2 changes: 2 additions & 0 deletions client/src/api/hooks/auth/useCheckAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const useCheckAuth = () => {
onSuccess: (data) => {
if (data && data.isRegistered) {
dispatch(userAuth.actions.authUserSuccess())
dispatch(userAuth.actions.setUserNotifications(data?.notifications))
dispatch(userAuth.actions.setUserId(data?._id))
}
},
onError: (error) => {
Expand Down
2 changes: 2 additions & 0 deletions client/src/api/hooks/auth/useLoginUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const useLoginUser = (type) => {
if (user.isRegistered) {
// save accessToken
dispatch(userAuth.actions.authUserSuccess())
dispatch(userAuth.actions.setUserNotifications(user?.notifications))
dispatch(userAuth.actions.setUserId(data?._id))
navigate('/', { replace: true })
} else {
// navigate user to finish registration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { errorToaster } from '../../../shared/components/Toasters/Error.toaster'

const { api } = http

export const useUpdateAvatar = (type) => {
export const useUpdateAvatar = (type, successHandler) => {
const queryClient = useQueryClient()

const updateUserAvatar = async (userData) => {
Expand All @@ -18,6 +18,12 @@ export const useUpdateAvatar = (type) => {
onSuccess: async () => {
if (type === 'teams') {
await queryClient.invalidateQueries('getTeamById', { refetchInactive: true })
} else if (type === 'users') {
await queryClient.invalidateQueries('getUserById', { refetchInactive: true })
}

if (successHandler) {
successHandler()
}

await queryClient.invalidateQueries('checkAuth', { refetchInactive: true })
Expand Down
10 changes: 3 additions & 7 deletions client/src/api/hooks/sidebar/useReadMessages.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { useMutation, useQueryClient } from 'react-query'
import { useDispatch } from 'react-redux'
import { useMutation } from 'react-query'

import http from '../../../http'
import { registrationAuth } from '../../../store/reducers/RegistrationAuth'
import { errorToaster } from '../../../shared/components/Toasters/Error.toaster'

const { api } = http

export const useReadMessages = () => {
const dispatch = useDispatch()
const queryClient = useQueryClient()

const readMessages = async (idsArr) => {
return await api.put('notifications/read', { notifications: idsArr })
}
Expand All @@ -21,7 +17,7 @@ export const useReadMessages = () => {
},
onError: (error) => {
// set error message
dispatch(registrationAuth.actions.finishRegistrationError(error.response?.data?.message))
errorToaster(error)
},
})
}
Loading

0 comments on commit 05412ec

Please sign in to comment.