managarten/maerchenzauber/apps/mobile/components/molecules/GlobalInsufficientCreditsHandler.tsx
Till-JS e7f5f942f3 chore: initial commit - consolidate 4 projects into monorepo
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>
2025-11-22 23:38:24 +01:00

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();
}}
/>
);
}