fix: back button

This commit is contained in:
IlyaDoronin 2024-05-09 11:48:03 +03:00
commit 1cf4cc7dae
3 changed files with 17 additions and 17 deletions

@ -65,6 +65,7 @@ export default function Payment() {
const [paymentLink, setPaymentLink] = useState<string>(""); const [paymentLink, setPaymentLink] = useState<string>("");
const [fromSquiz, setIsFromSquiz] = useState<boolean>(false); const [fromSquiz, setIsFromSquiz] = useState<boolean>(false);
const location = useLocation(); const location = useLocation();
console.log("location", location);
const verificationStatus = useUserStore((state) => state.verificationStatus); const verificationStatus = useUserStore((state) => state.verificationStatus);
const userId = useUserStore((state) => state.userId); const userId = useUserStore((state) => state.userId);
const navigate = useNavigate(); const navigate = useNavigate();
@ -85,7 +86,9 @@ export default function Payment() {
setIsFromSquiz(true); setIsFromSquiz(true);
setPaymentValueField((Number(params.get("dif") || "0") / 100).toString()); setPaymentValueField((Number(params.get("dif") || "0") / 100).toString());
} }
history.pushState(null, document.title, "/payment"); navigate(`/payment`, {
replace: true,
});
}, []); }, []);
async function handleChoosePaymentClick() { async function handleChoosePaymentClick() {
@ -181,14 +184,12 @@ export default function Payment() {
gap: "10px", gap: "10px",
}} }}
> >
{!upMd && location.key !== "default" && (
<IconButton <IconButton
onClick={handleCustomBackNavigation} onClick={handleCustomBackNavigation}
sx={{ p: 0, height: "28px", width: "28px", color: "black" }} sx={{ p: 0, height: "28px", width: "28px", color: "black" }}
> >
<ArrowBackIcon /> <ArrowBackIcon />
</IconButton> </IconButton>
)}
<Typography variant="h4">Способ оплаты</Typography> <Typography variant="h4">Способ оплаты</Typography>
</Box> </Box>
{!upMd && ( {!upMd && (

@ -60,7 +60,9 @@ export default function QuizPayment() {
if (first) { if (first) {
history.pushState(null, document.title, "/quizpayment"); navigate(`/quizpayment`, {
replace: true,
});
try { try {
first = false; first = false;

@ -16,7 +16,6 @@ export const useHistoryTracker = () => {
const handleCustomBackNavigation = () => { const handleCustomBackNavigation = () => {
const historyJSON = localStorage.getItem("history"); const historyJSON = localStorage.getItem("history");
// debugger;
if (historyJSON) { if (historyJSON) {
const history = JSON.parse(historyJSON); const history = JSON.parse(historyJSON);
@ -28,15 +27,13 @@ export const useHistoryTracker = () => {
return; return;
} }
if (location.search.includes("squizpay")) { navigate(-1);
navigate(-3); }
return; return;
} }
navigate(-1); navigate(-1);
}
}
}; };
return handleCustomBackNavigation; return handleCustomBackNavigation;