Skip to content

Commit

Permalink
Merge pull request #264 from AkshataKatwal16/prod-fix-issue
Browse files Browse the repository at this point in the history
Issue feat: fix production issues
  • Loading branch information
itsvick authored Oct 15, 2024
2 parents 45c12e5 + 1e78a38 commit eeb8ca2
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 67 deletions.
81 changes: 44 additions & 37 deletions src/pages/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,19 @@ const Block: React.FC = () => {
sort: sortBy,
};

const response = await queryClient.fetchQuery({
queryKey: [
QueryKeys.FIELD_OPTION_READ,
reqParams.limit,
reqParams.offset,
searchKeyword || "",
CohortTypes.DISTRICT,
reqParams.sort.join(","),
],
queryFn: () => getCohortList(reqParams),
});

// const response = await queryClient.fetchQuery({
// queryKey: [
// QueryKeys.FIELD_OPTION_READ,
// reqParams.limit,
// reqParams.offset,
// searchKeyword || "",
// CohortTypes.DISTRICT,
// reqParams.sort.join(","),
// ],
// queryFn: () => getCohortList(reqParams),
// });

const response= await getCohortList(reqParams)
const cohortDetails = response?.results?.cohortDetails || [];

const filteredDistrictData = cohortDetails
Expand Down Expand Up @@ -277,19 +278,24 @@ const Block: React.FC = () => {

const fetchBlocks = async () => {
try {
const response = await queryClient.fetchQuery({
queryKey: [
QueryKeys.FIELD_OPTION_READ,
// const response = await queryClient.fetchQuery({
// queryKey: [
// QueryKeys.FIELD_OPTION_READ,
// selectedDistrict === t("COMMON.ALL") ? "" : selectedDistrict,
// "blocks",
// ],
// queryFn: () =>
// getBlocksForDistricts({
// controllingfieldfk:
// selectedDistrict === t("COMMON.ALL") ? "" : selectedDistrict,
// fieldName: "blocks",
// }),
// });
const response = await getBlocksForDistricts({
controllingfieldfk:
selectedDistrict === t("COMMON.ALL") ? "" : selectedDistrict,
"blocks",
],
queryFn: () =>
getBlocksForDistricts({
controllingfieldfk:
selectedDistrict === t("COMMON.ALL") ? "" : selectedDistrict,
fieldName: "blocks",
}),
});
fieldName: "blocks",
})
const blocks = response?.result?.values || [];
setBlocksOptionRead(blocks);

Expand Down Expand Up @@ -335,19 +341,20 @@ const Block: React.FC = () => {
sort: sortBy,
};

const response = await queryClient.fetchQuery({
queryKey: [
QueryKeys.FIELD_OPTION_READ,
reqParams.limit,
reqParams.offset,
searchKeyword || "",
stateCode,
reqParams.filters.districts,
CohortTypes.BLOCK,
reqParams.sort.join(","),
],
queryFn: () => getCohortList(reqParams),
});
// const response = await queryClient.fetchQuery({
// queryKey: [
// QueryKeys.FIELD_OPTION_READ,
// reqParams.limit,
// reqParams.offset,
// searchKeyword || "",
// stateCode,
// reqParams.filters.districts,
// CohortTypes.BLOCK,
// reqParams.sort.join(","),
// ],
// queryFn: () => getCohortList(reqParams),
// });
const response = await getCohortList(reqParams)

const cohortDetails = response?.results?.cohortDetails || [];
const filteredBlockData = cohortDetails
Expand Down
51 changes: 27 additions & 24 deletions src/pages/district.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,20 @@ const District: React.FC = () => {
sort: sortBy,
};

const response = await queryClient.fetchQuery({
queryKey: [
QueryKeys.FIELD_OPTION_READ,
reqParams.limit,
reqParams.offset,
searchKeyword || "",
stateCode,
CohortTypes.DISTRICT,
reqParams.sort.join(","),
],
queryFn: () => getCohortList(reqParams),
});
// const response = await queryClient.fetchQuery({
// queryKey: [
// QueryKeys.FIELD_OPTION_READ,
// reqParams.limit,
// reqParams.offset,
// searchKeyword || "",
// stateCode,
// CohortTypes.DISTRICT,
// reqParams.sort.join(","),
// ],
// queryFn: () => getCohortList(reqParams),
// });

const response = await getCohortList(reqParams)

const cohortDetails = response?.results?.cohortDetails || [];

Expand Down Expand Up @@ -302,18 +304,19 @@ const District: React.FC = () => {
},
sort: sortBy,
};
const response = await queryClient.fetchQuery({
queryKey: [
QueryKeys.FIELD_OPTION_READ,
reqParams.limit,
reqParams.offset,
reqParams.filters.districts || "",
CohortTypes.BLOCK,
reqParams.sort.join(","),
],
queryFn: () => getCohortList(reqParams),
});

// const response = await queryClient.fetchQuery({
// queryKey: [
// QueryKeys.FIELD_OPTION_READ,
// reqParams.limit,
// reqParams.offset,
// reqParams.filters.districts || "",
// CohortTypes.BLOCK,
// reqParams.sort.join(","),
// ],
// queryFn: () => getCohortList(reqParams),
// });

const response= await getCohortList(reqParams)
const activeBlocks = response?.results?.cohortDetails || [];

const activeBlocksCount = activeBlocks.filter(
Expand Down
30 changes: 24 additions & 6 deletions src/pages/logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,32 @@ function Logout() {
}
};
userLogout();
localStorage.removeItem("token");
localStorage.removeItem("userId");
localStorage.removeItem("name");
localStorage.removeItem("tenantId");
localStorage.removeItem("adminInfo");

if (typeof window !== "undefined" && window.localStorage) {
// Specify the keys you want to keep
const keysToKeep = [
"preferredLanguage",
"mui-mode",
"mui-color-scheme-dark",
"mui-color-scheme-light",
"hasSeenTutorial",
];
// Retrieve the values of the keys to keep
const valuesToKeep: { [key: string]: any } = {};
keysToKeep.forEach((key: string) => {
valuesToKeep[key] = localStorage.getItem(key);
});

// Clear all local storage
localStorage.clear();

// Re-add the keys to keep with their values
keysToKeep.forEach((key: string) => {
if (valuesToKeep[key] !== null) {
// Check if the key exists and has a value
localStorage.setItem(key, valuesToKeep[key]);
}
});
}
router.replace("/login");
}, []);

Expand Down

0 comments on commit eeb8ca2

Please sign in to comment.