Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application Management Updated #1359

Merged
merged 24 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion micro-ui/web/micro-ui-internals/example/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ module.exports = function (app) {
"/project-factory",
"/project-factory/v1/data/_autoGenerateBoundaryCode",
"/billing-service/bill/v2/_fetchbill",
"/tenant-management"
"/tenant-management",
"/default-data-handler"
].forEach((location) => app.use(location, createProxy));
["/pb-egov-assets"].forEach((location) => app.use(location, assetsProxy));
["/mdms-v2/v2/_create"].forEach((location) => app.use(location, mdmsProxy));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
align-self: flex-start;
margin-bottom: 3rem;
font-size: 14px;
margin-top: -2.5rem;
margin-top: -0.5rem;
color: #505a5f;
font-family: "Roboto";
}
Expand Down Expand Up @@ -240,7 +240,7 @@
margin-top: 0.5rem;
}
.sandbox-url-footer {
margin-top: -1.5rem;
margin-top: 0.5rem;
}
.digit-button-primary {
width: 100%;
Expand All @@ -254,3 +254,64 @@
color: #00703c !important;
}
}
.sandbox-url-wrapper {
display: flex;
width: 100%;
.digit-text-input-field.urlInputText {
}
.digit-button-secondary.large.copyButton {
width: 30%;
padding: 0;
}
}

