Skip to content

Commit

Permalink
fixed the pop up button issue (#1215)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya-egov committed Aug 12, 2024
1 parent e92bbf0 commit e96df0c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const TimelineComponent = ({campaignId, resourceId}) => {
const searchParams = new URLSearchParams(location.search);
const [userCredential, setUserCredential] = useState(null);
const [newResourceId, setNewResourceId] = useState(resourceId);
const [searchDATA, setSearchDATA] = useState(null);
const [dataFetched, setDataFetched] = useState(false);
const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeOut" }]);

const formatLabel = (label) => {
Expand Down Expand Up @@ -91,32 +93,49 @@ const TimelineComponent = ({campaignId, resourceId}) => {
return latestProcess;
}, null);

const reqCriteriaSearch = {
url: `/project-factory/v1/project-type/search`,
body: {
CampaignDetails: {
tenantId: tenantId,
ids: [campaignId],
},
},
config: {
enabled: resourceId.length == 0 && lastCompletedProcess?.type === "campaign-creation" && lastCompletedProcess?.status === "completed",
},
};

const { data: searchDATA } = Digit.Hooks.useCustomAPIHook(reqCriteriaSearch);
const searchAPIData = async (campaignId, resourceId) => {
try {
const response = await Digit.CustomService.getResponse({
url: "/project-factory/v1/project-type/search",
body: {
CampaignDetails: {
tenantId: tenantId,
ids: [campaignId],
},
},
});
return response;
} catch (error) {
throw new Error(error?.response?.data?.Errors?.[0].description);
}
};

useEffect(() => {
if (resourceId.length === 0 && lastCompletedProcess?.type === "campaign-creation" && lastCompletedProcess?.status === "completed" && !dataFetched ) {
const fetchData = async () => {
try {
const data = await searchAPIData(campaignId);
setSearchDATA(data);
setDataFetched(true)
} catch (error) {
console.error("Error fetching data:", error);
}
};

fetchData();
}
}, [campaignId, newResourceId, lastCompletedProcess , dataFetched]);

useEffect(() => {
if (searchDATA) {
const userResource = searchDATA?.CampaignDetails?.[0]?.resources?.find(resource => resource.type === "user");
const userResource = searchDATA?.CampaignDetails?.[0]?.resources?.find((resource) => resource.type === "user");
if (userResource) {
setNewResourceId([userResource?.createResourceId]);
}
}
}, [searchDATA]);




useEffect(() => {
let intervalId;

Expand Down Expand Up @@ -211,16 +230,8 @@ const TimelineComponent = ({campaignId, resourceId}) => {
variant="inprogress"
showConnector={true}
/> */}
{subElements.length > 0 ? (
<Timeline label={t("HCM_CURRENT")} subElements={subElements} variant="inprogress" showConnector={true} />
) : (
<Timeline
label={t(formatLabel(lastCompletedProcess?.type))}
subElements={[epochToDateTime(lastCompletedProcess?.lastModifiedTime)]}
variant="completed"
showConnector={true}
/>
)}
{subElements.length > 0 && <Timeline label={t("HCM_CURRENT")} subElements={subElements} variant="inprogress" showConnector={true} />}

{completedTimelines?.map((timeline, index) => (
<Timeline key={index} label={timeline?.label} subElements={timeline?.subElements} variant="completed" showConnector={true} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ export const UICustomizations = {
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
const [timeLine, setTimeline] = React.useState(false);
const resourceIdArr = [];
row?.resources?.map((i) => {
if (i?.createResourceId && i?.type === "user") {
resourceIdArr.push(i?.createResourceId);
}
});
// const { t } = useTranslation();
const onActionSelect = (value, row) => {
switch (value?.code) {
Expand Down Expand Up @@ -168,7 +174,10 @@ export const UICustomizations = {
onOverlayClick={() => setTimeline(false)}
onClose={() => setTimeline(false)}
>
<TimelineComponent campaignId={row?.id} resourceId={[row?.resources.find((resource) => resource?.type === "user")?.createResourceId]} />
<TimelineComponent
campaignId={row?.id}
resourceId={resourceIdArr}
/>
</PopUp>
)}
</>
Expand Down Expand Up @@ -251,6 +260,12 @@ export const UICustomizations = {
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
const [timeLine, setTimeline] = React.useState(false);
const resourceIdArr = [];
row?.resources?.map((i) => {
if (i?.createResourceId && i?.type === "user") {
resourceIdArr.push(i?.createResourceId);
}
});
const onActionSelect = (value, row) => {
switch (value?.code) {
case "ACTION_LABEL_VIEW_TIMELINE":
Expand Down Expand Up @@ -296,7 +311,10 @@ export const UICustomizations = {
onOverlayClick={() => setTimeline(false)}
onClose={() => setTimeline(false)}
>
<TimelineComponent campaignId={row?.id} resourceId={[row?.resources.find((resource) => resource?.type === "user")?.createResourceId]} />
<TimelineComponent
campaignId={row?.id}
resourceId={resourceIdArr}
/>
</PopUp>
)}
</>
Expand Down Expand Up @@ -381,6 +399,12 @@ export const UICustomizations = {
additionalCustomizations: (row, key, column, value, t, searchResult) => {
const [timeLine, setTimeline] = React.useState(false);
// const { t } = useTranslation();
const resourceIdArr = [];
row?.resources?.map((i) => {
if (i?.createResourceId && i?.type === "user") {
resourceIdArr.push(i?.createResourceId);
}
});
const onActionSelect = (value, row) => {
switch (value?.code) {
case "ACTION_LABEL_UPDATE_DATES":
Expand Down Expand Up @@ -443,7 +467,10 @@ export const UICustomizations = {
onOverlayClick={() => setTimeline(false)}
onClose={() => setTimeline(false)}
>
<TimelineComponent campaignId={row?.id} resourceId={[row?.resources.find((resource) => resource?.type === "user")?.createResourceId]} />
<TimelineComponent
campaignId={row?.id}
resourceId={resourceIdArr}
/>
</PopUp>
)}
</>
Expand Down Expand Up @@ -616,6 +643,12 @@ export const UICustomizations = {
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
const [timeLine, setTimeline] = React.useState(false);
const resourceIdArr = [];
row?.resources?.map((i) => {
if (i?.createResourceId && i?.type === "user") {
resourceIdArr.push(i?.createResourceId);
}
});
const onActionSelect = (value, row) => {
switch (value?.code) {
case "ACTION_LABEL_VIEW_TIMELINE":
Expand Down Expand Up @@ -661,7 +694,10 @@ export const UICustomizations = {
onOverlayClick={() => setTimeline(false)}
onClose={() => setTimeline(false)}
>
<TimelineComponent campaignId={row?.id} resourceId={[row?.resources.find((resource) => resource?.type === "user")?.createResourceId]} />
<TimelineComponent
campaignId={row?.id}
resourceId={resourceIdArr}
/>
</PopUp>
)}
</>
Expand Down

0 comments on commit e96df0c

Please sign in to comment.