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

FEATURE/HCMPRE-1776 : Added preview component basic screen #2102

Open
wants to merge 1 commit into
base: console
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,33 @@
> div:nth-of-type(1) {
width: 69%;
}
}
.date-style{
max-width: 37.5rem;
display: flex;
gap: 1rem;
}
.app-preview{
width: 25rem;
border: 0.000rem solid #ccc;
border-radius: 1rem;
background-color: white;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
margin: 20px auto;
font-family: Arial, sans-serif;
}
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved
.mobile-top {
background-color: theme(digitv2.lightTheme.header-sidenav);
height: 4rem;
display: flex;
align-items: center;
padding: 0 1rem;
color: theme(digitv2.lightTheme.paper);
font-size: 1.5rem;
font-weight: theme(digitv2.fontWeight.bold);
width: 100%;
/* Full width */
box-sizing: border-box;
border-top-left-radius: 1rem;
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved
border-top-right-radius: 1rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import MapView from "./components/MapView";
import NoResultsFound from "./components/NoResultsFound";
import UploadDataMappingWrapper from "./components/UploadDataMappingWrapper";
import DataUploadWrapper from "./components/DataUploadWrapper";
import AppPreview from "./components/AppPreview";

/**
* MDMS Module name
Expand Down Expand Up @@ -175,6 +176,7 @@ const componentsToRegister = {
NoResultsFound,
UploadDataMappingWrapper,
DataUploadWrapper,
AppPreview
};

const overrideHooks = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
import React from "react";
import { Card, Header, CardText, TextInput, SelectionCard, Dropdown } from "@egovernments/digit-ui-components";
import { useTranslation } from "react-i18next";

const data = {
name: "HOUSEHOLD_LOCATION",
cards: [
{
fields: [
{
type: "text",
label: "Address Line 1",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
{
type: "Selection",
label: "Address Line 1",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
{
type: "numeric",
label: "Address Line 1",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
{
type: "dropdown",
label: "Address Line 2",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
{
type: "date",
label: "Address Line 2",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
{
type: "dob",
label: "Address Line 4",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
],
header: "Header",
description: "Desc",
headerFields: [
{
type: "text",
label: "SCREEN_HEADING",
active: true,
jsonPath: "ScreenHeading",
metaData: {},
required: true,
},
{
type: "text",
label: "SCREEN_DESCRIPTION",
active: true,
jsonPath: "Description",
metaData: {},
required: true,
},
],
},
],
order: 1,
config: {
enableComment: true,
enableFieldAddition: true,
allowFieldsAdditionAt: ["body"],
enableSectionAddition: true,
allowCommentsAdditionAt: ["body"],
},
parent: "REGISTRATION",
headers: [
{
type: "header",
label: "KJHSJKDHKJH",
},
{
type: "info",
label: "KJHSJKDHKJH",
},
{
type: "description",
label: "KJHSJKDHKJH",
},
],
};
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved

const DobPicker = ({t}) => {
return (
<div className="dob-picker">
<Card type="secondary">
<div>{t("HCM_DATE_OF_BIRTH")}</div>
<TextInput name="numeric" onChange={() => {}} type={"date"} />
<div>({t("HCM_OR")})</div>
<div>{t("HCM_AGE")}</div>
<div className="date-style">
<TextInput name="numeric" onChange={() => {}} placeholder={t("HCM_YEARS")} disabled={true} />
<TextInput name="numeric" onChange={() => {}} placeholder={t("HCM_MONTHS")} disabled={true}/>
</div>
</Card>
</div>
);
};

const renderField = (field ,t) => {
switch (field.type) {
case "text":
return <TextInput name="name" value={field?.name || ""} onChange={() => {}} disabled={true} />;
case "Selection":
return (
<SelectionCard
errorMessage=""
onSelectionChanged={() => {}}
options={[
{
code: "option1",
name: "Option 1",
prefixIcon: "",
suffixIcon: "",
},
{
code: "option2",
name: "Option 2",
prefixIcon: "",
suffixIcon: "",
},
{
code: "option3",
name: "Option 3",
prefixIcon: "",
suffixIcon: "",
},
]}
selected={[]}
/>
);
case "numeric":
return <TextInput name="numeric" onChange={() => {}} type={"numeric"} />;
case "dropdown":
return (
<Dropdown
option={[
{
code: "option1",
name: "Option 1",
prefixIcon: "",
suffixIcon: "",
},
{
code: "option2",
name: "Option 2",
prefixIcon: "",
suffixIcon: "",
},
{
code: "option3",
name: "Option 3",
prefixIcon: "",
suffixIcon: "",
},
]}
optionKey={"code"}
selected={[]}
select={() => {}}
// disabled={source === "microplan"}
/>
);
case "date":
return <TextInput name="numeric" onChange={() => {}} type={"date"} />;
case "dob":
return <DobPicker t={t} />
default:
return <div style={{ color: "red", marginTop: "5px" }}>Unsupported field type: {field.type}</div>;
}
};
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved

const AppPreview = () => {
const { t } = useTranslation();
return (
<div className="app-preview">
<div className="mobile-top">
<div className="mobile-menu-icon">&#9776;</div>
</div>
{data.cards.map((card, index) => (
<Card key={index}>
{card.headerFields
.filter((headerField) => headerField.active)
.map((headerField, headerIndex) => (
<div key={headerIndex}>
{headerField.jsonPath === "ScreenHeading" ? <Header>{headerField.label}</Header> : <CardText>{headerField.label}</CardText>}
</div>
))}

{card.fields
.filter((field) => field.active)
.map((field, fieldIndex) => (
<div key={fieldIndex} style={{ margin: "10px 0" }}>
<div>
{field.label}
{field.required && " *"}
</div>
{/* Call renderField function to render the specific component */}
{renderField(field , t)}
</div>
))}
</Card>
))}
</div>
);
};
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved



