redirect url
This commit is contained in:
@@ -58,3 +58,8 @@ export const removeToken = () => {
|
||||
export const removeRefreshToken = () => {
|
||||
Cookie.remove(import.meta.env.VITE_REFRESH_TOKEN_NAME, { domain, path: "/" });
|
||||
};
|
||||
|
||||
export const getRedirectUrl = () => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
return urlParams.get("redirect");
|
||||
};
|
||||
|
||||
@@ -5,6 +5,8 @@ export enum AdsDisplayLocation {
|
||||
OTHER_SERVICES_TOP = "OTHER_SERVICES_TOP",
|
||||
OTHER_SERVICES_LEFT = "OTHER_SERVICES_LEFT",
|
||||
SERVICE = "SERVICE",
|
||||
BLOG_PAGE_TOP_RIGHT = "BLOG_PAGE_TOP_RIGHT",
|
||||
BLOG_PAGE_BOTTOM_RIGHT = "BLOG_PAGE_BOTTOM_RIGHT",
|
||||
}
|
||||
|
||||
export type AdsItemType = {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { ErrorType } from '../../../helpers/types'
|
||||
import { toast } from 'react-toastify'
|
||||
import { setRefreshToken } from '../../../config/func'
|
||||
import { setToken } from '../../../config/func'
|
||||
|
||||
import { getRedirectUrl } from '../../../config/func'
|
||||
const LoginStep2: FC = () => {
|
||||
|
||||
const { t } = useTranslation('global')
|
||||
@@ -41,6 +41,12 @@ const LoginStep2: FC = () => {
|
||||
onSuccess(data) {
|
||||
setToken(data?.data?.accessToken?.token)
|
||||
setRefreshToken(data?.data?.refreshToken?.token)
|
||||
// Check if there's a redirect parameter in the URL
|
||||
const redirectUrl = getRedirectUrl();
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
return; // Prevent the default navigation
|
||||
}
|
||||
window.location.href = Pages.dashboard
|
||||
},
|
||||
onError(error: ErrorType) {
|
||||
@@ -63,7 +69,6 @@ const LoginStep2: FC = () => {
|
||||
} as CredentialRequestOptions) // اطمینان از تطابق تایپها
|
||||
.then((otpCredential) => {
|
||||
if (otpCredential && "code" in otpCredential) {
|
||||
alert("OTP Received: " + otpCredential.code);
|
||||
formik.setFieldValue("code", (otpCredential).code);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@ import { toast } from 'react-toastify'
|
||||
import { ErrorType } from '../../../helpers/types'
|
||||
import { setRefreshToken } from '../../../config/func'
|
||||
import { setToken } from '../../../config/func'
|
||||
import { getRedirectUrl } from '../../../config/func'
|
||||
|
||||
const LoginStep3: FC = () => {
|
||||
|
||||
@@ -37,6 +38,11 @@ const LoginStep3: FC = () => {
|
||||
onSuccess(data) {
|
||||
setToken(data?.data?.accessToken?.token)
|
||||
setRefreshToken(data?.data?.refreshToken?.token)
|
||||
const redirectUrl = getRedirectUrl();
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
return; // Prevent the default navigation
|
||||
}
|
||||
window.location.href = Pages.dashboard
|
||||
},
|
||||
onError(error: ErrorType) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { toast } from 'react-toastify'
|
||||
import { Pages } from '../../../config/Pages'
|
||||
import { setToken } from '../../../config/func'
|
||||
import { setRefreshToken } from '../../../config/func'
|
||||
|
||||
import { getRedirectUrl } from '../../../config/func'
|
||||
const RegisterStep2: FC = () => {
|
||||
|
||||
const { t } = useTranslation('global')
|
||||
@@ -51,6 +51,11 @@ const RegisterStep2: FC = () => {
|
||||
onSuccess(data) {
|
||||
setToken(data?.data?.accessToken?.token)
|
||||
setRefreshToken(data?.data?.refreshToken?.token)
|
||||
const redirectUrl = getRedirectUrl();
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
return; // Prevent the default navigation
|
||||
}
|
||||
window.location.href = Pages.dashboard
|
||||
},
|
||||
onError(error: ErrorType) {
|
||||
|
||||
@@ -19,15 +19,13 @@ const ServiceHeader: FC<Props> = (props: Props) => {
|
||||
const { t } = useTranslation('global')
|
||||
const [planSelected, setPlanSelected] = useState<string>(data?.subscriptionPlans[0]?.id)
|
||||
const [price, setPrice] = useState<number>(data?.subscriptionPlans[0]?.price)
|
||||
// const [finalPrice, setFinalPrice] = useState<number>(0)
|
||||
const [finalPrice, setFinalPrice] = useState<number>(0)
|
||||
const buyService = useBuyService()
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const plan: PlanItemType = data?.subscriptionPlans.find((item) => item.id === planSelected)
|
||||
console.log(plan);
|
||||
|
||||
// setFinalPrice(plan.finalPrice)
|
||||
setFinalPrice(plan.originalPrice)
|
||||
setPrice(plan?.price)
|
||||
|
||||
}, [planSelected])
|
||||
@@ -78,16 +76,18 @@ const ServiceHeader: FC<Props> = (props: Props) => {
|
||||
<div className='flex gap-4 mt-5 xl:mt-0 items-center justify-between xl:justify-normal'>
|
||||
<div className='text-xs whitespace-nowrap flex gap-1 items-center'>
|
||||
<div className='flex gap-2'>
|
||||
{/* {
|
||||
{
|
||||
finalPrice !== price &&
|
||||
<div className='line-through text-xs text-description'>
|
||||
{NumberFormat(Number(price))}
|
||||
</div>
|
||||
} */}
|
||||
}
|
||||
<div>{NumberFormat(Number(price))}</div>
|
||||
</div>
|
||||
<span>{t('toman')}</span>
|
||||
</div>
|
||||
{
|
||||
planSelected &&
|
||||
<Link to={Pages.services.buy + `${data.id}/${planSelected}`}>
|
||||
<Button
|
||||
// onClick={handleBuy}
|
||||
@@ -102,6 +102,8 @@ const ServiceHeader: FC<Props> = (props: Props) => {
|
||||
</div>
|
||||
</Button>
|
||||
</Link>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -63,12 +63,12 @@ export type PlanItemType = {
|
||||
type: string;
|
||||
}[];
|
||||
duration: number;
|
||||
finalPrice: number;
|
||||
id: string;
|
||||
isActive: boolean;
|
||||
name: string;
|
||||
price: number;
|
||||
updatedAt: string;
|
||||
originalPrice: number;
|
||||
};
|
||||
|
||||
// export type BuyServiceType = {
|
||||
|
||||
Reference in New Issue
Block a user