Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const MobileconfigPage = lazyWithRetry(() => import('@/pages/mobileconfig/Mobile
const MobileconfigDownload = lazyWithRetry(() => import('@/pages/mobileconfig/MobileconfigDownload'));
const HomeScreen = lazyWithRetry(() => import('./pages/home/HomeScreen'));

import { createBrowserRouter, RouterProvider, Navigate, Outlet, useLoaderData, useLocation, useNavigate, redirect } from 'react-router-dom';
import { createBrowserRouter, RouterProvider, Navigate, Outlet, useLoaderData, useLocation, useNavigate, redirect, ScrollRestoration } from 'react-router-dom';
import { ThemeProvider } from "@/components/theme-provider"
import api from "@/api/api";
import type { ModelAccount, ModelProfile } from "@/api/client/api";
Expand Down Expand Up @@ -528,6 +528,7 @@ function EventHandlerMount() {
function AppWithEventHandler() {
return (
<>
<ScrollRestoration />
<Toaster />
<AuthProvider>
<NavigationCollapseProvider>
Expand Down
61 changes: 3 additions & 58 deletions app/src/pages/account_preferences/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
TrashIcon,
} from "lucide-react";
import type { JSX } from "react";
import { useState, useEffect } from "react";
import { useState } from "react";
import { useLocation } from 'react-router-dom';
import { Button } from "@/components/ui/button";
import StatusBadge from "@/components/general/StatusBadge";
import { Card, CardContent } from "@/components/ui/card";
import AccountInfoCard from "@/pages/account_preferences/AccountInfoCard";
import type { ModelAccount, ModelSubscription } from "@/api/client/api";
import type { ModelAccount } from "@/api/client/api";
import api from "@/api/api";
import ToggleGroup from "@/components/general/ToggleGroup";
import { toast } from "sonner"
Expand Down Expand Up @@ -120,54 +120,7 @@ const PreferencesSection = ({ account }: PreferencesSectionProps): JSX.Element =
}
};

// Subscription state
const [subscription, setSubscription] = useState<ModelSubscription | null>(null);
const [subscriptionLoading, setSubscriptionLoading] = useState(false);
const [subscriptionError, setSubscriptionError] = useState<string | null>(null);

// Fetch subscription info once on mount (requires auth cookie)
useEffect(() => {
let cancelled = false;
const fetchSubscription = async () => {
setSubscriptionLoading(true);
setSubscriptionError(null);
try {
const resp = await api.Client.subscriptionApi.apiV1SubGet();
if (!cancelled) {
setSubscription(resp.data);
}
} catch (err: unknown) {
// 404 means no subscription yet; treat silently
let notFound = false;
if (typeof err === 'object' && err !== null && 'response' in err) {
const response = (err as { response?: { status?: number } }).response;
if (response?.status === 404) {
notFound = true;
}
}
if (notFound) {
if (!cancelled) setSubscription(null);
} else if (!cancelled) {
setSubscriptionError('Failed to load subscription');
}
} finally {
if (!cancelled) setSubscriptionLoading(false);
}
};
fetchSubscription();
return () => { cancelled = true; };
}, []);

const formatDate = (iso?: string) => {
if (!iso) return '—';
try {
const d = new Date(iso);
if (isNaN(d.getTime())) return iso;
return d.toLocaleDateString();
} catch { return iso; }
};

// Account info data (Member since removed; Active until + Subscription type added)
// Account info data
const accountInfo = [
{ label: "modDNS ID", value: currentAccount?.email || "" },
{
Expand All @@ -188,14 +141,6 @@ const PreferencesSection = ({ account }: PreferencesSectionProps): JSX.Element =
? <ShieldCheck className="w-4 h-4 text-[var(--tailwind-colors-rdns-600)]" />
: <ShieldX className="w-4 h-4 text-[var(--tailwind-colors-red-600)]" />,
},
{
label: "Active until",
value: subscriptionLoading
? 'Loading…'
: subscriptionError
? subscriptionError
: formatDate(subscription?.active_until),
},
];

// Section data
Expand Down
Loading
Loading