Skip to content

Commit

Permalink
Merge pull request #149 from upendraTekdi/admin_uk
Browse files Browse the repository at this point in the history
 Task #223738: update button on delete model, add word break css for name handle condition if No districts available and no blocks available on drop down
  • Loading branch information
itsvick authored Aug 22, 2024
2 parents 8e606d6 + 353a5ce commit c1ddfaa
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 76 deletions.
6 changes: 4 additions & 2 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@
"BLOCK_UPDATED_FAILURE": "Unable to update block",
"ADD": "Add",
"INACTIVE": "Inactive",
"DISTRICT":"District",
"BLOCK":"Block",
"DISTRICT": "District",
"BLOCK": "Block",
"SELECT_STATE": "Select State",
"SELECT_DISTRICT": "Select District",
"SOMETHING_WENT_WRONG": "Something went wrong",
"BLOCK_NAME_REQUIRED": "Block Name is Required",
"BLOCK_CODE_REQUIRED": "Code is Required",
"INVALID_INPUT": "Invalid Input",
"ALL_DISTRICTS": "All Districts",
"NO_DISTRICTS": "No Districts",
"ALL_STATES": "All States",
"LOGOUT": "Log out",
"HI": "Hi",
"MOBILE": "Mobile",
"ALL_BLOCKS": "All Blocks",
"NO_BLOCKS": "No Blocks",

