Skip to content

Commit

Permalink
Merge pull request #93 from AkshataKatwal16/admin
Browse files Browse the repository at this point in the history
Issue PS-1484 feat: FIx UI issues
  • Loading branch information
itsvick authored Aug 3, 2024
2 parents b3a01cc + 68df057 commit cf2f4be
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 17 deletions.
16 changes: 10 additions & 6 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
"ALL_BLOCKS": "Blocks",
"NEW_FACILITATOR": "New Facilitator",
"SEARCHBAR_PLACEHOLDER": "Search Facilitators..",
"FACILITATOR_CREATED_SUCCESSFULLY": "Teacher has been Successfully Created",
"FACILITATOR_UPDATED_SUCCESSFULLY": "Teacher has been Successfully Updated!"
"FACILITATOR_CREATED_SUCCESSFULLY": "Teacher has been successfully created",
"FACILITATOR_UPDATED_SUCCESSFULLY": "Teacher has been successfully updated!",
"EDIT_FACILITATOR":"Edit Facilitator"
},
"NAVBAR": {
"SEARCHBAR_PLACEHOLDER": "Search course, topic, student, pdf etc.."
Expand All @@ -97,15 +98,18 @@
"SEARCHBAR_PLACEHOLDER": "Search Learners..",
"NEW_LEARNER": "New Learner",
"FIRST_SELECT_REQUIRED_FIELDS": "First select required fields",
"LEARNER_CREATED_SUCCESSFULLY": "Learner has been Successfully Created!",
"LEARNER_UPDATED_SUCCESSFULLY": "Learner has been Successfully Updated!"
"LEARNER_CREATED_SUCCESSFULLY": "Learner has been successfully created!",
"LEARNER_UPDATED_SUCCESSFULLY": "Learner has been successfully updated!",
"EDIT_LEARNER":"Edit Learner"

},
"TEAM_LEADERS": {
"SEARCHBAR_PLACEHOLDER": "Search Team leaders..",
"NEW_TEAM_LEADER": "New Team Leader",
"FIRST_SELECT_REQUIRED_FIELDS": "First select required fields",
"TEAM_LEADER_CREATED_SUCCESSFULLY": "Team Leader has been Successfully Created!",
"TEAM_LEADER_UPDATED_SUCCESSFULLY": "Team Leader has been Successfully Updated!"
"TEAM_LEADER_CREATED_SUCCESSFULLY": "Team Leader has been successfully created!",
"TEAM_LEADER_UPDATED_SUCCESSFULLY": "Team Leader has been successfully updated!",
"EDIT_TEAM_LEADER":"Edit Team Leader"
},
"COHORTS": {
"SEARCHBAR_PLACEHOLDER": "Search Center.."
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddFacilitator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const AddFacilitatorModal: React.FC<AddFacilitatorModalprops> = ({
open={open}
onClose={onClose}
showFooter={false}
modalTitle={t("FACILITATORS.NEW_FACILITATOR")}
modalTitle={ !isEditModal?t("FACILITATORS.NEW_FACILITATOR"): t("FACILITATORS.EDIT_FACILITATOR")}
>
{/* {!dynamicForm && (
<Typography>{t("LEARNERS.FIRST_SELECT_REQUIRED_FIELDS")} </Typography>
Expand Down
10 changes: 8 additions & 2 deletions src/components/AddLeanerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface AddLearnerModalProps {
formData?: object;
isEditModal?: boolean;
userId?: string;
onSubmit: (submitValue: boolean) => void;
}
interface FieldProp {
value: string;
Expand All @@ -45,10 +46,12 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
formData,
isEditModal = false,
userId,
onSubmit
}) => {
const [schema, setSchema] = React.useState<any>();
const [uiSchema, setUiSchema] = React.useState<any>();


const [credentials, setCredentials] = React.useState({
username: "",
password: "",
Expand Down Expand Up @@ -212,6 +215,7 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
const response = await createUser(apiBody);
showToastMessage(t("LEARNERS.LEARNER_CREATED_SUCCESSFULLY"), "success");
}
onSubmit(true);
onClose();
} catch (error) {
onClose();
Expand Down Expand Up @@ -303,7 +307,7 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
open={open}
onClose={onClose}
showFooter={false}
modalTitle={t("LEARNERS.NEW_LEARNER")}
modalTitle={!isEditModal?t("LEARNERS.NEW_LEARNER"): t("LEARNERS.EDIT_LEARNER")}
>
<>
<Box
Expand Down Expand Up @@ -376,5 +380,7 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
</>
);
};

AddLearnerModal.defaultProps = {
onSubmit: () => {}, // Default to a no-op function
};
export default AddLearnerModal;
2 changes: 1 addition & 1 deletion src/components/AddTeamLeaderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const AddTeamLeaderModal: React.FC<AddLearnerModalProps> = ({
open={open}
onClose={onClose}
showFooter={false}
modalTitle={t("TEAM_LEADERS.NEW_TEAM_LEADER")}
modalTitle={!isEditModal? t("TEAM_LEADERS.NEW_TEAM_LEADER"): t("TEAM_LEADERS.EDIT_TEAM_LEADER")}
>
<>
<Box
Expand Down
1 change: 0 additions & 1 deletion src/components/KaTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
: [...prevSelected, rowId]
);
};

const tableProps: ITableProps = {
columns,
data,
Expand Down
8 changes: 6 additions & 2 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ const UserTable: React.FC<UserTableProps> = ({
const [loading, setLoading] = useState<boolean | undefined>(undefined);
const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false);
const [userId, setUserId] = useState();
const [submitValue, setSubmitValue] = useState<boolean>(false);

const handleOpenAddLearnerModal = () => {
console.log("hello");
setOpenAddLearnerModal(true);
};
const handleModalSubmit = (value: boolean) => {
setSubmitValue(true);

};
const handleCloseAddLearnerModal = () => {
setOpenAddLearnerModal(false);
};
Expand Down Expand Up @@ -514,7 +517,7 @@ const handleCloseAddTeamLeaderModal = () => {
}
};
fetchUserList();
}, [pageOffset, pageLimit, sortBy, filters, openAddFacilitatorModal, openAddLearnerModal, openAddTeamLeaderModal, parentState]);
}, [pageOffset,submitValue, pageLimit, sortBy, filters, openAddFacilitatorModal, openAddTeamLeaderModal]);

useEffect(() => {
const fetchData = async () => {
Expand Down Expand Up @@ -662,6 +665,7 @@ const handleCloseAddTeamLeaderModal = () => {
formData={formdata}
isEditModal={true}
userId={userId}
onSubmit={handleModalSubmit}
/>
<AddFacilitatorModal
open={openAddFacilitatorModal}
Expand Down
1 change: 1 addition & 0 deletions src/components/layouts/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const Sidebar = ({
selected={location === subItem.href}
sx={{
pl: 8,
ml:2,
mb: 1,
...(location === subItem.href && {
color: "black",
Expand Down
7 changes: 7 additions & 0 deletions src/pages/learners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ import AddLearnerModal from '@/components/AddLeanerModal';
const Learners: React.FC = () => {
const { t } = useTranslation();
const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false);
const [submitValue, setSubmitValue] = React.useState<boolean>(false);

const handleOpenAddLearnerModal = () => {
setOpenAddLearnerModal(true);
};
const handleModalSubmit = (value: boolean) => {
setSubmitValue(true);

};
const handleCloseAddLearnerModal = () => {
setOpenAddLearnerModal(false);
};
Expand All @@ -24,6 +29,8 @@ const handleCloseAddLearnerModal = () => {
<AddLearnerModal
open={openAddLearnerModal}
onClose={handleCloseAddLearnerModal}
onSubmit={handleModalSubmit}

/>

</>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ const LoginPage = () => {
)}
<Image src={appLogo} alt="App Logo" height={100} />
</Box>
<Typography
{/* <Typography
variant="h4"
gutterBottom
textAlign="center"
sx={{ mt: 2 }}
>
{t("LOGIN_PAGE.LOGIN")}
</Typography>
</Typography> */}
<FormControl fullWidth margin="normal">
<Select
className="SelectLanguages"
Expand Down Expand Up @@ -293,7 +293,7 @@ const LoginPage = () => {
marginTop="1.2rem"
className="remember-me-checkbox"
>
<Checkbox
{/* <Checkbox
onChange={(e) => setRememberMe(e.target.checked)}
checked={rememberMe}
/>
Expand All @@ -316,7 +316,7 @@ const LoginPage = () => {
}}
>
{t("LOGIN_PAGE.REMEMBER_ME")}
</Typography>
</Typography> */}
</Box>
<Box marginTop="2rem" textAlign="center">
<Button
Expand Down
1 change: 1 addition & 0 deletions src/pages/logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Logout() {
};
userLogout();
localStorage.removeItem("token");

router.replace("/login");
}, []);

Expand Down

0 comments on commit cf2f4be

Please sign in to comment.