mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 14:52:31 +00:00
billing events (wip)
This commit is contained in:
1 parent
de4a70009d
commit
7082cf2830
3 files changed
+43
-5
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
faPaintbrush,
|
||||
faImage,
|
||||
faPenNib,
|
||||
faGem,
|
||||
} from "@fortawesome/pro-solid-svg-icons";
|
||||
import {
|
||||
faWindowRestore,
|
||||
@@ -51,6 +52,8 @@ import {
|
||||
} from "@storyteller/tauri-utils";
|
||||
import { useEditStore } from "../../../pages/PageEdit/stores/EditState";
|
||||
import { BaseSelectorImage } from "../../../pages/PageEdit/BaseImageSelector";
|
||||
import { ProviderSetupModal } from "@storyteller/provider-setup-modal";
|
||||
import { usePricingModalStore } from "@storyteller/ui-pricing-modal";
|
||||
|
||||
interface Props {
|
||||
pageName: string;
|
||||
@@ -190,7 +193,7 @@ export const TopBar = ({ pageName, loginSignUpPressed }: Props) => {
|
||||
|
||||
const pageTitle = getPageTitle();
|
||||
|
||||
// const { toggleModal } = usePricingModalStore(); - Uncomment for pricing modal - BFlat
|
||||
const { toggleModal } = usePricingModalStore();
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -261,14 +264,14 @@ export const TopBar = ({ pageName, loginSignUpPressed }: Props) => {
|
||||
<div className="flex justify-end gap-2" data-tauri-drag-region>
|
||||
<div className="no-drag flex gap-2">
|
||||
{/* - Uncomment for pricing modal - BFlat */}
|
||||
{/* <Button
|
||||
<Button
|
||||
variant="primary"
|
||||
icon={faGem}
|
||||
onClick={toggleModal}
|
||||
className="shadow-md shadow-primary-500/50 transition-all duration-300 hover:shadow-md hover:shadow-primary-500/75"
|
||||
>
|
||||
Upgrade Now
|
||||
</Button> */}
|
||||
</Button>
|
||||
<Tooltip content="Settings" position="bottom" delay={300}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
@@ -336,6 +339,8 @@ export const TopBar = ({ pageName, loginSignUpPressed }: Props) => {
|
||||
onDownloadClicked={downloadFile}
|
||||
onEditClicked={handleEditFromGallery}
|
||||
/>
|
||||
|
||||
<ProviderSetupModal />
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -24,7 +24,6 @@ import { PageEditor } from "~/pages/PageEnigma/PageEditor";
|
||||
import { GalleryDragComponent } from "@storyteller/ui-gallery-modal";
|
||||
import { LoadingDots } from "@storyteller/ui-loading";
|
||||
import { PricingModal } from "@storyteller/ui-pricing-modal";
|
||||
import { ProviderSetupModal } from "@storyteller/provider-setup-modal";
|
||||
import {
|
||||
isActionReminderOpen,
|
||||
actionReminderProps,
|
||||
@@ -120,7 +119,6 @@ export const PageEnigma = ({ sceneToken }: { sceneToken?: string }) => {
|
||||
/>
|
||||
<GenerateModals />
|
||||
<ErrorDialog />
|
||||
<ProviderSetupModal />
|
||||
|
||||
<EditorLoadingBar />
|
||||
<Toaster offsetTop={70} offsetRight={12} />
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { listen, UnlistenFn } from '@tauri-apps/api/event';
|
||||
import { BasicEventWrapper } from '../../common/BasicEventWrapper';
|
||||
import { useEffect } from 'react';
|
||||
import { GenerationProvider } from '@storyteller/common';
|
||||
|
||||
const EVENT_NAME : string = 'show_provider_billing_modal_event';
|
||||
|
||||
export interface ShowProviderBillingModalEvent {
|
||||
provider: GenerationProvider,
|
||||
}
|
||||
|
||||
export const useShowProviderBillingModalEvent = (asyncCallback: (event: ShowProviderBillingModalEvent) => Promise<void>) => {
|
||||
useEffect(() => {
|
||||
let isUnmounted = false;
|
||||
let unlisten: Promise<UnlistenFn>;
|
||||
|
||||
const setup = async () => {
|
||||
unlisten = listen<BasicEventWrapper<ShowProviderBillingModalEvent>>(EVENT_NAME, async (wrappedEvent) => {
|
||||
await asyncCallback(wrappedEvent.payload.data);
|
||||
});
|
||||
|
||||
if (isUnmounted) {
|
||||
unlisten.then(f => f()); // Unsubscribe if unmounted early.
|
||||
}
|
||||
};
|
||||
|
||||
setup();
|
||||
|
||||
return () => {
|
||||
isUnmounted = true;
|
||||
unlisten.then(f => f());
|
||||
};
|
||||
|
||||
}, []);
|
||||
}
|
||||
Reference in new issue
Block a user