Skip to content

Commit

Permalink
Merge pull request #48 from chaitanyakole/bugs_issue
Browse files Browse the repository at this point in the history
Bug #235035 [admin portal] Learner Details List Does Not Auto-RefreshAfter Update/Delete. Bug #235032 [admin portal] While Creaing Learner, Full Name Field Removes Space Between First and Last Name.Bug #235022 [admin portal] while creating cohort admin,showing unecessary validation error.PFA  Bug #235063 [admin portal] Search is not working properly. PFA Bug #234421 [Admin] Sorting is not working on cohort list page. PFA
  • Loading branch information
gouravmore authored Feb 14, 2025
2 parents 65683a0 + 6d8cfd4 commit 5fbdeea
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 34 deletions.
5 changes: 4 additions & 1 deletion src/components/AddNewTenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
showToastMessage("Form data is required", "error");
return;
}
const formatName = (names: any) => {
return names?.trim().replace(/\s+/g, " ");
};
const cohortDetails: CohortDetails = {
name: formData?.name.replace(/\s/g, ""),
name: formatName(formData?.name),
domain: formData?.domain ? formData?.domain : " ",
// status: formData?.status,
};
Expand Down
12 changes: 12 additions & 0 deletions src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
delete updatedUiSchema[property]["ui:help"];
}

