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

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

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