/**
* Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { TestableComponentInterface } from "@thiva/core/models";
import { LocalStorageUtils } from "@thiva/core/utils";
import { GenericIcon, Heading, PrimaryButton, Text } from "@thiva/react-components";
import React, { FunctionComponent, ReactElement, Suspense, useEffect, useState } from "react";
import Tour, { ReactourStep } from "reactour";
import { AppConstants } from "@thiva/admin.core.v1/constants";
import { history } from "@thiva/admin.core.v1/helpers";
import {
ReactComponent as AsgardioTourWelcomeIllustration
} from "../../assets/illustrations/asgardio-tour-welcome-illustration.svg";
import {
ReactComponent as AsgardioMiniLogo
} from "../../assets/mini-asgardio-logo.svg";
const MiniLogo = () => (
);
const steps: ReactourStep[] = [ {
content: () => {
return (
<>
Hello!
Securing your applications and its users takes just a few minutes with Asgardeo.
We'll handle the hassle of authentication & access management,
so you can focus on your business.
>
);
},
position: "center",
selector: "[data-tut=\"tour-get-started-step\"]"
} ];
/**
* Proptypes for the tour page component.
*/
type TourPageInterface = TestableComponentInterface;
const WELCOME_TOUR_SHOWN_LOCALSTORAGE_KEY: string = "is_welcome_tour_shown";
/**
* Console app tour page.
*
* @param props - Props injected to the component.
*
* @returns the console app tour page.
*/
const TourPage: FunctionComponent = (
props: TourPageInterface
): ReactElement => {
const {
[ "data-testid" ]: testId
} = props;
const [ isTourOpen, setIsTourOpen ] = useState(true);
const [ , setCurrentStep ] = useState(undefined);
const [ welcomeTourDoneState, setWelcomeTourDoneState ] = useState(false);
const getWelcomeTourState = () => {
return JSON.parse(LocalStorageUtils.getValueFromLocalStorage(WELCOME_TOUR_SHOWN_LOCALSTORAGE_KEY)) || "";
};
useEffect(() => {
if (getWelcomeTourState()) {
history.push(AppConstants.getDeveloperViewHomePath());
}
}, [ welcomeTourDoneState ]);
const skipTour = (): void => {
setWelcomeTourDoneState(true);
LocalStorageUtils.setValueInLocalStorage(WELCOME_TOUR_SHOWN_LOCALSTORAGE_KEY, "true");
};
const handleGetStartedFlow = (): void => {
skipTour();
history.push(AppConstants.getDeveloperViewHomePath());
};
return (
> }>
{
setIsTourOpen(false);
handleGetStartedFlow();
} }
closeWithMask = { false }
nextButton={
Next
}
lastStepNextButton={
Get Started
}
prevButton={ <>> }
getCurrentStep={ (step: number) => setCurrentStep(step) }
/>
);
};
/**
* Default props for the component.
*/
TourPage.defaultProps = {
"data-testid": "tour-page"
};
/**
* A default export was added to support React.lazy.
* TODO: Change this to a named export once react starts supporting named exports for code splitting.
* @see {@link https://reactjs.org/docs/code-splitting.html#reactlazy}
*/
export default TourPage;