Skip to content

Commit

Permalink
Merge pull request #325 from suvarnakale/shiksha-2.0
Browse files Browse the repository at this point in the history
Issue #000 chore: build issue fixes
  • Loading branch information
itsvick authored Jun 28, 2024
2 parents cc6cdd3 + 3775a0b commit 6a9ed00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/components/ManageCentersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ManageCentersModal: React.FC<ManageUsersModalProps> = ({
}) => {
const theme = useTheme<any>();
const { t } = useTranslation();
const [checkedCenters, setCheckedCenters] = React.useState([]);
const [checkedCenters, setCheckedCenters] = React.useState<string[]>([]);

const style = {
position: 'absolute',
Expand All @@ -47,7 +47,9 @@ const ManageCentersModal: React.FC<ManageUsersModalProps> = ({
};

React.useEffect(() => {
setCheckedCenters(centers);
if (centers) {
setCheckedCenters(centers as never[]);
}
}, [centers]);

const handleToggle = (name: string) => {
Expand All @@ -67,7 +69,9 @@ const ManageCentersModal: React.FC<ManageUsersModalProps> = ({
};

const handleAssign = () => {
onAssign(checkedCenters);
if (onAssign) {
onAssign(checkedCenters);
}
};

return (
Expand Down
11 changes: 8 additions & 3 deletions src/pages/manageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ interface Cohort {
name: string;
}

interface User {
name: string;
userId: string;
}

type CohortsData = {
[userId: string]: Cohort[];
};
Expand All @@ -58,7 +63,7 @@ const manageUsers = () => {
const [centersData, setCentersData] = useState<Cohort[]>([]);
const [open, setOpen] = React.useState(false);
const [openCentersModal, setOpenCentersModal] = React.useState(false);
const [selectedUser, setSelectedUser] = useState(null);
const [selectedUser, setSelectedUser] = useState<User | null>(null);
const [selectedUserName, setSelectedUserName] = useState(null);
const [centers, setCenters] = useState<string[]>([]);
const [centerList, setCenterList] = useState<string[]>([]);
Expand Down Expand Up @@ -245,10 +250,10 @@ const manageUsers = () => {
}
};

const handleAssignCenters = async (selectedCenters) => {
const handleAssignCenters = async (selectedCenters: any) => {
console.log('selectedUser', selectedUser);
try {
const selectedUserIds = [selectedUser.userId];
const selectedUserIds = [selectedUser?.userId];

const matchedCohortIdsFromCohortsData = Object.values(cohortsData)
.flatMap((cohorts) => cohorts)
Expand Down

0 comments on commit 6a9ed00

Please sign in to comment.