Skip to content

Commit

Permalink
update pr: resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshataKatwal16 committed Aug 7, 2024
1 parent 6172722 commit bea04ec
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
6 changes: 3 additions & 3 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@
"FIELD_REQUIRED": "{{field}} is required",
"THIS_IS_REQUIRED_FIELD": "This is required field",
"ENTER_ONLY_DIGITS": "Please enter only digits",
"MIN_LENGTH_DIGITS_ERROR": "Minimum {{minLength}} year age required",
"MAX_LENGTH_DIGITS_ERROR": "Maximum till {{maxLength}} year age allowed",
"MIN_LENGTH_CHARACTERS_ERROR": "Minimum {{minLength}} characters required",
"MIN_LENGTH_DIGITS_ERROR": "Minimum {{minLength}} Digits required",
"MAX_LENGTH_DIGITS_ERROR": "Maximum {{maxLength}} Digits allowed",
"MIN_LENGTH_CHARACTERS_ERROR": "Minimum {{minLength}} characters required",
"MAX_LENGTH_CHARACTERS_ERROR": "Maximum {{maxLength}} characters allowed",
"NUMBER_AND_SPECIAL_CHARACTERS_NOT_ALLOWED": "Numbers and special characters are not allowed",
"CHARACTERS_AND_SPECIAL_CHARACTERS_NOT_ALLOWED": "Characters and special characters are not allowed",
Expand Down
4 changes: 2 additions & 2 deletions src/components/CommonUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ const CommonUserModal: React.FC<UserModalProps> = ({
setSubmitButtonEnable(false)

}
if(dynamicForm && userType!=FormContextType.TEAM_LEADER || isEditModal)
if(dynamicForm && userType!==FormContextType.TEAM_LEADER || isEditModal)
{
setSubmitButtonEnable(true)
}
Expand Down Expand Up @@ -495,7 +495,7 @@ const CommonUserModal: React.FC<UserModalProps> = ({
{/* <CustomSubmitButton onClose={primaryActionHandler} /> */}
</DynamicForm>
)
: userType === "TEAM LEADER"
: userType === FormContextType.TEAM_LEADER
? dynamicFormForBlock &&
schema &&
uiSchema && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
new Set(
data[key]
.filter((item: any) => item !== "")
.map((item: any) => (item === "_lifeskills" ? "life_skills" : item))
//.map((item: any) => (item === "_lifeskills" ? "life_skills" : item))
)
);
}
Expand Down
34 changes: 20 additions & 14 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import DeleteUserModal from "@/components/DeleteUserModal";
import HeaderComponent from "@/components/HeaderComponent";
import PageSizeSelector from "@/components/PageSelector";
import { SORT, Status } from "@/utils/app.constant";
import { FormContextType, SORT, Status } from "@/utils/app.constant";
import DeleteIcon from "@mui/icons-material/Delete";
import EditIcon from "@mui/icons-material/Edit";
import Box from "@mui/material/Box";
Expand Down Expand Up @@ -200,13 +200,13 @@ const UserTable: React.FC<UserTableProps> = ({
const handleFilterChange = async (event: SelectChangeEvent) => {
console.log(event.target.value as string);
setSelectedFilter(event.target.value as string);
if (event.target.value === "Active") {
if (event.target.value === Status.ACTIVE_LABEL ) {
console.log(true);
setFilters((prevFilters) => ({
...prevFilters,
status: [Status.ACTIVE],
}));
} else if (event.target.value === "InActive") {
} else if (event.target.value === Status.INACTIVE) {
setFilters((prevFilters) => ({
...prevFilters,
status: [Status.ARCHIVED],
Expand Down Expand Up @@ -506,10 +506,16 @@ const UserTable: React.FC<UserTableProps> = ({
});
if(filters?.name)
{
const prioritizedResult = finalResult
.filter((user:any) => user.name.toLowerCase().startsWith(filters?.name))
.concat(finalResult.filter((user:any) => !user.name.toLowerCase().startsWith(filters?.name)));
setData(prioritizedResult)
const prioritizedResult = finalResult.sort((a: any, b: any) => {
const aStartsWith = a.name.toLowerCase().startsWith(filters?.name);
const bStartsWith = b.name.toLowerCase().startsWith(filters?.name);

if (aStartsWith && !bStartsWith) return -1;
if (!aStartsWith && bStartsWith) return 1;
return 0;
});

setData(prioritizedResult);
}

else{
Expand Down Expand Up @@ -650,7 +656,7 @@ const UserTable: React.FC<UserTableProps> = ({
) : data.length !== 0 && loading === false ? (
<KaTableComponent
columns={
role === "Team Leader"
role === Role.TEAM_LEADER
? getTLTableColumns(t, isMobile)
: getUserTableColumns(t, isMobile)
}
Expand Down Expand Up @@ -682,7 +688,7 @@ const UserTable: React.FC<UserTableProps> = ({

<KaTableComponent
columns={
role === "Team Leader"
role === Role.TEAM_LEADER
? getTLTableColumns(t, isMobile)
: getUserTableColumns(t, isMobile)
}
Expand Down Expand Up @@ -727,11 +733,11 @@ const UserTable: React.FC<UserTableProps> = ({
userId={userId}
onSubmit={handleModalSubmit}
userType={
userType === "Learners"
? "STUDENT"
: userType === "Facilitators"
? "TEACHER"
: "TEAM LEADER"
userType === Role.LEARNERS
? FormContextType.STUDENT
: userType === Role.FACILITATORS
? FormContextType.TEACHER
: FormContextType.TEAM_LEADER
}
/>
</HeaderComponent>
Expand Down
3 changes: 3 additions & 0 deletions src/utils/app.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export enum Role {
TEACHER = "Teacher",
TEAM_LEADER = "Team Leader",
ADMIN = "Admin",
LEARNERS="Learners",
FACILITATORS="Facilitators"
}

export enum Status {
Expand All @@ -11,6 +13,7 @@ export enum Status {
ACTIVE = "active",
ACTIVE_LABEL = "Active",
ALL_LABEL = "All",
INACTIVE="Inactive"
}
export enum SORT {
ASCENDING = "asc",
Expand Down

0 comments on commit bea04ec

Please sign in to comment.