chore: move all settings to dashboard

This commit is contained in:
kieran 2024-07-22 11:26:44 +01:00
parent 563d313dae
commit ab0923d06d
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
8 changed files with 74 additions and 38 deletions

View File

@ -9,7 +9,7 @@ export interface ModalProps {
bodyClassName?: string;
onClose?: (e: React.MouseEvent | KeyboardEvent) => void;
onClick?: (e: React.MouseEvent) => void;
children: ReactNode;
children?: ReactNode;
showClose?: boolean;
ready?: boolean;
largeModal?: boolean;

View File

@ -90,13 +90,13 @@ interface NewStreamDialogProps {
btnClassName?: string;
}
export function NewStreamDialog(props: NewStreamDialogProps & StreamEditorProps) {
export function NewStreamDialog({ text, btnClassName, ...props }: NewStreamDialogProps & StreamEditorProps) {
const [open, setOpen] = useState(false);
return (
<>
<DefaultButton className={props.btnClassName} onClick={() => setOpen(true)}>
{props.text && props.text}
{!props.text && (
<DefaultButton className={btnClassName} onClick={() => setOpen(true)}>
{text && text}
{!text && (
<>
<span className="max-xl:hidden">
<FormattedMessage defaultMessage="Stream" id="uYw2LD" />

View File

@ -134,10 +134,6 @@ const router = createBrowserRouter([
path: "",
element: <AccountSettingsTab />,
},
{
path: "stream",
element: <StreamSettingsTab />,
},
{
path: "profile",
element: <ProfileSettings />,

View File

@ -0,0 +1,28 @@
import { DefaultButton } from "@/element/buttons";
import Modal from "@/element/modal";
import { useState } from "react";
import { FormattedMessage } from "react-intl";
import { NostrStreamProvider } from "@/providers";
import NostrProviderDialog from "@/element/provider/nostr";
export default function BalanceHistoryModal({ provider }: { provider: NostrStreamProvider }) {
const [show, setShow] = useState(false);
return (
<>
<DefaultButton onClick={() => setShow(true)}>
<FormattedMessage defaultMessage="Balance" />
</DefaultButton>
{show && (
<Modal id="raid-menu" onClose={() => setShow(false)} largeModal={true}>
<NostrProviderDialog
provider={provider}
showBalanceHistory={true}
showEditor={false}
showEndpoints={true}
showForwards={false}
/>
</Modal>
)}
</>
);
}

View File

@ -28,6 +28,8 @@ import classNames from "classnames";
import ManualStream from "./manual-stream";
import { unixNow } from "@snort/shared";
import { Icon } from "@/element/icon";
import ForwardingModal from "./forwarding";
import BalanceHistoryModal from "./balance-history";
const StreamSummary = lazy(() => import("@/element/summary-chart"));
export function DashboardForLink({ link }: { link: NostrLink }) {
@ -220,6 +222,17 @@ export function DashboardForLink({ link }: { link: NostrLink }) {
</div>
</DashboardCard>
)}
{(!streamLink || status === StreamState.Ended) && (
<DashboardCard className="flex flex-col gap-4">
<h3>
<FormattedMessage defaultMessage="Account Setup" />
</h3>
<div className="flex gap-2">
<BalanceHistoryModal provider={provider} />
<ForwardingModal provider={provider} />
</div>
</DashboardCard>
)}
</div>
{streamLink && status === StreamState.Live && (
<>

View File

@ -0,0 +1,28 @@
import { DefaultButton } from "@/element/buttons";
import Modal from "@/element/modal";
import { useState } from "react";
import { FormattedMessage } from "react-intl";
import { NostrStreamProvider } from "@/providers";
import NostrProviderDialog from "@/element/provider/nostr";
export default function ForwardingModal({ provider }: { provider: NostrStreamProvider }) {
const [show, setShow] = useState(false);
return (
<>
<DefaultButton onClick={() => setShow(true)}>
<FormattedMessage defaultMessage="Stream Forwarding" />
</DefaultButton>
{show && (
<Modal id="raid-menu" onClose={() => setShow(false)}>
<NostrProviderDialog
provider={provider}
showBalanceHistory={false}
showEditor={false}
showEndpoints={false}
showForwards={true}
/>
</Modal>
)}
</>
);
}

View File

@ -11,10 +11,6 @@ const Tabs = [
name: <FormattedMessage defaultMessage="Profile" />,
path: "profile",
},
{
name: <FormattedMessage defaultMessage="Stream" />,
path: "stream",
},
];
export default function SettingsPage() {
const naviage = useNavigate();

View File

@ -1,25 +0,0 @@
import NostrProviderDialog from "@/element/provider/nostr";
import { useStreamProvider } from "@/hooks/stream-provider";
import { NostrStreamProvider } from "@/providers";
import { unwrap } from "@snort/shared";
import { FormattedMessage } from "react-intl";
export function StreamSettingsTab() {
const providers = useStreamProvider();
return (
<>
<h1>
<FormattedMessage defaultMessage="Stream" id="uYw2LD" />
</h1>
<div className="flex flex-col gap-4">
<NostrProviderDialog
provider={unwrap(providers.find(a => a.name === "zap.stream")) as NostrStreamProvider}
showEndpoints={true}
showEditor={false}
showForwards={true}
showBalanceHistory={true}
/>
</div>
</>
);
}