if (property === "mail") {
if (error.name === "required") {
error.message = submittedButtonStatus
? t("FORM_ERROR_MESSAGES.THIS_IS_REQUIRED_FIELD")
: "";
} else if (error.name === "format" || error.name === "pattern") {
error.message = !submittedButtonStatus
? t("FORM_ERROR_MESSAGES.ENTER_VALID_EMAIL_ADDRESS")
: "";
}
return error;
}
switch (error.name) {
case "required": {
error.message = submittedButtonStatus
Expand Down
25 changes: 15 additions & 10 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,7 @@ const UserTable: React.FC<UserTableProps> = ({
if (filters.name) {
offset = 0;
}
const tenantId = filters?.tenantId
? filters?.tenantId
: listOfTenants?.[0]?.tenantId;
const tenantId = filters?.tenantId && filters?.tenantId;

const selectedTenantOrNot = selectedTenant?.[0] === "All";
const payload = {
Expand Down Expand Up @@ -664,11 +662,12 @@ const UserTable: React.FC<UserTableProps> = ({

fetchUserList();
}, [
// pageOffset,
pageOffset,
// submitValue,
pageLimit,
sortBy,
filters,
editUserState,
// parentState,
// userType,
// editUserState,
Expand All @@ -683,10 +682,13 @@ const UserTable: React.FC<UserTableProps> = ({
if (selectedNames && selectedCodes) {
const tenantId = selectedCodes.join(",");
setSelectedTenant(selectedNames);
if (selectedNames?.[0] == "All") {
setFilters((prevFilter) => ({
...prevFilter,
}));

if (selectedNames?.[0] === "All") {
setFilters((prevFilter) => {
const newFilters = { ...prevFilter };
delete newFilters.tenantId;
return newFilters;
});
} else {
setFilters((prevFilter) => ({
...prevFilter,
Expand All @@ -709,7 +711,7 @@ const UserTable: React.FC<UserTableProps> = ({
value: number
) => {
if (value >= 1 && value <= pageCount) {
setPageOffset(value - 1); // Ensure pageOffset is updated correctly
setPageOffset(value - 1);
}
};

Expand Down Expand Up @@ -795,9 +797,12 @@ const UserTable: React.FC<UserTableProps> = ({
// showToastMessage(t("CENTERS.NO_COHORT_ID_SELECTED"), "error");
// return;
// }
const formatName = (names: any) => {
return names?.trim().replace(/\s+/g, " ");
};
let cohortDetails = {
userData: {
name: formData?.name.replace(/\s/g, ""),
name: formatName(formData?.name),
role: formData?.role,
userId: formData?.userId,
username: formData?.username.replace(/\s/g, ""),
Expand Down
4 changes: 0 additions & 4 deletions src/components/layouts/header/Invitation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ const InvitationMenu = () => {
) => {
try {
// Simulate API call
console.log("invitation", tenantId, invitationId);

const respose = await updateInvitation({
invitationId,
invitationStatus,
Expand All @@ -188,8 +186,6 @@ const InvitationMenu = () => {
showToastMessage(t("COHORTINVITATION.ACCEPTED_SUCCESS"), "success");
router.push("/cohorts");
} else {
console.log("response", respose);

showToastMessage(t("COHORTINVITATION.REJECTED_SUCCESS"), "success");
}
fetchInitialInvitations();
Expand Down
4 changes: 1 addition & 3 deletions src/context/AuthContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const AuthProvider = ({ children }) => {
if (refreshToken) {
await logout(refreshToken);
}
} catch (error) {
console.log(error);
}
} catch (error) {}
localStorage.removeItem("token");

router.replace("/login");
Expand Down
1 change: 0 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ function App({ Component, pageProps }: AppProps) {
await registerUser();
}
if (keycloak.refreshToken) {
console.log("Get keycloak refresh token token", keycloak);
localStorage.setItem("refreshToken", keycloak.refreshToken);
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/cohortAdminSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
}
},
"dependencies": {}
}
}
31 changes: 24 additions & 7 deletions src/pages/cohorts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const Center: React.FC = () => {
name: {
"ui:widget": "text",
"ui:placeholder": "Enter your full name",
"ui:help": "Full name, numbers, letters and spaces are allowed.",
// "ui:help": "Full name, numbers, letters and spaces are allowed.",
},
username: {
"ui:widget": "text",
Expand Down Expand Up @@ -231,7 +231,13 @@ const Center: React.FC = () => {
email: {
// "ui:widget": "text",
"ui:placeholder": "Enter your email address",
"ui:help": "Enter a valid email address.",
// "ui:help": "Enter a valid email address.",
// "ui:options": {
// errorsSchema: {
// required: "This field is required",
// pattern: "Enter a valid email address",
// },
// },
// "ui:options": {},
},
// dob: {
Expand Down Expand Up @@ -453,7 +459,6 @@ const Center: React.FC = () => {
tenantId: tenantId,
}));
} else {
console.log("No valid tenants selected");
}
};

Expand Down Expand Up @@ -646,6 +651,16 @@ const Center: React.FC = () => {
const handleError = (error: any) => {
setError(error);
};
const handleCohortAdminError = (errors: any) => {
if (errors.length > 0) {
if (!errors[0].formData?.email) {
errors = [
errors.find((error: any) => error.name === "required"),
].filter(Boolean);
}
}
return errors;
};
const handleUpdateAction = async (
data: IChangeEvent<any, RJSFSchema, any>,
event: React.FormEvent<any>
Expand Down Expand Up @@ -799,9 +814,11 @@ const Center: React.FC = () => {
(role: any) => role.code === formData?.role
);
const roleId = matchedRole ? matchedRole?.roleId : "";

const formatName = (names: any) => {
return names?.trim().replace(/\s+/g, " ");
};
let obj: UserCreateData = {
name: formData?.name.replace(/\s/g, ""),
name: formatName(formData?.name),
mobile: formData?.mobileNo,
email: formData?.email,
username: formData?.username.replace(/\s/g, ""),
Expand Down Expand Up @@ -925,7 +942,7 @@ const Center: React.FC = () => {
handleAddUserClick: handleAddUserClick,
statusValue: statusValue,
setStatusValue: setStatusValue,
showSort: true,
showSort: false,
};

return (
Expand Down Expand Up @@ -1149,7 +1166,7 @@ const Center: React.FC = () => {
uiSchema={cohortAdminUiSchema}
onSubmit={handleAddCohortAdminAction}
onChange={handleChangeForm}
onError={handleError}
onError={handleCohortAdminError}
widgets={{}}
showErrorList={false}
customFields={customFields}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ function Logout() {
const userLogout = async () => {
try {
await logout();
} catch (error) {
console.log(error);
}
} catch (error) {}
};
userLogout();
if (typeof window !== "undefined" && window.localStorage) {
Expand Down
16 changes: 12 additions & 4 deletions src/pages/tenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,11 @@ const Tenant: React.FC = () => {
showToastMessage(t(""), "error");
return;
}
const formatName = (names: any) => {
return names?.trim().replace(/\s+/g, " ");
};
let cohortDetails = {
name: formData?.name.replace(/\s/g, ""),
name: formatName(formData?.name),
domain: formData?.domain,
// customFields: customFields,
};
Expand Down Expand Up @@ -683,9 +686,11 @@ const Tenant: React.FC = () => {
try {
setLoading(true);
setConfirmButtonDisable(true);

const formatName = (names: any) => {
return names?.trim().replace(/\s+/g, " ");
};
let obj = {
name: formData?.name.replace(/\s/g, ""),
name: formatName(formData?.name),
cohortId: selectedRowData?.cohortId,
tenantId: selectedRowData?.tenantId,
status: formData?.status,
Expand Down Expand Up @@ -734,9 +739,12 @@ const Tenant: React.FC = () => {
const tenantAdminRole = response?.result.find(
(item: any) => item.code === "tenant_admin"
);
const formatName = (names: any) => {
return names?.trim().replace(/\s+/g, " ");
};

let obj = {
name: formData?.name.replace(/\s/g, ""),
name: formatName(formData?.name),
username: formData?.username.replace(/\s/g, ""),
password: formData?.password,
mobile: formData?.mobileNo,
Expand Down

0 comments on commit 5fbdeea

Please sign in to comment.