import { useEffect } from 'react' import { useTranslations } from 'next-intl'; import { useDispatch } from 'react-redux'; import { useAppSelector } from '@/redux/store'; import CircularProgress from '@mui/material/CircularProgress'; import { AppDispatch } from '@/redux/store'; import { setSearchKeyword ,load , search , delete_ } from '@/redux/features/members-slice' import ListPagination from './parts/membersListPagination' import { setDetailsPopUp , setUpdatePopUp , setUpdateSubPopUp , setCurrentPage } from '@/redux/features/members-slice'; export default function List() { const t = useTranslations('members'); const dispatch = useDispatch() const listContent = useAppSelector((state) => state.membersReducer.value.listContent) const isLoading = useAppSelector((state) => state.membersReducer.value.isLoading) const loadedFirstTime = useAppSelector((state) => state.membersReducer.value.loadedFirstTime) const searchKeyword = useAppSelector((state) => state.membersReducer.value.searchKeyword) const currentPage = useAppSelector((state) => state.membersReducer.value.currentPage) const appGeneralSettings = useAppSelector((state) => state.settingsReducer.value.appGeneralSettings) useEffect(() => { if(loadedFirstTime) return; if(isLoading) return; async function a() { await dispatch(load({page : 1})) } a() }, []) return ( <>

{t('members')}

# {t('firstName')} {t('lastName')} {t('gendre')} {t('payMonth')} {t('planDelay')} {t('planStatus')} {t('actions')}
{ !isLoading && listContent.flat().length == 0 && currentPage >= 2 && searchKeyword.length == 0 ?

{t('thisPageIsEmpty')}

: <> } { !isLoading && listContent.flat().length == 0 && currentPage < 2 && searchKeyword.length == 0 ?

{t('noData')}

: <> } { !isLoading && listContent.flat().length == 0 && searchKeyword.length != 0 ?

{t('noSearchResults')}

: <> } { // single sender account isLoading ?
: listContent.flat().map((v : any , i) => { return (
{i + 1} {v.firstName} {v.lastName} {t(v.gendre+'Gendre')} {v.payMonth} {appGeneralSettings.currencySymbol} {v.planDelay + ' ' + t('months')} {v.planExpAt_unix - (Date.now() / 1000) > 259200 ? {t('trueActive')} : ( v.planExpAt_unix - (Date.now() / 1000) > 0 ? {t('expireVerySoon')} : {t('falseActive')} ) }
) }) }
) }