Skip to content

Commit

Permalink
updated hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulg1254 committed Aug 12, 2024
1 parent 2833e5a commit f7a718a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/pages/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const Block: React.FC = () => {
const districts = data?.result?.values || [];
setDistrictData(districts);
setInitialDistrict(districts[0].value);
const districtFieldID = data?.result?.fieldId || "";
setDistrictFieldId(districtFieldID);
} catch (error) {
console.error("Error fetching districts", error);
} finally {
Expand All @@ -151,13 +153,20 @@ const Block: React.FC = () => {
const response = await getBlocksForDistricts({
limit: limit,
offset: offset,
controllingfieldfk: DistrictId,
controllingfieldfk: selectedDistrict,
fieldName: "blocks",
sort: sortBy,
});

console.log("block response", response);
setBlockData(response?.result?.values || []);
setBlocksFieldId(response?.result?.fieldId || "");

const blockFieldID = response?.result?.fieldId || "";

console.log("blockFieldID", blockFieldID);
setBlocksFieldId(blockFieldID);

console.log("new blockFeldId", blocksFieldId);

setPaginationCount(response?.result?.totalCount || 0);

Expand Down Expand Up @@ -278,10 +287,14 @@ const Block: React.FC = () => {
},
};

console.log("reqParams block", reqParams);

const response = await getCohortList(reqParams);
console.log("getCohortData", response);

const cohortDetails = response?.results?.cohortDetails;
console.log("cohort detail at block", cohortDetails);

if (cohortDetails && cohortDetails.length > 0) {
cohortDetails.forEach(
(cohort: { customFields: any; cohortId: any; status: any }) => {
Expand Down Expand Up @@ -427,7 +440,7 @@ const Block: React.FC = () => {
parentId: cohortId, //cohortId of district
customFields: [
{
fieldId: blocksFieldId, // district fieldId
fieldId: districtFieldId, // district fieldId
value: [selectedDistrict], // district code
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/pages/district.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ const District: React.FC = () => {
name: name,
type: "DISTRICT",
status: cohortStatus,
parentId: cohortId,
parentId: cohortId, //cohortId of state
customFields: [
{
fieldId: stateFieldId, // state fieldId
Expand Down

0 comments on commit f7a718a

Please sign in to comment.