"SEND_CREDENTIALS": "Send Credentials",
"CREDENTIALS_EMAILED_OF_FACILITATOR": "The login credentials will be emailed to the Facilitator at {{email}} ",
Expand Down
41 changes: 26 additions & 15 deletions src/components/AreaSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ interface DropdownBoxProps {
selectedDistrict: string[];
selectedBlock: string[];
selectedCenter?: any;
inModal?:boolean
inModal?: boolean;
handleStateChangeWrapper: (
selectedNames: string[],
selectedCodes: string[],
selectedCodes: string[]
) => Promise<void>;
handleDistrictChangeWrapper: (
selected: string[],
selectedCodes: string[],
selectedCodes: string[]
) => Promise<void>;
handleBlockChangeWrapper: (
selected: string[],
selectedCodes: string[],
selectedCodes: string[]
) => void;
handleCenterChangeWrapper?: (
selected: string[],
selectedCodes: string[],
selectedCodes: string[]
) => void;

isMobile: boolean;
Expand All @@ -73,7 +73,7 @@ const AreaSelection: React.FC<DropdownBoxProps> = ({
isMobile,
isMediumScreen,
isCenterSelection = false,
inModal=false,
inModal = false,
handleCenterChangeWrapper = () => {},
stateDefaultValue,
userType
Expand Down Expand Up @@ -136,27 +136,31 @@ theme.breakpoints.down("sm"),
names={states?.map(
(state) =>
state.label?.toLowerCase().charAt(0).toUpperCase() +
state.label?.toLowerCase().slice(1),
state.label?.toLowerCase().slice(1)
)}
codes={states?.map((state) => state.value)}
tagName={t("FACILITATORS.STATE")}
selectedCategories={selectedState}
onCategoryChange={handleStateChangeWrapper}
disabled={stateDefaultValue=== t("COMMON.ALL_STATES")? false: true}
disabled={
stateDefaultValue === t("COMMON.ALL_STATES") ? false : true
}
overall={!inModal}
defaultValue={ stateDefaultValue}

defaultValue={stateDefaultValue}
/>
<MultipleSelectCheckmarks
names={districts?.map((districts) => districts.label)}
codes={districts?.map((districts) => districts.value)}
tagName={t("FACILITATORS.DISTRICT")}
selectedCategories={selectedDistrict}
onCategoryChange={handleDistrictChangeWrapper}
disabled={selectedState.length===0 && stateDefaultValue=== t("COMMON.ALL_STATES")}
disabled={
districts?.length <= 0 ||
(selectedState.length === 0 &&
stateDefaultValue === t("COMMON.ALL_STATES"))
}
overall={!inModal}
defaultValue={t("COMMON.ALL_DISTRICTS")}

defaultValue={districts?.length <= 0 ? t("COMMON.NO_DISTRICTS"):t("COMMON.ALL_DISTRICTS")}
/>
<MultipleSelectCheckmarks
names={blocks?.map((blocks) => blocks.label)}
Expand All @@ -165,10 +169,17 @@ theme.breakpoints.down("sm"),
selectedCategories={selectedBlock}
onCategoryChange={handleBlockChangeWrapper}
disabled={
selectedDistrict?.length === 0 || (selectedDistrict && selectedDistrict[0] === "" || selectedDistrict[0] === t("COMMON.ALL_DISTRICTS"))
blocks?.length <= 0 ||
selectedDistrict?.length === 0 ||
(selectedDistrict && selectedDistrict[0] === "") ||
selectedDistrict[0] === t("COMMON.ALL_DISTRICTS")
}
overall={!inModal}
defaultValue={t("COMMON.ALL_BLOCKS")}
defaultValue={
blocks?.length <= 0
? t("COMMON.NO_BLOCKS")
: t("COMMON.ALL_BLOCKS")
}
/>
{ isCenterSelection && ( <MultipleSelectCheckmarks
names={capitalizeFirstLetterOfEachWordInArray(allCenters?.map((centers) => centers.name))}
Expand Down
10 changes: 5 additions & 5 deletions src/components/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ const ConfirmationModal: React.FC<ConfirmationModalProps> = ({
p: 2,
}}
>


<Button
sx={{
border: "none",
color: "secondary",
fontSize: "14px",
fontWeight: "500",
"&:hover": {
border: "none",
backgroundColor: "transparent",
},
width: "auto",
height: "40px",
marginLeft: "10px",
}}
variant="outlined"
onClick={handleCloseModal}
Expand Down
75 changes: 22 additions & 53 deletions src/pages/centers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const Center: React.FC = () => {
const [selectedSort, setSelectedSort] = useState("Sort");
const [selectedFilter, setSelectedFilter] = useState("Active");
const [cohortData, setCohortData] = useState<cohortFilterDetails[]>([]);
const [pageSize, setPageSize] = React.useState<string | number>("10");
const [pageSize, setPageSize] = React.useState<string | number>(10);
const [confirmationModalOpen, setConfirmationModalOpen] =
React.useState<boolean>(false);
const [selectedCohortId, setSelectedCohortId] = React.useState<string>("");
Expand Down Expand Up @@ -144,7 +144,7 @@ const Center: React.FC = () => {
const isMobile = useMediaQuery((theme: Theme) =>
theme.breakpoints.down("sm")
);

const getAdminInformation = () => {
if (typeof window !== "undefined" && window.localStorage) {
const admin = localStorage.getItem("adminInfo");
Expand All @@ -159,12 +159,19 @@ const Center: React.FC = () => {
label: stateField.value,
},
];

setStatesInformation(object);
console.log("object", object[0]?.value);
setSelectedStateCode(object[0]?.value);

setFilters({
type: "COHORT",
states: object[0]?.value,
status: filters.status,
});
}
}
};


// use api calls
useEffect(() => {
Expand All @@ -175,15 +182,15 @@ const Center: React.FC = () => {

// get form data for center create
getAddCenterFormData();
getAdminInformation();
// getCohortMemberlistData();
getAdminInformation();
}, []);

const fetchUserList = async () => {
setLoading(true);
try {
const limit = pageLimit;
const offset = filters?.name ? 0 : pageOffset * limit;
const offset = pageOffset * limit;
const sort = sortBy;

const data = {
Expand Down Expand Up @@ -325,9 +332,10 @@ const Center: React.FC = () => {
};

useEffect(() => {

fetchUserList();
getFormData();
}, [pageOffset, pageLimit, sortBy, filters]);
}, [pageOffset, pageLimit, sortBy, filters, filters.states, filters.status]);

// handle functions
const handleChange = (event: SelectChangeEvent<typeof pageSize>) => {
Expand Down Expand Up @@ -503,13 +511,19 @@ const Center: React.FC = () => {
};

const handleSearch = (keyword: string) => {
setPageOffset(Numbers.ZERO);
setPageCount(Numbers.ONE);
setFilters((prevFilters) => ({
...prevFilters,
name: keyword,
}));
};

const handleFilterChange = async (event: SelectChangeEvent) => {
setPageSize(Numbers.TEN);
setPageLimit(Numbers.TEN);
setPageOffset(Numbers.ZERO);
setPageCount(Numbers.ONE);
setSelectedFilter(event.target.value);

if (event.target.value === Status.ACTIVE_LABEL) {
Expand Down Expand Up @@ -738,32 +752,7 @@ const Center: React.FC = () => {
fetchData();
}, []);

// const fetchUserDetail = async () => {
// let userId;
// try {
// if (typeof window !== "undefined" && window.localStorage) {
// userId = localStorage.getItem(Storage.USER_ID);
// }
// const fieldValue = true;
// if (userId) {
// console.log("true");
// const response = await getUserDetailsInfo(userId, fieldValue);

// const userInfo = response?.userData;
// //set user info in zustand store
// if (typeof window !== 'undefined' && window.localStorage) {
// localStorage.setItem('adminInfo', JSON.stringify(userInfo))
// }
// setAdminInformation(userInfo);
// }
// } catch (error) {
// console.log(error);
// }
// };

// useEffect(() => {
// fetchUserDetail();
// }, []);


// props to send in header
const userProps = {
Expand All @@ -783,31 +772,11 @@ const Center: React.FC = () => {
handleSearch: handleSearch,
showAddNew: true,
handleAddUserClick: handleAddUserClick,
showSort: cohortData?.length > 0,
};

return (
<>
{/* <CustomModal
open={editModelOpen}
handleClose={onCloseEditMOdel}
title={t("COMMON.EDIT_CENTER_NAME")}
// subtitle={t("COMMON.NAME")}
primaryBtnText={t("COMMON.UPDATE_CENTER")}
secondaryBtnText="Cancel"
// primaryBtnClick={handleUpdateAction}
primaryBtnDisabled={confirmButtonDisable}
secondaryBtnClick={onCloseEditMOdel}
>
<Box>
<TextField
id="standard-basic"
label="Center Name"
variant="standard"
value={inputName}
onChange={handleInputName}
/>
</Box>
</CustomModal> */}
<ConfirmationModal
message={
t("CENTERS.SURE_DELETE_CENTER") +
Expand Down
3 changes: 2 additions & 1 deletion src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
}

.ka-cell {
line-height: 24px;
line-height: 24px !important;
word-wrap: break-word;
}

@media (max-width: 768px) {
Expand Down

0 comments on commit c1ddfaa

Please sign in to comment.