Skip to content

Commit

Permalink
changes in the url
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavya-egov committed Nov 15, 2024
1 parent c79c4fd commit f076ed0
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const CampaignCard = () => {
}

const { t } = useTranslation();
const userId = Digit.UserService.getUser().info.uuid;
const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED"

let links = [

Expand All @@ -36,9 +38,9 @@ const CampaignCard = () => {
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
{ //@Bhavya put the new url and remove the comment
{
label: t("ACTION_TEST_SETUP_CAMPAIGN_FROM_MICROPLAN"),
link: `/${window?.contextPath}/employee/campaign/setup-campaign`,
link: `/${window?.contextPath}/employee/campaign/setup-microplan&userId=${userId}&status=${microplanStatus}`,
roles: ROLES.CAMPAIGN_MANAGER
},
{
Expand All @@ -58,13 +60,7 @@ const CampaignCard = () => {
link: `/${window?.contextPath}/employee/campaign/boundary/home`,
roles: ROLES.BOUNDARY_MANAGER,
// count: isLoading?"-":data
},
{
label: t("MICROPLAN_CAMPAIGN"),
link: `/${window?.contextPath}/employee/campaign/my-microplan`,
roles: ROLES.CAMPAIGN_MANAGER,
// count: isLoading?"-":data
},
}
];

links = links.filter((link) => (link?.roles && link?.roles?.length > 0 ? Digit.Utils.didEmployeeHasAtleastOneRole(link?.roles) : true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ import { ErrorMessage, FieldV1 , Stepper , TextBlock ,Card } from "@egovernments

const CampaignName = ({ onSelect, formData, control, formState, ...props }) => {
const { t } = useTranslation();
const [name, setName] = useState(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName || "");

const [executionCount, setExecutionCount] = useState(0);
const [startValidation, setStartValidation] = useState(null);
const [error, setError] = useState(null);
const searchParams = new URLSearchParams(location.search);
const microplanName = searchParams.get("microName");
const source = searchParams.get("source");
const [name, setName] = useState(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName || "");
useEffect(() => {
setName(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName);
if(source === "microplan"){
const sessionName = props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName.replace(/&/g, "and");
if(sessionName === microplanName){
setName("");
}
}
else setName(props?.props?.sessionData?.HCM_CAMPAIGN_NAME?.campaignName);
}, [props?.props?.sessionData?.HCM_CAMPAIGN_NAME]);
const searchParams = new URLSearchParams(location.search);

const [currentStep , setCurrentStep] = useState(1);
const currentKey = searchParams.get("key");
const [key, setKey] = useState(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
const searchParams = new URLSearchParams(location.search);
const [currentStep , setCurrentStep] = useState(1);
const currentKey = searchParams.get("key");
const productType = searchParams.get("type");
const source = searchParams.get("source");
const [key, setKey] = useState(() => {
const keyParam = searchParams.get("key");
return keyParam ? parseInt(keyParam) : 1;
Expand Down Expand Up @@ -144,7 +144,7 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
setStartValidation(true);
handleChange(value);
}}
disabled = {productType === "microplan"}
disabled = {source === "microplan"}

/>
{error?.message && <ErrorMessage message={t(error?.message)} showIcon={true} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export const UICustomizations = {
history.push(`/${window.contextPath}/employee/campaign/checklist/create?campaignName=${campaignName}&role=${role_code}&checklistType=${cl_code}&projectType=${projectType}&campaignId=${campaignId}`)
}}
/>
)
}
);
}
default:
return value;
}
Expand Down Expand Up @@ -305,18 +305,15 @@ export const UICustomizations = {
},
MicroplanCampaignSearchConfig: {
preProcess: (data, additionalDetails) => {
const { name, status } = data?.state?.searchForm || {};
data.body.PlanConfigurationSearchCriteria = {};
data.body.PlanConfigurationSearchCriteria.limit = data?.state?.tableForm?.limit;
// data.body.PlanConfigurationSearchCriteria.limit = 10
data.body.PlanConfigurationSearchCriteria.offset = data?.state?.tableForm?.offset;
data.body.PlanConfigurationSearchCriteria.name = name;
data.body.PlanConfigurationSearchCriteria.tenantId = Digit.ULBService.getCurrentTenantId();
data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid;
// delete data.body.PlanConfigurationSearchCriteria.pagination
data.body.PlanConfigurationSearchCriteria.status = status?.status;
const url = window.location.pathname;
const queryString = url.includes("?") ? url.split("?")[1] : url.split("&").slice(1).join("&");
const searchParams = new URLSearchParams(queryString);
const userId = searchParams.get("userId");
const status = searchParams.get("status");
data.body.PlanConfigurationSearchCriteria.userUuid = userId;
data.body.PlanConfigurationSearchCriteria.status = [status];
data.body.PlanConfigurationSearchCriteria.name = data?.state?.searchForm?.microplanName;
data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code;
// data.body.PlanConfigurationSearchCriteria.campaignType = data?.state?.searchForm?.campaignType?.[0]?.code;
return data;
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
Expand All @@ -326,10 +323,10 @@ export const UICustomizations = {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
maxWidth: "15rem",
wordWrap: "break-word",
whiteSpace: "normal",
overflowWrap: "break-word",
}}
>
<p>{t(value)}</p>
Expand All @@ -345,7 +342,7 @@ export const UICustomizations = {

case "CAMPAIGN_TYPE":
if (value && value != "NA") {
return <p>{t(Digit.Utils.locale.getTransformedLocale("MICROPLAN_TYPE_" + value))}</p>;
return <p>{t(Digit.Utils.locale.getTransformedLocale("CAMPAIGN_TYPE_" + value))}</p>;
} else {
return (
<div>
Expand Down Expand Up @@ -452,7 +449,6 @@ export const UICustomizations = {
setTimeline(true);
break;
case "ACTION_LABEL_CONFIGURE_APP":

window.history.pushState(
{
name: row?.campaignName,
Expand Down Expand Up @@ -770,7 +766,6 @@ export const UICustomizations = {
setTimeline(true);
break;


case "ACTION_LABEL_UPDATE_BOUNDARY_DETAILS":
window.history.pushState(
{
Expand All @@ -790,7 +785,7 @@ export const UICustomizations = {
name: row?.campaignName,
data: row,
projectId: row?.projectId,
campaignType: row?.projectType
campaignType: row?.projectType,
},
"",
`/${window.contextPath}/employee/campaign/checklist/search?name=${row?.campaignName}&campaignId=${row?.id}&projectType=${row?.projectType}`
Expand Down Expand Up @@ -1032,8 +1027,8 @@ export const UICustomizations = {
setTimeline(true);
break;
case "ACTION_LABEL_RETRY":
retryCampaign(row,searchResult);
break;
retryCampaign(row, searchResult);
break;
default:
console.log(value);
break;
Expand Down Expand Up @@ -1062,7 +1057,10 @@ export const UICustomizations = {
type="actionButton"
variation="secondary"
label={"Action"}
options={[{ key: 1, code: "ACTION_LABEL_VIEW_TIMELINE", i18nKey: t("ACTION_LABEL_VIEW_TIMELINE") },{ key: 2, code: "ACTION_LABEL_RETRY", i18nKey: t("ACTION_LABEL_RETRY") }].filter(obj=>Digit.Utils.didEmployeeHasAtleastOneRole(["SYSTEM_ADMINISTRATOR"]||obj?.key!=2))} //added retry for system adminstrator for failed campaign
options={[
{ key: 1, code: "ACTION_LABEL_VIEW_TIMELINE", i18nKey: t("ACTION_LABEL_VIEW_TIMELINE") },
{ key: 2, code: "ACTION_LABEL_RETRY", i18nKey: t("ACTION_LABEL_RETRY") },
].filter((obj) => Digit.Utils.didEmployeeHasAtleastOneRole(["SYSTEM_ADMINISTRATOR"] || obj?.key != 2))} //added retry for system adminstrator for failed campaign
optionsKey="i18nKey"
showBottom={true}
isSearchable={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
requestParam: {
},
requestBody: {
"PlanConfigurationSearchCriteria": {
"PlanConfigurationSearchCriteria": {
"limit": 10,
"offset": 0,
"tenantId": "mz",
"userUuid": "ff4ca65b-de7a-48de-ab9d-23c7728dc1aa"
"tenantId": tenantId,
},
},
masterName: "commonUiConfig",
Expand All @@ -38,31 +37,31 @@
},
fields: [
{
label: "Name of the microplan",
label: "NAME_OF_MICROPLAN",
isMandatory: false,
key: "microplanName",
type: "text",
populators: {
name: "microplanName"
},
},
{
label: "CAMPAIGN_SEARCH_TYPE",
type: "apidropdown",
isMandatory: false,
disable: false,
populators: {
optionsCustomStyle: {
top: "2.3rem",
},
name: "campaignType",
optionsKey: "code",
allowMultiSelect: false,
masterName: "commonUiConfig",
moduleName: "MyCampaignConfigDrafts",
customfn: "populateCampaignTypeReqCriteria",
},
},
// {
// label: "CAMPAIGN_SEARCH_TYPE",
// type: "apidropdown",
// isMandatory: false,
// disable: false,
// populators: {
// optionsCustomStyle: {
// top: "2.3rem",
// },
// name: "campaignType",
// optionsKey: "code",
// allowMultiSelect: false,
// masterName: "commonUiConfig",
// moduleName: "MyCampaignConfigDrafts",
// customfn: "populateCampaignTypeReqCriteria",
// },
// },
],
},

Expand All @@ -78,7 +77,7 @@
},
{
label:"CAMPAIGN_TYPE",
jsonPath:"campaignDetails.projectType",
jsonPath:"additionalDetails.campaignType",
additionalCustomization:true
},
{
Expand All @@ -90,14 +89,11 @@
resultsJsonPath: "PlanConfiguration",

enableColumnSort: true,
// resultsJsonPath: "mdms",
},
show: true,
},
// customHookName: "microplanv1.useSavedMicroplans",

},
customHookName:"microplanv1.useSavedMicroplans"
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,19 @@ import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { MicroplanCampaignSearchConfig } from "../../configs/myMicroplanConfig";



const defaultSearchValues = {

};

const MyMicroplans = () => {
const { t } = useTranslation();
const [defaultValues, setDefaultValues] = useState(defaultSearchValues); // State to hold default values for search fields
const history = useHistory();
useEffect(() => {
// Set default values when component mounts
setDefaultValues(defaultSearchValues);
}, []);

const onTabChange = (n) => {

setTabData((prev) => prev.map((i, c) => ({ ...i, active: c === n ? true : false }))); //setting tab enable which is being clicked
// setConfig(TabSearchconfig?.TabSearchconfig?.[n]);// as per tab number filtering the config
const url = new URL(window.location.href);
url.searchParams.set("tabId", `${n}`);
window.history.replaceState({}, "", url);

};
const onClickRow = ({ original: row }) => {
history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&type=microplan`);
console.log("row" , row);
const updatedName = row.name.replace(/&/g, "and");
history.push(`/${window.contextPath}/employee/campaign/setup-campaign?id=${row.campaignId}&draft=true&fetchBoundary=true&draftBoundary=true&source=microplan&microName=${updatedName}`);
};
return (
<React.Fragment>

<Header styles={{ fontSize: "32px" }}>{t("MY_MICROPLANS_HEADING")}</Header>
<div className="inbox-search-wrapper">
{/* Pass defaultValues as props to InboxSearchComposer */}
<InboxSearchComposer
configs={MicroplanCampaignSearchConfig?.[0]}
additionalConfig={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => {
const isDateRestricted = searchParams.get("date");
const isChangeDates = searchParams.get("changeDates");
const actionBar = searchParams.get("actionBar");
const type = searchParams.get("type");
const source = searchParams.get("source");
const microplanName = searchParams.get("microName");
const [isDraftCreated, setIsDraftCreated] = useState(false);
const [currentKey, setCurrentKey] = useState(() => {
const keyParam = searchParams.get("key");
Expand Down Expand Up @@ -113,8 +114,10 @@ const SetupCampaign = ({ hierarchyType, hierarchyData }) => {
setIsDraftCreated(true);
if (isSkip === "false") {
if (currentKey === 1) setCurrentKey(1);
} else if (type === "microplan") {
//if user comes from set up microplan
} else if (source === "microplan") {
setCurrentKey(2);
//if the campaign is in draft and the start date is passed
}else if (isDateRestricted === "true") {
setCurrentKey(3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const CampaignBreadCrumb = ({ location, defaultPath }) => {
*/
const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => {
const location = useLocation();
const userId = Digit.UserService.getUser().info.uuid;
const microplanStatus = "RESOURCE_ESTIMATIONS_APPROVED"
const UploadBoundaryData = Digit?.ComponentRegistryService?.getComponent("UploadBoundaryData");
const CycleConfiguration = Digit?.ComponentRegistryService?.getComponent("CycleConfiguration");
const DeliveryRule = Digit?.ComponentRegistryService?.getComponent("DeliveryRule");
Expand Down Expand Up @@ -149,7 +151,7 @@ const App = ({ path, BOUNDARY_HIERARCHY_TYPE, hierarchyData }) => {
<PrivateRoute path={`${path}/boundary/view-all-hierarchy`} component={()=> <ViewBoundary />} />
<PrivateRoute path={`${path}/boundary/data`} component={()=> <ViewHierarchy />} />
<PrivateRoute path={`${path}/update-campaign`} component={() => <UpdateCampaign />} />
<PrivateRoute path={`${path}/my-microplan`} component={() => <MyMicroplans />} />
<PrivateRoute path={`${path}/setup-microplan&userId=${userId}&status=${microplanStatus}`} component={() => <MyMicroplans />} />
</AppContainer>
</Switch>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export const handleValidate = ({formData,t,setShowToast,hierarchyDefinition,low
if (typeof formData?.campaignName !== "string" || !formData?.campaignName.trim()) {
setShowToast({ key: "error", label: "CAMPAIGN_NAME_MISSING_TYPE_ERROR" });
return false;
} else if (formData.campaignName.length > 250) {
setShowToast({ key: "error", label: "CAMPAIGN_NAME_TOO_LONG_ERROR" });
} else if (formData.campaignName.length > 30) {
setShowToast({ key: "error", label: "CAMPAIGN_NAME_LONG_ERROR" });
return false;
} else {
setShowToast(null);
Expand Down

0 comments on commit f076ed0

Please sign in to comment.