Skip to content

Commit

Permalink
HLM-5342: Inbox Search Composer enhacement for MultiTab
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelmd-eGov committed Mar 19, 2024
1 parent 49ca169 commit 220229b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@
@extend .light-text-color-primary;
height: fit-content;
}
&.tab{
display: block;
background-color: #eee;
box-shadow: none;
.search-wrapper{
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.16);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,20 +530,28 @@
}

.search-tabs-container {
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
margin-bottom: 35px;
display: flex;
justify-content: space-between;
background-color: #eee;

.search-tab-head {
padding: 10px 35px;
font-weight: 700;
font-size: 1rem;
border: 1px solid #d6d5d4;
border-radius: 0.5rem 0.5rem 0 0;
}

.search-tab-head-selected {
padding: 10px 35px;
color: rgb(244, 119, 56);
background-color: #fff;
border: 1px solid #f47738;
border-radius: 0.5rem 0.5rem 0 0;
border-bottom: 4px solid rgb(244, 119, 56);
font-weight: bold;
font-weight: 700;
font-size: 1.125rem;
margin-bottom: -1rem;
}

.search-tab-head-selected:focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import SubmitBar from "../atoms/SubmitBar";
import Toast from "../atoms/Toast";
import { FilterIcon, RefreshIcon } from "./svgindex";

const SearchComponent = ({ uiConfig, header = "", screenType = "search", fullConfig, data }) => {
const SearchComponent = ({ uiConfig, header = "", screenType = "search", fullConfig, data, showTab, tabData, onTabChange }) => {
const { t } = useTranslation();
const { state, dispatch } = useContext(InboxContext)
const [showToast, setShowToast] = useState(null)
let updatedFields = [];
const { apiDetails } = fullConfig
const customDefaultPagination = fullConfig?.sections?.searchResult?.uiConfig?.customDefaultPagination || null

if (fullConfig?.postProcessResult) {
//conditions can be added while calling postprocess function to pass different params
Expand Down Expand Up @@ -119,6 +120,21 @@ const SearchComponent = ({ uiConfig, header = "", screenType = "search", fullCon

return (
<React.Fragment>
{showTab && <div className="search-tabs-container">
<div>
{tabData?.map((i,num) => (
<button
className={i?.active === true ? "search-tab-head-selected" : "search-tab-head"}
onClick={() => {
clearSearch({});
onTabChange(num);
}}>
{t(i?.label)}
</button>
))}
</div>
</div>
}
<div className={'search-wrapper'}>
{header && renderHeader()}
<form onSubmit={handleSubmit(onSubmit)} onKeyDown={(e) => checkKeyDown(e)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const Table = ({
tableSelectionHandler = () => {},
onClickRow= ()=>{},
rowClassName = "",
noColumnBorder=false
noColumnBorder=false,
customPageSizesArray = null
}) => {
const {
getTableProps,
Expand Down Expand Up @@ -227,11 +228,17 @@ const Table = ({
style={{ marginRight: "15px" }}
onChange={manualPagination ? onPageSizeChange : (e) => setPageSize(Number(e.target.value))}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
{customPageSizesArray ?
customPageSizesArray.map((pageSize) => (
<option key={pageSize} value={pageSize}>
{pageSize}
</option>
)):
[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
{pageSize}
</option>
))}
))}
</select>
<span>
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ import Header from "../atoms/Header";
import { useTranslation } from "react-i18next";


const InboxSearchComposer = ({configs,headerLabel,additionalConfig,onFormValueChange=()=>{}}) => {
const InboxSearchComposer = ({configs,headerLabel,additionalConfig,onFormValueChange=()=>{},showTab,tabData,onTabChange}) => {
const { t } = useTranslation();

const [enable, setEnable] = useState(false);
const [state, dispatch] = useReducer(reducer, initialInboxState);
const [state, dispatch] = useReducer(reducer, initialInboxState(configs));
const [showToast, setShowToast] = useState(false);
//for mobile view
const [type, setType] = useState("");
const [popup, setPopup] = useState(false);

const apiDetails = configs?.apiDetails
const [apiDetails, setApiDetails] = useState(configs?.apiDetails);

useEffect(()=>{
setApiDetails(configs?.apiDetails)
},[configs])

const mobileSearchSession = Digit.Hooks.useSessionStorage("MOBILE_SEARCH_MODAL_FORM",
{}
Expand Down Expand Up @@ -172,13 +176,16 @@ const InboxSearchComposer = ({configs,headerLabel,additionalConfig,onFormValueCh
}
{
configs?.type === 'search' && configs?.sections?.search?.show &&
<div className="section search">
<div className={`section search ${showTab ? "tab": ""}`}>
<SearchComponent
uiConfig={ configs?.sections?.search?.uiConfig}
header={configs?.sections?.search?.label}
screenType={configs.type}
fullConfig={configs}
data={data}
showTab={showTab}
tabData={tabData}
onTabChange={onTabChange}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
export const initialInboxState = {
searchForm:{

},
filterForm:{

},
tableForm:{
export const initialInboxState = (config) => {
if (config?.sections?.searchResult?.uiConfig?.customDefaultPagination) {
return {
searchForm: {},
filterForm: {},
tableForm: {
...config?.sections?.searchResult?.uiConfig?.customDefaultPagination,
},
};
}
return {
searchForm: {},
filterForm: {},
tableForm: {
limit: 10,
offset: 0,
}
};
},
};
};

const reducer = (state, action) => {
switch (action.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ResultsTable = ({ tableContainerClass, config,data,isLoading,isFetching,fu
}
})
}, [config, searchResult])

const defaultValuesFromSession = config?.customDefaultPagination ? config?.customDefaultPagination : {limit:10,offset:0}
const {
register,
handleSubmit,
Expand All @@ -92,10 +92,7 @@ const ResultsTable = ({ tableContainerClass, config,data,isLoading,isFetching,fu
clearErrors,
unregister,
} = useForm({
defaultValues: {
offset: 0,
limit: 10,
},
defaultValues: defaultValuesFromSession
});

const isMobile = window.Digit.Utils.browser.isMobile();
Expand Down Expand Up @@ -125,8 +122,8 @@ const ResultsTable = ({ tableContainerClass, config,data,isLoading,isFetching,fu
}, []);

useEffect(() => {
register("offset", 0);
register("limit", 10);
register("offset", config?.customDefaultPagination?.offset || 0);
register("limit", config?.customDefaultPagination?.limit || 10);
}, [register]);

useEffect(() => {
Expand Down Expand Up @@ -210,6 +207,7 @@ const ResultsTable = ({ tableContainerClass, config,data,isLoading,isFetching,fu
onClickRow={additionalConfig?.resultsTable?.onClickRow}
rowClassName={config.rowClassName}
noColumnBorder={config?.noColumnBorder}
customPageSizesArray={config?.customPageSizesArray || null}
/>}
</div>
)
Expand Down

0 comments on commit 220229b

Please sign in to comment.