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

Tenant config upload #1416

Merged
merged 12 commits into from
Sep 27, 2024
2 changes: 1 addition & 1 deletion micro-ui/web/core/inter-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-react-components": "1.8.1-beta.11",
"@egovernments/digit-ui-react-components": "1.8.1-beta.14",
"@egovernments/digit-ui-components": "0.0.2-beta.31",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@egovernments/digit-ui-module-open-payment":"0.0.1",
"@egovernments/digit-ui-module-hrms": "1.8.1-beta.1",
"@egovernments/digit-ui-module-pgr": "1.8.1-beta.1",
"@egovernments/digit-ui-react-components": "1.8.2-beta.13",
"@egovernments/digit-ui-react-components": "1.8.2-beta.14",
"babel-loader": "8.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@
margin-top: 3rem;
width: 100%;
}

.submit-bar {
margin-top: 3rem;
width: 100%;
}

.bannerHeader {
.bannerLogo {
margin-top: 1rem;
Expand Down Expand Up @@ -173,6 +175,7 @@
margin-right: auto;
width: fit-content;
}

.digit-card-text.sandbox-resend-otp {
margin: 0;
margin-top: -1rem;
Expand Down Expand Up @@ -213,6 +216,7 @@
}
}
}

.digit-card-component.signupCardClassName.sandbox-onboarding-wrapper {
.bannerHeader {
.bannerLogo {
Expand All @@ -221,6 +225,7 @@
}
}
}

.digit-card-component.card-sandbox {
.bannerHeader {
.bannerLogo {
Expand All @@ -237,32 +242,40 @@
height: 2rem;
}
}

.sandbox-success-signup {
margin-top: unset;
}

.digit-field {
margin-top: 0.5rem;
}

.sandbox-url-footer {
margin-top: 0.5rem;
}

.digit-button-primary {
width: 100%;
}
}

.submit-bar {
background-color: #c84c0e;
}

.digit-employee-card.card-sandbox {
.digit-card-header.cardHeader-sandbox {
color: #00703c !important;
}
}

