This commit is contained in:
Alex Holliday committed 2025-12-02 00:20:09 +00:00
1 parent 01c0e9ef4d
commit 1b162578c2
22 files changed
+450 -72

No files matched your search

+22
View File
@@ -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>
);
};
+33 -1
View File
@@ -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;
@@ -19,12 +19,14 @@ import useMediaQuery from "@mui/material/useMediaQuery";
import { useState } from "react";
import { useDelete } from "@/hooks/UseApi";
import { InitializingStatusBox } from "@/components/design-elements/StatusBox";
import { useAppSelector } from "@/hooks/AppHooks";
const GLOBAL_REFRESH = import.meta.env.VITE_APP_GLOBAL_REFRESH;
const PageSpeedMonitorsPage = () => {
const theme = useTheme();
const { t } = useTranslation();
const { user } = useAppSelector((state) => state.auth);
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
const [selectedMonitor, setSelectedMonitor] = useState<IMonitor | null>(null);
const isDialogOpen = Boolean(selectedMonitor);
@@ -64,6 +66,8 @@ const PageSpeedMonitorsPage = () => {
const downCount = response?.data?.downCount || 0;
const pausedCount = response?.data?.pausedCount || 0;
const monitorLimitReached = count >= (user?.entitlements?.monitorsMax || 0);
const handleConfirm = async () => {
await deleteFn(`/monitors/${selectedMonitor?._id}`);
setSelectedMonitor(null);
@@ -79,6 +83,7 @@ const PageSpeedMonitorsPage = () => {
loading={isValidating}
error={error}
items={monitors}
monitorLimitReached={monitorLimitReached}
page="infrastructure"
actionLink="/infrastructure/create"
>
@@ -19,11 +19,14 @@ import useMediaQuery from "@mui/material/useMediaQuery";
import { useState } from "react";
import { useDelete } from "@/hooks/UseApi";
import { InitializingStatusBox } from "@/components/design-elements/StatusBox";
import { useAppSelector } from "@/hooks/AppHooks";
const GLOBAL_REFRESH = import.meta.env.VITE_APP_GLOBAL_REFRESH;
const PageSpeedMonitorsPage = () => {
const theme = useTheme();
const { user } = useAppSelector((state) => state.auth);
const { t } = useTranslation();
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
const [selectedMonitor, setSelectedMonitor] = useState<IMonitor | null>(null);
@@ -64,6 +67,8 @@ const PageSpeedMonitorsPage = () => {
const downCount = response?.data?.downCount || 0;
const pausedCount = response?.data?.pausedCount || 0;
const monitorLimitReached = count >= (user?.entitlements?.monitorsMax || 0);
const handleConfirm = async () => {
await deleteFn(`/monitors/${selectedMonitor?._id}`);
setSelectedMonitor(null);
@@ -81,6 +86,7 @@ const PageSpeedMonitorsPage = () => {
items={monitors}
page="pageSpeed"
actionLink="/pagespeed/create"
monitorLimitReached={monitorLimitReached}
>
<InfoBox
title="Website Performance Tracking"
+6 -1
View File
@@ -10,6 +10,7 @@ import { HeaderCreate } from "@/components/common";
import Stack from "@mui/material/Stack";
import { Dialog } from "@/components/inputs";
import { MonitorTable } from "@/pages/uptime/MonitorTable";
import { InitializingStatusBox } from "@/components/design-elements/StatusBox";
import { useTranslation } from "react-i18next";
import { useTheme } from "@mui/material/styles";
@@ -26,12 +27,13 @@ import {
import useMediaQuery from "@mui/material/useMediaQuery";
import { useState } from "react";
import { useDelete } from "@/hooks/UseApi";
import { InitializingStatusBox } from "@/components/design-elements/StatusBox";
import { useAppSelector } from "@/hooks/AppHooks";
const GLOBAL_REFRESH = import.meta.env.VITE_APP_GLOBAL_REFRESH;
const UptimeMonitors = () => {
const theme = useTheme();
const { user } = useAppSelector((state) => state.auth);
const { t } = useTranslation();
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
const [selectedMonitor, setSelectedMonitor] = useState<IMonitor | null>(null);
@@ -91,6 +93,8 @@ const UptimeMonitors = () => {
const downCount = response?.data?.downCount || 0;
const pausedCount = response?.data?.pausedCount || 0;
const monitorLimitReached = count >= (user?.entitlements?.monitorsMax || 0);
const handleConfirm = async () => {
await deleteFn(`/monitors/${selectedMonitor?._id}`);
setSelectedMonitor(null);
@@ -120,6 +124,7 @@ const UptimeMonitors = () => {
items={monitorItems}
page="uptime"
actionLink="/uptime/create"
monitorLimitReached={monitorLimitReached}
>
<InfoBox
title="Website & API Uptime Monitoring"