mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 00:06:41 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import { useInsufficientCreditsInterceptor } from '../../src/hooks/useInsufficientCreditsInterceptor';
|
|
import { useInsufficientCreditsStore } from '../../src/stores/insufficientCreditsStore';
|
|
import InsufficientCreditsModal from './InsufficientCreditsModal';
|
|
|
|
/**
|
|
* Global handler for insufficient credits errors.
|
|
* This component should be mounted at the root level of the app.
|
|
* It intercepts 402 errors and displays the insufficient credits modal.
|
|
*/
|
|
export default function GlobalInsufficientCreditsHandler() {
|
|
// Set up the global fetch interceptor
|
|
useInsufficientCreditsInterceptor();
|
|
|
|
// Get modal state from the store
|
|
const { isModalVisible, requiredCredits, availableCredits, operation, closeModal } =
|
|
useInsufficientCreditsStore();
|
|
|
|
return (
|
|
<InsufficientCreditsModal
|
|
visible={isModalVisible}
|
|
requiredCredits={requiredCredits || 0}
|
|
availableCredits={availableCredits || 0}
|
|
operationType={operation === 'story_creation' ? 'story' : 'character'}
|
|
onClose={closeModal}
|
|
onGetCredits={() => {
|
|
// TODO: Navigate to credits purchase page
|
|
console.log('Navigate to credits purchase page');
|
|
closeModal();
|
|
}}
|
|
/>
|
|
);
|
|
}
|