34 lines
1.4 KiB
JavaScript
34 lines
1.4 KiB
JavaScript
import React, { useContext, useEffect, useState } from 'react'
|
|
import { getNotifications } from '../../middlewares/notifications/getNotifications';
|
|
import Notification from '../middlewares/notifications/Notification';
|
|
import { GSContext } from '../../middlewares/GlobalStore';
|
|
import HomeLeft from '../menus/left/HomeLeft';
|
|
import { I18nContext } from '../../middlewares/Locale';
|
|
|
|
export default function Notifications() {
|
|
const { locale } = useContext(I18nContext);
|
|
const { globalState } = useContext(GSContext);
|
|
|
|
useEffect(()=>{
|
|
getNotifications().then(get => globalState.setNotifications(get));
|
|
globalState.states.setLeftMenu(<HomeLeft/>);
|
|
},[]);
|
|
|
|
return (
|
|
<div className='flex flex-col bg-white rounded-2xl p-1 gap-2 w-full h-96'>
|
|
<div className='flex items-center p-2 justify-between'>
|
|
<p className='font-bold'>{locale["notifications"]}</p>
|
|
<p onClick={() => {getNotifications().then(get => globalState.setNotifications(get))}} className='p-2 rounded-lg cursor-pointer hover:bg-pc'>Yenile</p>
|
|
</div>
|
|
<hr/>
|
|
<div className='flex flex-col gap-1 overflow-hidden overflow-y-scroll'>
|
|
{
|
|
globalState.notifications.map((get) =>
|
|
<Notification key={get.id} data={get} notifications={get}/>
|
|
)
|
|
}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|