Skip to content
Merged
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
11 changes: 6 additions & 5 deletions ui/src/components/AdvancePropertise/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const AdvancePropertise = (props: SchemaProps) => {
{
...props?.value,
[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: (event.target as HTMLInputElement)?.value,
validationRegex: '',
validationRegex: currentToggleStates?.validationRegex || '',
minChars: currentToggleStates?.minChars,
maxChars:currentToggleStates?.maxChars,
mandatory: currentToggleStates?.mandatory,
Expand All @@ -134,6 +134,7 @@ const AdvancePropertise = (props: SchemaProps) => {
embedObjects: embedObjectslabels,
minRange: currentToggleStates?.minRange,
maxRange: currentToggleStates?.maxRange,
default_value: currentToggleStates?.default_value,
},
checkBoxChanged
);
Expand All @@ -159,7 +160,7 @@ const AdvancePropertise = (props: SchemaProps) => {
props?.rowId,
{
[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: value,
validationRegex: '',
validationRegex: currentToggleStates?.validationRegex || '',
mandatory: currentToggleStates?.mandatory,
multiple: currentToggleStates?.multiple,
unique: false,
Expand All @@ -186,7 +187,7 @@ const AdvancePropertise = (props: SchemaProps) => {
props?.rowId,
{
[field?.charAt(0)?.toUpperCase() + field?.slice(1)]: value,
validationRegex: '',
validationRegex: currentToggleStates?.validationRegex || '',
mandatory: currentToggleStates?.mandatory,
multiple: currentToggleStates?.multiple,
unique: false,
Expand Down Expand Up @@ -237,7 +238,7 @@ const AdvancePropertise = (props: SchemaProps) => {
props?.rowId,
{
['default_value']: option?.key,
validationRegex: '',
validationRegex: currentToggleStates?.validationRegex || '',
mandatory: currentToggleStates?.mandatory,
multiple: currentToggleStates?.multiple,
unique: false,
Expand Down Expand Up @@ -268,7 +269,7 @@ const AdvancePropertise = (props: SchemaProps) => {
props?.rowId,
{
['default_value']: '',
validationRegex: '',
validationRegex: currentToggleStates?.validationRegex || '',
mandatory: currentToggleStates?.mandatory,
multiple: currentToggleStates?.multiple,
unique: false,
Expand Down
24 changes: 24 additions & 0 deletions ui/src/hooks/usePreventBackNavigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useEffect } from "react";
import { useLocation, useNavigate } from "react-router";

const usePreventBackNavigation = (): void => {
const navigate = useNavigate();
const location = useLocation();

useEffect(() => {
// push a dummy state to the history stack
window.history.pushState(null, "", window.location.href);

const handlePopState = () => {
navigate(location.pathname, { replace: true });
};

window.addEventListener("popstate", handlePopState);

return () => {
window.removeEventListener("popstate", handlePopState);
};
}, [navigate, location]);
};

export default usePreventBackNavigation;
2 changes: 2 additions & 0 deletions ui/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { CS_ENTRIES } from '../../utilities/constants';
// Interface
import { HomepageType } from './home.interface';
import useBlockNavigation from '../../hooks/userNavigation';
import usePreventBackNavigation from '../../hooks/usePreventBackNavigation';

const Home = () => {
const [data, setData] = useState<HomepageType>({});
useBlockNavigation(true);
usePreventBackNavigation();

const fetchData = async () => {
//check if offline CMS data field is set to true, if then read data from cms data file.
Expand Down
3 changes: 3 additions & 0 deletions ui/src/pages/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { userSession, requestSMSToken } from '../../services/api/login.service';

// Interface
import { IProps, IStates, defaultStates, User, UserRes, LoginType } from './login.interface';
import usePreventBackNavigation from '../../hooks/usePreventBackNavigation';

//Components
import AccountPage from '../../components/AccountPage';
Expand All @@ -41,6 +42,8 @@ import { RootState } from '../../store';
const Login: FC<IProps> = () => {
const [data, setData] = useState<LoginType>({});

usePreventBackNavigation();

// ************* Fetch Login Data ************
const fetchData = async () => {
//check if offline CMS data field is set to true, if then read data from cms data file.
Expand Down
3 changes: 3 additions & 0 deletions ui/src/pages/Projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { validateObject } from '../../utilities/functions';
import { ProjectsType, ProjectsObj } from './projects.interface';
import { ModalObj } from '../../components/Modal/modal.interface';
import { CTA } from '../Home/home.interface';
import usePreventBackNavigation from '../../hooks/usePreventBackNavigation';


// Components
Expand Down Expand Up @@ -59,6 +60,8 @@ const Projects = () => {
const [searchText, setSearchText] = useState(search);
const [isModalOpen, setIsModalOpen] = useState(false);

usePreventBackNavigation();

const fetchProjects = async () => {
setLoadStatus(true);
if (selectedOrganisation?.value) {
Expand Down
5 changes: 4 additions & 1 deletion ui/src/pages/RegionalLogin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CS_ENTRIES } from '../../utilities/constants';

// Interface
import { RegionType } from './regionalLogin.interface';
import usePreventBackNavigation from '../../hooks/usePreventBackNavigation';

// Style
import './index.scss';
Expand All @@ -37,6 +38,8 @@ const RegionalLogin = () => {

const { description, heading, regions } = data;

usePreventBackNavigation();

return (
<div className="d-flex vh-100 justify-content-center flex-column">
<div className="mx-3">
Expand Down Expand Up @@ -76,7 +79,7 @@ const RegionalLogin = () => {
className="body-4 fw-bold stretched-link"
onClick={(e) =>{
e.preventDefault();
navigate(`/login?region=${region?.region}`)}
navigate(`/login?region=${region?.region}`, { replace: true })}
}
>
<span className="link-basic-icon link-arrow">{region?.cta?.title}</span>
Expand Down