Skip to content

Commit

Permalink
Merge pull request #516 from Aar-if/fifty
Browse files Browse the repository at this point in the history
Issue #000 Bug:  Reassign caching issue fix
  • Loading branch information
itsvick authored Dec 12, 2024
2 parents afa0225 + 60fe4d5 commit 03e209e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/components/ManageCentersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ const ManageCentersModal: React.FC<ManageUsersModalProps> = ({
{isForLearner ? (
<Radio
sx={{ pb: '20px' }}
checked={selectedValue === center?.name?.toLowerCase()}
checked={
selectedValue === center?.name?.toLowerCase()
}
onChange={() =>
handleRadioChange(center?.name, center?.cohortId)
}
Expand Down
16 changes: 8 additions & 8 deletions src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({

setTimeout(() => {
console.log('extractedData', extractedData);

setUsers(extractedData);
setLoading(false);
});
Expand Down Expand Up @@ -249,6 +250,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({
) || [t('ATTENDANCE.NO_CENTERS_ASSIGNED')];
setCenters(centerNames);
setSelectedUser(user);
console.log(user);
}

if (
Expand Down Expand Up @@ -295,14 +297,13 @@ const ManageUser: React.FC<ManageUsersProps> = ({
cdata: [],
},
edata: {
id:'click-on-delete-user:'+userId,
id: 'click-on-delete-user:' + userId,
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
},
};
telemetryFactory.interact(telemetryInteract);

} else {
console.log(
'User does not belong to any cohorts, proceed with deletion'
Expand Down Expand Up @@ -357,7 +358,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({
cdata: [],
},
edata: {
id:'click-on-reassign-centers:'+userId,
id: 'click-on-reassign-centers:' + userId,
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
Expand Down Expand Up @@ -450,17 +451,15 @@ const ManageUser: React.FC<ManageUsersProps> = ({
const handleRequestBlockAction = () => {
showToastMessage(t('BLOCKS.REASSIGN_BLOCK_REQUESTED'), 'success');


setState({ ...state, bottom: false });


const telemetryInteract = {
context: {
env: 'teaching-center',
cdata: [],
},
edata: {
id:'reassign-block-request-success',
id: 'reassign-block-request-success',
type: Telemetry.CLICK,
subtype: '',
pageid: 'centers',
Expand Down Expand Up @@ -561,7 +560,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({
fontSize: '24px',
marginTop: '1rem',
color: theme.palette.warning['300'],
cursor:'pointer'
cursor: 'pointer',
}}
/>
) : (
Expand Down Expand Up @@ -697,7 +696,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({
fontSize: '24px',
marginTop: '1rem',
color: theme.palette.warning['300'],
cursor:'pointer'
cursor: 'pointer',
}}
/>
</Box>
Expand Down Expand Up @@ -867,6 +866,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({
reloadState={reloadState}
setReloadState={setReloadState}
buttonNames={{ primary: t('COMMON.SAVE') }}
selectedUser={selectedUser}
/>

<DeleteUserModal
Expand Down
19 changes: 13 additions & 6 deletions src/components/ReassignModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { toPascalCase } from '@/utils/Helper';
import NoDataFound from './common/NoDataFound';
import { useQueryClient } from '@tanstack/react-query';


interface ReassignModalProps {
cohortNames?: any;
message: string;
Expand All @@ -24,6 +23,7 @@ interface ReassignModalProps {
modalOpen: boolean;
reloadState: boolean;
setReloadState: React.Dispatch<React.SetStateAction<boolean>>;
selectedUser: any;
}

interface ButtonNames {
Expand All @@ -35,7 +35,7 @@ interface Cohort {
id: any;
cohortId: string;
name: string;
status: any
status: any;
}

const ReassignModal: React.FC<ReassignModalProps> = ({
Expand All @@ -47,8 +47,9 @@ const ReassignModal: React.FC<ReassignModalProps> = ({
handleCloseReassignModal,
reloadState,
setReloadState,
selectedUser,
}) => {
console.log("ReassignModal")
console.log('ReassignModal');
const theme = useTheme<any>();
const { t } = useTranslation();
const store = useStore();
Expand All @@ -59,7 +60,7 @@ const ReassignModal: React.FC<ReassignModalProps> = ({
(cohort: { cohortId: any; name: string; status: any }) => ({
name: cohort.name,
id: cohort.cohortId,
status: cohort?.status
status: cohort?.status,
})
);

Expand Down Expand Up @@ -94,8 +95,10 @@ const ReassignModal: React.FC<ReassignModalProps> = ({
const filteredCenters = React.useMemo(() => {
return cohorts
.map(({ cohortId, name, status }) => ({ id: cohortId, name, status }))
.filter(({ name, status }) =>
name.toLowerCase().includes(searchInput.toLowerCase()) && status === Status.ACTIVE
.filter(
({ name, status }) =>
name.toLowerCase().includes(searchInput.toLowerCase()) &&
status === Status.ACTIVE
)
.sort((a, b) =>
checkedCenters.includes(a.name) === checkedCenters.includes(b.name)
Expand Down Expand Up @@ -129,6 +132,10 @@ const ReassignModal: React.FC<ReassignModalProps> = ({
queryClient.invalidateQueries({
queryKey: [QueryKeys.GET_ACTIVE_FACILITATOR],
});
queryClient.invalidateQueries({
queryKey: [QueryKeys.MY_COHORTS, selectedUser.userId],
});

setReloadState(true);
} catch (error) {
showToastMessage(t('MANAGE_USERS.CENTERS_REQUEST_FAILED'), 'error');
Expand Down

0 comments on commit 03e209e

Please sign in to comment.