-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Harrylever/dev
Dev
- Loading branch information
Showing
20 changed files
with
666 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './hooks/hooks'; | ||
export * from './store/store'; | ||
export * from './constants/const'; | ||
export * from './slices/authSlice'; | ||
export * from './store/store'; | ||
export { default as useAxiosPrivate } from './hooks/useAxiosPrivate'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { INotification } from '../../../typings'; | ||
|
||
interface INotificationSlice { | ||
notifications: Array<INotification>; | ||
} | ||
|
||
const initState: INotificationSlice = { | ||
notifications: [], | ||
}; | ||
|
||
const notificationSlice = createSlice({ | ||
name: 'notificationSlice', | ||
initialState: initState, | ||
reducers: { | ||
setReduxNotifications: ( | ||
state: INotificationSlice, | ||
action: PayloadAction<INotificationSlice> | ||
) => { | ||
state.notifications = action.payload.notifications; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setReduxNotifications } = notificationSlice.actions; | ||
export default notificationSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,64 @@ | ||
import { Outlet } from 'react-router-dom'; | ||
import { NavBarComponent, SideBarChatList } from '../sections'; | ||
import { useEffect, useState } from 'react'; | ||
import axios from 'axios'; | ||
import { IUser } from '../../../typings'; | ||
import { Outlet } from 'react-router-dom'; | ||
import { useAppSelector } from '../../app'; | ||
import React, { useEffect, useState } from 'react'; | ||
import LoadingPlayer from '../atoms/LoadingPlayer'; | ||
import { NavBarComponent, SideBarChatList } from '../sections'; | ||
|
||
export default function Layout() { | ||
const user = useAppSelector((state) => state.userReduce); | ||
const sideBarChatListIsOpen = useAppSelector((state) => state.appUIStateReduce.sideBarChatOpen); | ||
const sideBarChatListIsOpen = useAppSelector( | ||
(state) => state.appUIStateReduce.sideBarChatOpen | ||
); | ||
|
||
const [localuser, setLocalUser] = useState<IUser | undefined>(undefined); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
if (user && user._id !== '') { | ||
setLocalUser(user); | ||
} | ||
}, [user]); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const handleGetAPIIndex = async () => { | ||
const BASE_URL = import.meta.env.VITE_BE_URL; | ||
const fetch = await axios.get(BASE_URL); | ||
return fetch.data; | ||
}; | ||
|
||
const response = await handleGetAPIIndex(); | ||
if (response.success) { | ||
setIsLoading(false); | ||
} | ||
})(); | ||
}, []); | ||
|
||
return ( | ||
<div className="w-full text-white font-nunito"> | ||
<div className="w-full relative"> | ||
{/* */} | ||
{sideBarChatListIsOpen && <SideBarChatList />} | ||
<React.Fragment> | ||
{isLoading ? ( | ||
<LoadingPlayer /> | ||
) : ( | ||
<div className="w-full text-white font-nunito"> | ||
<div className="w-full relative"> | ||
{/* */} | ||
{sideBarChatListIsOpen && <SideBarChatList />} | ||
|
||
<div className="relative z-[20] w-full bg-slate-900 shadow-xl"> | ||
<div className="mx-auto px-6 sm:px-8"> | ||
<NavBarComponent props={{ user: localuser }} /> | ||
</div> | ||
</div> | ||
<div className="relative z-[10] w-full pt-5"> | ||
<div className=" max-w-6xl mx-auto px-6 sm:px-8 xl:px-0"> | ||
<Outlet /> | ||
<div className="relative z-[20] w-full bg-slate-900 shadow-xl"> | ||
<div className="mx-auto px-6 sm:px-8"> | ||
<NavBarComponent props={{ user: localuser }} /> | ||
</div> | ||
</div> | ||
<div className="relative z-[10] w-full pt-5"> | ||
<div className=" max-w-6xl mx-auto px-6 sm:px-8 xl:px-0"> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
</React.Fragment> | ||
); | ||
} |
Oops, something went wrong.