Skip to content

Commit

Permalink
Merge pull request #415 from Rushikesh-Sonawane99/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-2424 chore: Added no data found tex when no facilitators present
  • Loading branch information
itsvick authored Nov 23, 2024
2 parents 53c6f50 + 5d7ee45 commit 9880368
Showing 1 changed file with 73 additions and 60 deletions.
133 changes: 73 additions & 60 deletions src/pages/centers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import ManageUser from '@/components/ManageUser';
import { showToastMessage } from '@/components/Toastify';
import { getCohortList } from '@/services/CohortServices';
import useStore from '@/store/store';
import { CenterType, Role, Telemetry , TelemetryEventType} from '@/utils/app.constant';
import {
CenterType,
Role,
Telemetry,
TelemetryEventType,
} from '@/utils/app.constant';
import { accessGranted, toPascalCase } from '@/utils/Helper';
import withAccessControl from '@/utils/hoc/withAccessControl';
import { ArrowDropDown, Clear, Search } from '@mui/icons-material';
Expand Down Expand Up @@ -55,7 +60,7 @@ const CentersPage = () => {
const [centerType, setCenterType] = useState<'regular' | 'remote' | ''>('');
const [appliedFilters, setAppliedFilters] = useState({
centerType: '',
sortOrder: ''
sortOrder: '',
});
const [openCreateCenterModal, setOpenCreateCenterModal] =
React.useState(false);
Expand All @@ -75,7 +80,8 @@ const CentersPage = () => {
cdata: [],
},
edata: {
id:newValue===2? 'change-tab-to-facilitator':'change-tab-to-center',
id:
newValue === 2 ? 'change-tab-to-facilitator' : 'change-tab-to-center',
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
Expand Down Expand Up @@ -134,7 +140,7 @@ const CentersPage = () => {
cdata: [],
},
edata: {
id:'search-centers',
id: 'search-centers',
type: Telemetry.SEARCH,
subtype: '',
pageid: 'centers',
Expand Down Expand Up @@ -236,14 +242,14 @@ const CentersPage = () => {

const getFilteredCenters = useMemo(() => {
let filteredCenters = centerData;

// Apply search filter
if (searchInput) {
filteredCenters = filteredCenters.filter((center) =>
center.cohortName.toLowerCase().includes(searchInput.toLowerCase())
);
}

// Apply center type filter
if (centerType) {
filteredCenters = filteredCenters.filter(
Expand All @@ -252,21 +258,21 @@ const CentersPage = () => {
center.centerType.toLowerCase() === centerType.toLowerCase()
);
}

// Apply sorting
if (sortOrder === 'asc') {
filteredCenters.sort((a, b) => a.cohortName.localeCompare(b.cohortName));
} else if (sortOrder === 'desc') {
filteredCenters.sort((a, b) => b.cohortName.localeCompare(a.cohortName));
}

return filteredCenters;
}, [centerData, searchInput, appliedFilters]);

useEffect(() => {
setFilteredCenters(getFilteredCenters);
}, [getFilteredCenters]);

const handleFilterApply = () => {
setAppliedFilters({ centerType, sortOrder });
setFilteredCenters(getFilteredCenters);
Expand All @@ -278,13 +284,14 @@ const CentersPage = () => {
cdata: [],
},
edata: {
id:'apply-filter',
id: 'apply-filter',
type: TelemetryEventType.RADIO,
subtype: '',
pageid: 'centers',
},
};
telemetryFactory.interact(telemetryInteract); };
telemetryFactory.interact(telemetryInteract);
};

const handleCreateCenterClose = () => {
setOpenCreateCenterModal(false);
Expand Down Expand Up @@ -471,46 +478,48 @@ const CentersPage = () => {
'showCreateCenterButton',
accessControl,
userRole
) && isActiveYear && (
<Box mt={'18px'} px={'18px'}>
<Button
sx={{
border: '1px solid #1E1B16',
borderRadius: '100px',
height: '40px',
px: '20px',
color: theme.palette.error.contrastText,
'& .MuiButton-endIcon': {
marginLeft: isRTL
? '0px !important'
: '8px !important',
marginRight: isRTL
? '8px !important'
: '-2px !important',
},
}}
className="text-1E"
endIcon={<AddIcon />}
onClick={() => {setOpenCreateCenterModal(true)
const telemetryInteract = {
context: {
env: 'teaching-center',
cdata: [],
},
edata: {
id:'click-on-create-center',
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
) &&
isActiveYear && (
<Box mt={'18px'} px={'18px'}>
<Button
sx={{
border: '1px solid #1E1B16',
borderRadius: '100px',
height: '40px',
px: '20px',
color: theme.palette.error.contrastText,
'& .MuiButton-endIcon': {
marginLeft: isRTL
? '0px !important'
: '8px !important',
marginRight: isRTL
? '8px !important'
: '-2px !important',
},
};
telemetryFactory.interact(telemetryInteract);
}}
>
{t('BLOCKS.CREATE_NEW')}
</Button>
</Box>
)}
}}
className="text-1E"
endIcon={<AddIcon />}
onClick={() => {
setOpenCreateCenterModal(true);
const telemetryInteract = {
context: {
env: 'teaching-center',
cdata: [],
},
edata: {
id: 'click-on-create-center',
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
},
};
telemetryFactory.interact(telemetryInteract);
}}
>
{t('BLOCKS.CREATE_NEW')}
</Button>
</Box>
)}
</Grid>

{openCreateCenterModal && (
Expand Down Expand Up @@ -565,15 +574,19 @@ const CentersPage = () => {
</>
)}
</Box>
<Box>
{value === 2 && blockData?.length > 0 && (
<ManageUser
reloadState={reloadState}
setReloadState={setReloadState}
cohortData={blockData}
/>
)}
</Box>
{value === 2 ? (
<Box>
{blockData?.length > 0 ? (
<ManageUser
reloadState={reloadState}
setReloadState={setReloadState}
cohortData={blockData}
/>
) : (
<NoDataFound />
)}
</Box>
) : null}
</Box>
<FilterModalCenter
open={filterModalOpen}
Expand Down

0 comments on commit 9880368

Please sign in to comment.