stripe
This commit is contained in:
1 parent
01c0e9ef4d
commit
1b162578c2
22 files changed
+450
-72
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { BasePage, InfoBox, PlanCard } from "@/components/design-elements";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import Box from "@mui/material/Box";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { Button } from "@/components/inputs";
|
||||
|
||||
import { useAppSelector } from "@/hooks/AppHooks";
|
||||
import { useGet, usePost } from "@/hooks/UseApi";
|
||||
@@ -27,6 +29,14 @@ const BillingPage = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancel = async () => {
|
||||
const result = await post("/billing/cancel", {});
|
||||
const redirectUrl = result?.data?.redirectUrl;
|
||||
if (redirectUrl) {
|
||||
window.location = redirectUrl;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<BasePage>
|
||||
<InfoBox
|
||||
@@ -48,6 +58,18 @@ const BillingPage = () => {
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
{selectedPlan !== "free" && (
|
||||
<Box>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="error"
|
||||
onClick={handleCancel}
|
||||
loading={isPosting}
|
||||
>
|
||||
Cancel subscription
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
</BasePage>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,37 @@
|
||||
import { BasePage } from "@/components/design-elements";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { Navigate, useSearchParams } from "react-router-dom";
|
||||
import { useGet } from "@/hooks/UseApi";
|
||||
import type { ApiResponse } from "@/hooks/UseApi";
|
||||
|
||||
const BillingSuccessPage = () => {
|
||||
return "Great";
|
||||
const theme = useTheme();
|
||||
const [searchParams] = useSearchParams();
|
||||
const plan = searchParams.get("plan");
|
||||
|
||||
const { response } = useGet<ApiResponse<any>>(
|
||||
`/billing/confirm?plan=${plan}`,
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
const success = response?.data?.success ?? false;
|
||||
if (success === true) {
|
||||
return <Navigate to="/billing" replace />;
|
||||
} else {
|
||||
return (
|
||||
<BasePage>
|
||||
<Stack direction="row" alignItems={"center"} gap={theme.spacing(10)}>
|
||||
<CircularProgress color="accent" />
|
||||
<Typography>Awaiting confirmation..</Typography>
|
||||
</Stack>
|
||||
</BasePage>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default BillingSuccessPage;
|
||||
Reference in new issue
Block a user