.setupMasterSetupActionBar {
margin-top: 2.5rem;
margin-bottom: -1rem;
margin-left: -1rem;
margin-right: -1rem;
z-index: 1000;
box-shadow: 0 -0.063rem 0.125rem 0 rgba(0, 0, 0, 0.14902);
padding: 1.5rem;
display: flex;
flex-direction: row-reverse;
}
.digit-employee-card.sandboxSetupMasterInfo {
.h1.headerFlex {
display: flex;
gap: 1rem;
align-items: center;
}
.digit-card-header.subHeader {
font-size: 1.5rem;
font-weight: 700;
color: unset !important;
}
}
.digit-card-header.setupMaster-subheading {
font-size: 1.5rem;
color: unset !important;
margin-left: 1.5rem;
}
.digit-popup-wrapper.masterHandlerPopup {
.digit-popup-header {
.header-close-container {
.digit-popup-close {
display: none !important;
}
}
}
}
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
.digit-topbar-ulb {
.state {
width: 80px;
height: 19px;
}
}
.digit-popup-footer.masterHandlerPopUpFooter {
.digit-popup-footer-buttons {
margin-left: unset;
width: 100%;
justify-content: center;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useStore = ({ stateCode, moduleCode, language ,modulePrefix = "rain
export const useInitStore = (stateCode, enabledModules,modulePrefix = "rainmaker" ) => {
const { isLoading, error, isError, data } = useQuery(
["initStore", stateCode, enabledModules,modulePrefix],
() => StoreService.digitInitData(stateCode, enabledModules ,modulePrefix),
() => StoreService.digitInitData(stateCode, enabledModules ,modulePrefix, window?.globalPath === "sandbox-ui" ? true : false),
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use this flag MULTI_ROOT_TENANT ,
introduce a util function to interact with Globalconfig
that util function to be called everywhere

var multiRootTenant = true;
@NabeelAyubee

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

{
staleTime: Infinity,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mdmsV1Path = window?.globalConfigs?.getConfig("MDMS_V1_CONTEXT_PATH") || "
const mdmsV2Path = window?.globalConfigs?.getConfig("MDMS_V2_CONTEXT_PATH") || "mdms-v2";
const Urls = {
MDMS: `/${mdmsV1Path}/v1/_search`,
TenantConfigSearch: `/tenant-management/tenant/config/_search`,
WorkFlow: `/egov-workflow-v2/egov-wf/businessservice/_search`,
WorkFlowProcessSearch: `/egov-workflow-v2/egov-wf/process/_search`,
localization: `/localization/messages/v1/_search`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ServiceRequest } from "../atoms/Utils/Request";
import Urls from "../atoms/urls";

export const TenantConfigSearch = {
tenant: (stateCode) =>
ServiceRequest({
serviceName: "tenantConfigSearch",
url: Urls.TenantConfigSearch,
data: {},
useCache: true,
params: { code: stateCode },
}),
};
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LocalizationService } from "../../elements/Localization/service";
import { MdmsService } from "../../elements/MDMS";
import { Storage } from "../../atoms/Utils/Storage";
import { ApiCacheService } from "../../atoms/ApiCacheService";
import { TenantConfigSearch } from "../../elements/TenantConfigService";

const getImgUrl = (url, fallbackUrl) => {
if (!url && fallbackUrl) {
Expand Down Expand Up @@ -30,7 +31,7 @@ const addLogo = (id, url, fallbackUrl = "") => {

const renderTenantLogos = (stateInfo, tenants) => {
addLogo(stateInfo.code, stateInfo.logoUrl);
tenants.forEach((tenant) => {
tenants?.forEach((tenant) => {
addLogo(tenant.code, tenant.logoId, stateInfo.logoUrl);
});
};
Expand All @@ -54,21 +55,25 @@ export const StoreService = {
});
return await Promise.all(allBoundries);
},
digitInitData: async (stateCode, enabledModules , modulePrefix) => {
digitInitData: async (stateCode, enabledModules, modulePrefix, tenantConfigFetch) => {
const { MdmsRes } = await MdmsService.init(stateCode);
const stateInfo = MdmsRes["common-masters"]?.StateInfo?.[0]||{};
const uiHomePage = MdmsRes["common-masters"]?.uiHomePage?.[0]||{};
const stateInfo = MdmsRes["common-masters"]?.StateInfo?.[0] || {};
const uiHomePage = MdmsRes["common-masters"]?.uiHomePage?.[0] || {};
const tenantConfigs = await TenantConfigSearch.tenant(stateCode);
const tenantConfigSearch = tenantConfigs?.tenantConfigs ? tenantConfigs?.tenantConfigs : null;
const localities = {};
const revenue_localities = {};
const initData = {
languages: stateInfo.hasLocalisation ? stateInfo.languages : [{ label: "ENGLISH", value: Digit.Utils.getDefaultLanguage() }],
stateInfo: {
code: stateInfo.code,
name: stateInfo.name,
logoUrl: stateInfo.logoUrl,
statelogo: stateInfo.statelogo,
logoUrlWhite: stateInfo.logoUrlWhite,
bannerUrl: stateInfo.bannerUrl,
code: tenantConfigFetch ? tenantConfigSearch?.[0]?.code : stateInfo.code,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put these contents inside a function, which gets triggered only during
MULTI_ROOT_TENANT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

name: tenantConfigFetch ? tenantConfigSearch?.[0]?.name : stateInfo.name,
logoUrl: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "logoUrl")?.url : stateInfo.logoUrl,
statelogo: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "statelogo")?.url : stateInfo.statelogo,
logoUrlWhite: tenantConfigFetch
? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "logoUrlWhite")?.url
: stateInfo.logoUrlWhite,
bannerUrl: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "bannerUrl")?.url : stateInfo.bannerUrl,
},
localizationModules: stateInfo.localizationModules,
modules: MdmsRes?.tenant?.citymodule?.filter((module) => module?.active)?.filter((module) => enabledModules?.includes(module?.code))?.sort((x,y)=>x?.order-y?.order)|| [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const componentsToRegister = {
ChangeCity,
ChangeLanguage,
PrivacyComponent,
OtpComponent
OtpComponent,
};

export const initCoreComponents = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const Redircter = () => {
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { error: null, errorStack: null, hasError: false };
this.state = { error: null, errorStack: null, hasError: false, module: null, action: null, info: null };
}

static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { error: error?.message, hasError: true, errorStack: error?.stack };
return { error: error?.message, hasError: true, errorStack: error?.stack, module: error?.module, action: error?.action, info: error?.info };
}

componentDidCatch(error, errorInfo) {
Expand All @@ -40,7 +40,7 @@ class ErrorBoundary extends React.Component {
return (
<div className="error-boundary">
<Redircter />
<ErrorComponent initData={this.props.initData} />
<ErrorComponent initData={this.props.initData} errorData={this.state} />

{/* <summary>Something went wrong</summary>
<details style={{ whiteSpace: "pre-wrap" }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ const ErrorConfig = {
},
};

const ModuleBasedErrorConfig = {
sandbox: {
imgUrl: `https://s3.ap-south-1.amazonaws.com/egov-qa-assets/error-image.png`,
infoMessage: "WRONG_TENANT_SIGN_UP",
buttonInfo: "CREATE_TENANT_ERROR_BUTTON",
},
};

const ErrorComponent = (props) => {
const { type = "error" } = Digit.Hooks.useQueryParams();
const config = ErrorConfig[type];
const module = props?.errorData?.module;
const { t } = useTranslation();

const config = module ? ModuleBasedErrorConfig[module] : ErrorConfig[type];
const stateInfo = props.stateInfo;

return (
Expand All @@ -33,7 +41,7 @@ const ErrorComponent = (props) => {
<h1>{t(config.infoMessage)}</h1>
<button
onClick={() => {
props.goToHome();
module ? props?.errorData?.action() : props.goToHome();
}}
>
{t(config.buttonInfo)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useQuery } from "react-query";

const tenantConfigSearchService = async ({ tenantId, filter, pagination }) => {
const response = await Digit.CustomService.getResponse({
url: "/tenant-management/tenant/config/_search",
body: {},
params: {
code: tenantId,
},
});
return response?.tenantConfigs;
};
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved

export const useTenantConfigSearch = ({ tenantId, filter, pagination, config = {} }) => {
return useQuery(["SEARCH_TENANT_CONFIG", tenantId, filter, pagination], () => tenantConfigSearchService({ tenantId, filter, pagination }), config);
};
Comment on lines +14 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the useTenantConfigSearch hook.

The hook correctly utilizes useQuery from react-query to fetch data asynchronously. Here are some points to consider:

  • Parameter Handling: The hook destructures its parameters and passes them along to the service function. However, as noted earlier, filter and pagination are not used in the service function.
  • Config Flexibility: The hook allows for a config parameter to customize the useQuery behavior, which is a good practice for flexibility.

Ensure that all parameters passed to the service function are actually used or remove them if unnecessary. This will clean up the interface and avoid confusion about the function's capabilities.

-export const useTenantConfigSearch = ({ tenantId, filter, pagination, config = {} }) => {
+export const useTenantConfigSearch = ({ tenantId, config = {} }) => {
  return useQuery(["SEARCH_TENANT_CONFIG", tenantId], () => tenantConfigSearchService({ tenantId }), config);
};
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const useTenantConfigSearch = ({ tenantId, filter, pagination, config = {} }) => {
return useQuery(["SEARCH_TENANT_CONFIG", tenantId, filter, pagination], () => tenantConfigSearchService({ tenantId, filter, pagination }), config);
};
export const useTenantConfigSearch = ({ tenantId, config = {} }) => {
return useQuery(["SEARCH_TENANT_CONFIG", tenantId], () => tenantConfigSearchService({ tenantId }), config);
};

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const SignUpConfig = [
name: "accountName",
validation: {
required: true,
patter: /^[A-Za-z][A-Za-z-' ]*[A-Za-z]$/,
pattern: /^[A-Za-z]+( [A-Za-z]+)*$/,
},
error: "ERR_ACCOUNT_NAME_REQUIRED",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { BackLink, Button, Card, CardHeader, CardText, FieldV1, SVG } from "@egovernments/digit-ui-components";
import React, { useRef } from "react";
import { BackLink, Button, Card, CardHeader, CardLabel, CardText, FieldV1, SVG, TextInput } from "@egovernments/digit-ui-components";
import { useTranslation } from "react-i18next";
import { useRouteMatch, useHistory, useLocation } from "react-router-dom";
import Background from "../../../components/Background";
Expand All @@ -10,13 +10,19 @@ const ViewUrl = () => {
const location = useLocation();
const { tenant } = location.state || {};
const history = useHistory();
const ref = useRef(null);

const onButtonClick = () => {
window.location.href = `/${window?.globalPath}/${tenant}/employee`;
// history.push({
// pathname: `/${window?.globalPath}/${tenant}/employee`,
// });
};

const handleCopyUrl = () => {
navigator.clipboard.writeText(ref.current.value);
};

return (
<Background>
<div className="employeeBackbuttonAlign">
Expand All @@ -31,7 +37,7 @@ const ViewUrl = () => {
{t("SANDBOX_HEADER")}
</CardHeader>
<CardText className="cardText-sandbox">{t("SAMDBOX_URL_SUB")}</CardText>
<FieldV1
{/* <FieldV1
className="field-sandbox"
withoutLabel={false}
label={t("SANDBOX_URL")}
Expand All @@ -40,7 +46,18 @@ const ViewUrl = () => {
value={`${window.location.host}/${window?.globalPath}/${tenant}`}
placeholder={t("SANDBOX_URL_PLACEHOLDER")}
populators={{}}
/>
/> */}
<CardLabel> {t("SANDBOX_URL")} </CardLabel>
<div className="sandbox-url-wrapper">
<TextInput
inputRef={ref}
className={"urlInputText"}
onChange={() => {}}
nonEditable={true}
value={`${window.location.host}/${window?.globalPath}/${tenant}`}
/>
<Button className="copyButton" variation={"secondary"} onClick={() => handleCopyUrl()} label={t("COPY_URL")}></Button>
</div>
<div className="sandbox-url-footer">{t("SANDBOX_URL_FOOT")}</div>
<Button onClick={onButtonClick} label={t("SIGN_IN")}></Button>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const UICustomizations = {
preProcess: (data, additionalDetails) => {
const tenantId = Digit.ULBService.getCurrentTenantId();
data.params = {
tenantId: tenantId
tenantId: tenantId,
};
data.body = { RequestInfo: data.body.RequestInfo };
data.body.MdmsCriteria = {
Expand All @@ -200,7 +200,7 @@ export const UICustomizations = {
const temp = data?.MdmsRes?.["sandbox-ui"]?.ModuleMasterConfig?.find((item) => item?.module === additionalDetails?.moduleName);
return {
module: temp?.module,
master: temp?.master?.filter((item) => item.type === "module" || item.type === "common"),
master: temp?.master?.filter((item) => item.type === "module" || item.type === "common" || item.type === "boundary"),
};
};

Expand Down Expand Up @@ -235,19 +235,28 @@ export const UICustomizations = {
return value;

case "SANDBOX_ACTIONS":
const handleRedirect = (value) => {
window.history.pushState(
null,
"",
`/${window.contextPath}/employee/workbench/mdms-search-v2?moduleName=${value?.split(".")?.[0]}&masterName=${value?.split(".")?.[1]}`
);
const navEvent = new PopStateEvent("popstate");
window.dispatchEvent(navEvent);
const handleRedirect = (value, type) => {
if (type === "boundary") {
window.history.pushState(
null,
"",
`/${window.contextPath}/employee/workbench/upload-boundary?hierarchyType=${value}&from=sandbox`
);
const navEvent = new PopStateEvent("popstate");
window.dispatchEvent(navEvent);
} else {
window.history.pushState(
null,
"",
`/${window.contextPath}/employee/workbench/mdms-search-v2?moduleName=${value?.split(".")?.[0]}&masterName=${value?.split(".")?.[1]}`
);
const navEvent = new PopStateEvent("popstate");
window.dispatchEvent(navEvent);
}
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
};

return (
<div>
<SVG.Edit style={{ cursor: "pointer" }} onClick={() => handleRedirect(row?.code)} />
<SVG.Edit style={{ cursor: "pointer" }} onClick={() => handleRedirect(row?.code, row?.type)} />
</div>
);
default:
Expand Down
Loading