Skip to content

Commit

Permalink
Merge pull request #88 from AkshataKatwal16/admin
Browse files Browse the repository at this point in the history
Issue feat: add gender validation
  • Loading branch information
itsvick authored Aug 2, 2024
2 parents f2a4c7b + 5077a46 commit 4d4ace2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 39 deletions.
18 changes: 14 additions & 4 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ const UserTable: React.FC<UserTableProps> = ({
const [selectedUserId, setSelectedUserId] = useState("");
const [selectedReason, setSelectedReason] = useState("");
const [otherReason, setOtherReason] = useState("");
// const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'));
const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('md'));
const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'));
// const isMobile = useMediaQuery("(max-width:600px)");


const [confirmButtonDisable, setConfirmButtonDisable] = useState(false);
Expand Down Expand Up @@ -316,6 +316,7 @@ const handleCloseAddTeamLeaderModal = () => {
);

const getValue = (data: any, field: any) => {
console.log(data, field)
if (item.default) {
return item.default;
}
Expand All @@ -333,7 +334,16 @@ const handleCloseAddTeamLeaderModal = () => {
return parseInt(String(field?.value));
} else if (item?.type === "text") {
return String(field?.value);
} else {
}

else {
console.log("asakas",field?.value)
if(field.value ==='FEMALE' || field.value ==='MALE')
{
console.log(true)
return field?.value?.toLowerCase();
}
// console.log()
return field?.value;
}
}
Expand Down Expand Up @@ -595,7 +605,7 @@ const handleCloseAddTeamLeaderModal = () => {
<Loader showBackdrop={true} loadingText={t("COMMON.LOADING")} />
) : data.length !== 0 && loading === false ? (
<KaTableComponent
columns= {role==="Team Leader" ? getTLTableColumns(t): getUserTableColumns(t, isMobile)}
columns= {role==="Team Leader" ? getTLTableColumns(t, isMobile): getUserTableColumns(t, isMobile)}
data={data}
limit={pageLimit}
offset={pageOffset}
Expand Down
32 changes: 17 additions & 15 deletions src/data/tableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,42 @@ export const getUserTableColumns = (t: any, isMobile: any) => {
title: t("FORM.NAME"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
width: isMobile?160:null,
width:isMobile?160:null,

},
{
key: "status",
title: t("FORM.STATUS"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
width: isMobile?160:null,
width:isMobile?160:null,
},


{
key: "age",
title: t("FORM.AGE"),
dataType: DataType.String,
width: isMobile?160:null,
width:isMobile?160:null,
},
{
key: "gender",
title: t("FORM.GENDER"),
dataType: DataType.String,
width: isMobile?160:null,
width:isMobile?160:null,
},
{
key: "mobile",
title: t("FORM.MOBILE_NUMBER"),
dataType: DataType.String,
width: isMobile?160:null,
width:isMobile?160:null,
},
{
key: "state",
title: t("FORM.STATE"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
width: isMobile?160:null,
width:isMobile?160:null,
},
{
key: "district",
Expand All @@ -58,7 +58,7 @@ export const getUserTableColumns = (t: any, isMobile: any) => {
title: t("FORM.BLOCK"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
width: isMobile?160:null,
width:isMobile?160:null,
},
{
key: "centers",
Expand All @@ -77,65 +77,67 @@ export const getUserTableColumns = (t: any, isMobile: any) => {
}


export const getTLTableColumns = (t: any) => {
export const getTLTableColumns = (t: any, isMobile:any) => {
return[

{
key: "name",
title: t("FORM.NAME"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
// width: isMobile?160:null,

},
{
key: "status",
title: t("FORM.STATUS"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
//width: isMobile?160:null,
// width: isMobile?160:null,
},


{
key: "age",
title: t("FORM.AGE"),
dataType: DataType.String,
// width: 160,
// width: isMobile?160:null,
},
{
key: "gender",
title: t("FORM.GENDER"),
dataType: DataType.String,
// width: 160,
// width: isMobile?160:null,
},

{
key: "state",
title: t("FORM.STATE"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
// width: 160,
// width: isMobile?160:null,
},
{
key: "district",
title:t("FORM.DISTRICT"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
// width: 160,
// width: isMobile?160:null,
},

{
key: "blocks",
title: t("FORM.BLOCK"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
// width: 160,
// width: isMobile?160:null,
},

{
key: "actions",
title: t("FORM.ACTION"),
dataType: DataType.String,
// width: 160,
// width: isMobile?160:null,
},
];
}
Expand Down
46 changes: 26 additions & 20 deletions src/utils/useLocationState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,35 @@ export const useLocationState = (open: boolean, onClose: () => void) => {
try {
console.log(selectedStateCode, selectedDistrictCode);
const object = {
limit: 200,
offset: 0,
filters: {
type: "BLOCK",
status: ["active"],
// "states": selectedStateCode,
// "districts": selectedDistrictCode,
// "blocks": selectedCodes[0]
name: selected[0],
},
"limit":200,
"offset": 0,
"filters": {
// "type": "COHORT",
"status": [
"active"
],
"states": selectedStateCode,
"districts": selectedDistrictCode,
"blocks": selectedCodes[0]
// name:selected[0]
}
};
const response2 = await getCenterList(object);

console.log(selected);
const getBlockIdObject = {
limit: 200,
offset: 0,
filters: {
type: "BLOCK",
status: ["active"],
name: selected[0],
},
};
console.log(selected)
const getBlockIdObject={
"limit": 200,
"offset": 0, "filters": {
// "type":"COHORT",
"status": [
"active"
],
"states": selectedStateCode,
"districts": selectedDistrictCode,
"blocks": selectedCodes[0]
// "name": selected[0]
},
}
const response = await getCenterList(getBlockIdObject);
setSelectedBlockFieldId(
response?.result?.results?.cohortDetails[0].cohortId
Expand Down

0 comments on commit 4d4ace2

Please sign in to comment.