.sandbox-url-wrapper {
display: flex;
width: 100%;
.digit-text-input-field.urlInputText {
}

.digit-text-input-field.urlInputText {}

.digit-button-secondary.large.copyButton {
width: 30%;
padding: 0;
Expand All @@ -280,12 +293,14 @@
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;
Expand All @@ -309,6 +324,7 @@
color: unset !important;
margin-left: 1.5rem;
}

.digit-popup-wrapper.masterHandlerPopup {
.digit-popup-header {
.header-close-container {
Expand All @@ -318,41 +334,48 @@
}
}
}

.digit-topbar-ulb {
.state {
width: 80px;
height: 19px;
}
}

.digit-popup-footer.masterHandlerPopUpFooter {
.digit-popup-footer-buttons {
margin-left: unset;
width: 100%;
justify-content: center;
}
}

.main.center-container.citizen-home-container {
z-index: 100;
justify-content: flex-start;
}

.SideBarStatic {
z-index: 10;
height: 100vh;
}

.citizen-form-wrapper {
justify-content: flex-start;

.citizen-card-input.citizen-card-input--front {
margin-bottom: 0;
}
}

.action-bar-wrap {
.menu-wrap {
p {
margin: 0 !important;
}
}
}

.digit-popup-wrapper.setupMasterPopUp.alert {
.digit-popup-alert-content {
.digit-popup-alert-heading {
Expand Down Expand Up @@ -496,3 +519,12 @@ digit-card-text.center {
position: relative;
z-index: 0;
}
.digit-uploader-content{
.digit-button-secondary.large{
.icon-label-container.secondary.large{
.digit-button-label{
width: fit-content !important;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApiCacheService } from "../../atoms/ApiCacheService";
import { TenantConfigSearch } from "../../elements/TenantConfigService";

const getImgUrl = (url, fallbackUrl) => {

if (!url && fallbackUrl) {
return fallbackUrl;
}
Expand Down Expand Up @@ -101,17 +102,26 @@ export const StoreService = {
const fetchTenantConfig = async () => {
const tenantConfigs = await TenantConfigSearch.tenant(stateCode);
const tenantConfigSearch = tenantConfigs?.tenantConfigs ? tenantConfigs?.tenantConfigs : null;
const logoArray = tenantConfigSearch[0].documents
.filter(doc => doc.type === "logoUrl")
.map(doc => doc.fileStoreId);
const bannerArray = tenantConfigSearch[0].documents
.filter(doc => doc.type === "bannerUrl")
.map(doc => doc.fileStoreId);
const logoUrl = await Digit.UploadServices.Filefetch(logoArray, tenantConfigSearch?.[0]?.code);
const bannerUrl = await Digit.UploadServices.Filefetch(bannerArray, tenantConfigSearch?.[0]?.code)

return {
languages: stateInfo.hasLocalisation ? stateInfo.languages : [{ label: "ENGLISH", value: Digit.Utils.getDefaultLanguage() }],
stateInfo: {
code: tenantConfigFetch ? tenantConfigSearch?.[0]?.code : stateInfo.code,
name: tenantConfigFetch ? tenantConfigSearch?.[0]?.name : stateInfo.name,
logoUrl: tenantConfigFetch ? tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "logoUrl")?.url : stateInfo.logoUrl,
logoUrl: tenantConfigFetch ? logoUrl?.data?.fileStoreIds?.[0]?.url ? logoUrl?.data?.fileStoreIds?.[0]?.url?.split(',')[0] : 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,
bannerUrl: tenantConfigFetch ? bannerUrl?.data?.fileStoreIds?.[0]?.url ? bannerUrl?.data?.fileStoreIds?.[0]?.url?.split(',')[0] : tenantConfigSearch?.[0]?.documents?.find((item) => item.type === "bannerUrl")?.url : stateInfo.bannerUrl,
},
localizationModules: stateInfo.localizationModules,
modules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"prepublish": "yarn build"
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.2-beta.13",
"@egovernments/digit-ui-react-components": "1.8.2-beta.14",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hook-form": "6.15.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"react-router-dom": "5.3.0"
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.2-beta.13",
"@egovernments/digit-ui-react-components": "1.8.2-beta.14",
"lodash.merge": "^4.6.2",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { default as EmployeeApp } from "./pages/employee";
import SandboxCard from "./components/SandboxCard";
import { overrideHooks, updateCustomConfigs } from "./utils";
import ModuleCard from "./components/ModuleCard";
import ConfigUploaderComponent from "./pages/employee/tenantMgmt/ConfigUploaderComponent";
import LogoUploaderComponent from "./pages/employee/tenantMgmt/LogoUploaderComponent";

export const SandboxModule = ({ stateCode, userType, tenants }) => {
const { path, url } = useRouteMatch();
Expand Down Expand Up @@ -33,6 +35,8 @@ const componentsToRegister = {
SandboxCard,
WorkbenchCard: null,
SandboxModuleCard: ModuleCard,
ConfigUploaderComponent,
LogoUploaderComponent
};

export const initSandboxComponents = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ApplicationHome from "./applicationMgmt/ApplicationHome";
import ModuleMasterTable from "./applicationMgmt/ModuleMasterTable";
import TenantUpdate from "./tenantMgmt/TenantUpdate";
import SetupMaster from "./applicationMgmt/SetupMaster";
import TenantConfigUpload from "./tenantMgmt/TenantConfigUpload";

const bredCrumbStyle = { maxWidth: "min-content" };

Expand Down Expand Up @@ -54,6 +55,7 @@ const App = ({ path, stateCode, userType, tenants }) => {
<PrivateRoute path={`${path}/tenant-management/create`} component={() => <TenantCreate />} />
<PrivateRoute path={`${path}/tenant-management/search`} component={() => <TenantView />} />
<PrivateRoute path={`${path}/tenant-management/update`} component={() => <TenantUpdate />} />
<PrivateRoute path={`${path}/tenant-management/config/upload`} component={() => <TenantConfigUpload />} />
<PrivateRoute path={`${path}/application-management/home`} component={() => <ApplicationHome />} />
<PrivateRoute path={`${path}/application-management/module-master`} component={() => <SandboxSearch />} />
<PrivateRoute path={`${path}/application-management/setup-master`} component={() => <SetupMaster />} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React, { useEffect, useState } from "react";
import { CardLabel, LabelFieldPair, Uploader } from "@egovernments/digit-ui-components";
import {Toast} from "@egovernments/digit-ui-react-components";
import { useTranslation } from "react-i18next";
import { Fragment } from "react";

const ConfigUploaderComponent = ({ onSelect, ...props }) => {
const [showToast, setShowToast] = useState(null);
const [toastMessage, setToastMessage] = useState("");
const [isError, setIsError] = useState(false);
const [file, setFile] = useState(null);
const [fileStoreId, setFileStoreId] = useState(null);
const tenantId = Digit.ULBService.getCurrentTenantId();
const { t } = useTranslation();


const handleUploadFile = async () => {
// Upload the file first
try {
const response = await Digit.UploadServices.Filestorage("Sandbox", file, tenantId);
const fileStoreId = response?.data?.files?.[0]?.fileStoreId;
setFileStoreId(fileStoreId)
} catch (error) {
setToastMessage(t("BANNER_UPLOAD_FAILED"));
setIsError(true);
setShowToast(true);
setTimeout(() => {
setShowToast(false);
}, 2000);
}
};


useEffect(() => {
if (fileStoreId) {
onSelect("ConfigUploaderComponent", { "fileStoreId": fileStoreId, "type": props?.config?.customProps?.type })
}
}, [fileStoreId])


const selectFile = (file) => {
setFile(file?.[0])
}

useEffect(() => {
if (file) {
handleUploadFile();
}
}, [file])
return (
<>

<LabelFieldPair className={"uploader-label-field"}>
<CardLabel>{`${t("BANNER_UPLOAD")}`}</CardLabel>
<Uploader
uploadedFiles={[]}
variant="uploadFile"
onUpload={(files) => selectFile(files)}
// if (files && files.length > 0) {
// handleUploadFile(files);
// }
/>
</LabelFieldPair>
{showToast && (
<Toast
error={isError}
label={toastMessage}
onClose={() => setShowToast(false)}
/>
)}
</>
);
};

export default ConfigUploaderComponent;
Loading