export default AppPreview;
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useState, useMemo, useRef, useEffect, Fragment } from "react";
import { UploadIcon, FileIcon, DeleteIconv2, Toast, Header } from "@egovernments/digit-ui-react-components";
import { UploadIcon, FileIcon, DeleteIconv2, Toast, Header } from "@egovernments/digit-ui-react-components";
import { useTranslation } from "react-i18next";
import { LabelFieldPair } from "@egovernments/digit-ui-components";
import { Button, CardText, Dropdown, ErrorMessage, PopUp, Stepper, TextBlock , Card} from "@egovernments/digit-ui-components";
import { Button, CardText, Dropdown, ErrorMessage, PopUp, Stepper, TextBlock, Card } from "@egovernments/digit-ui-components";
import AppPreview from "./AppPreview";

const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
const { t } = useTranslation();
Expand All @@ -15,9 +16,10 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
const [error, setError] = useState(null);
const [startValidation, setStartValidation] = useState(null);
const [showPopUp, setShowPopUp] = useState(null);
const [showPopUp1, setShowPopUp1] = useState(null);
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved
const [canUpdate, setCanUpdate] = useState(null);
const searchParams = new URLSearchParams(location.search);
const [currentStep , setCurrentStep] = useState(1);
const [currentStep, setCurrentStep] = useState(1);
const currentKey = searchParams.get("key");
const source = searchParams.get("source");
const [key, setKey] = useState(() => {
Expand Down Expand Up @@ -156,7 +158,44 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
<div>{t(`CAMPAIGN_TYPE_${beneficiaryType}`)}</div>
</LabelFieldPair>
)}
{/* <Button
type={"button"}
size={"large"}
variation={"secondary"}
label={t("PREVIEW")}
onClick={() => {
setShowPopUp1(true);
}}
/> */}
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved
</Card>
{showPopUp1 && (
<PopUp
className={"custom-pop-up"}
type={"default"}
heading={t("CHECKLIST_PREVIEW")}
children={[]}
onOverlayClick={() => {
setShowPopUp1(false);
}}
onClose={() => {
setShowPopUp1(false);
}}
footerChildren={[
<Button
type={"button"}
size={"large"}
variation={"primary"}
label={t("CLOSE")}
onClick={() => {
setShowPopUp1(false);
}}
/>,
]}
sortFooterChildren={true}
>
<AppPreview />
</PopUp>
)}
Bhavya-egov marked this conversation as resolved.
Show resolved Hide resolved
</div>
{showPopUp && (
<PopUp
Expand Down Expand Up @@ -203,7 +242,6 @@ const CampaignSelection = ({ onSelect, formData, formState, ...props }) => {
)}
</div>
</>

);
};

Expand Down
Loading