@umituz/react-native-ai-generation-content 1.28.5 → 1.28.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.6",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useMemo, useCallback, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { View, StyleSheet } from "react-native";
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
8
|
+
import { useAppDesignTokens, useAlert, AlertType, AlertMode } from "@umituz/react-native-design-system";
|
|
9
9
|
import { useFlow } from "../../../infrastructure/flow/useFlow";
|
|
10
10
|
import { StepType, type StepDefinition } from "../../../../../domain/entities/flow-config.types";
|
|
11
11
|
import type { WizardFeatureConfig } from "../../domain/entities/wizard-config.types";
|
|
@@ -14,6 +14,7 @@ import { useWizardGeneration, type WizardScenarioData } from "../hooks/useWizard
|
|
|
14
14
|
import type { AlertMessages } from "../../../../../presentation/hooks/generation/types";
|
|
15
15
|
import type { UploadedImage } from "../../../../../presentation/hooks/generation/useAIGenerateState";
|
|
16
16
|
import type { Creation } from "../../../../creations/domain/entities/Creation";
|
|
17
|
+
import { createCreationsRepository } from "../../../../creations";
|
|
17
18
|
import { useResultActions } from "../../../../result-preview/presentation/hooks/useResultActions";
|
|
18
19
|
import { validateScenario } from "../utilities/validateScenario";
|
|
19
20
|
import { WizardStepRenderer } from "./WizardStepRenderer";
|
|
@@ -32,7 +33,6 @@ export interface GenericWizardFlowProps {
|
|
|
32
33
|
readonly onGenerationComplete?: (result: unknown) => void;
|
|
33
34
|
readonly onGenerationError?: (error: string) => void;
|
|
34
35
|
readonly onCreditsExhausted?: () => void;
|
|
35
|
-
readonly onRate?: (creationId: string, rating: number, description: string) => Promise<boolean>;
|
|
36
36
|
readonly onBack?: () => void;
|
|
37
37
|
readonly onTryAgain?: () => void;
|
|
38
38
|
readonly t: (key: string) => string;
|
|
@@ -53,7 +53,6 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
53
53
|
onGenerationComplete,
|
|
54
54
|
onGenerationError,
|
|
55
55
|
onCreditsExhausted,
|
|
56
|
-
onRate,
|
|
57
56
|
onBack,
|
|
58
57
|
onTryAgain,
|
|
59
58
|
t,
|
|
@@ -63,11 +62,14 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
63
62
|
renderResult,
|
|
64
63
|
}) => {
|
|
65
64
|
const tokens = useAppDesignTokens();
|
|
65
|
+
const alert = useAlert();
|
|
66
66
|
const [currentCreation, setCurrentCreation] = useState<Creation | null>(null);
|
|
67
67
|
const [showRatingPicker, setShowRatingPicker] = useState(false);
|
|
68
68
|
const [hasRated, setHasRated] = useState(false);
|
|
69
69
|
const prevStepIdRef = useRef<string | undefined>(undefined);
|
|
70
70
|
|
|
71
|
+
const repository = useMemo(() => createCreationsRepository("creations"), []);
|
|
72
|
+
|
|
71
73
|
const flowSteps = useMemo<StepDefinition[]>(() => {
|
|
72
74
|
return buildFlowStepsFromWizard(featureConfig, {
|
|
73
75
|
includePreview: true,
|
|
@@ -184,13 +186,16 @@ export const GenericWizardFlow: React.FC<GenericWizardFlowProps> = ({
|
|
|
184
186
|
}, []);
|
|
185
187
|
|
|
186
188
|
const handleSubmitRating = useCallback(async (rating: number, description: string) => {
|
|
187
|
-
if (!currentCreation?.id || !
|
|
188
|
-
const success = await
|
|
189
|
-
if (success)
|
|
189
|
+
if (!currentCreation?.id || !userId) return;
|
|
190
|
+
const success = await repository.rate(userId, currentCreation.id, rating, description);
|
|
191
|
+
if (success) {
|
|
192
|
+
setHasRated(true);
|
|
193
|
+
alert.show(AlertType.SUCCESS, AlertMode.TOAST, t("result.rateSuccessTitle"), t("result.rateSuccessMessage"));
|
|
194
|
+
}
|
|
190
195
|
setShowRatingPicker(false);
|
|
191
|
-
}, [currentCreation,
|
|
196
|
+
}, [currentCreation, userId, repository, alert, t]);
|
|
192
197
|
|
|
193
|
-
const showRatingButton = Boolean(
|
|
198
|
+
const showRatingButton = Boolean(userId) && !hasRated;
|
|
194
199
|
|
|
195
200
|
return (
|
|
196
201
|
<View style={[styles.container, { backgroundColor: tokens.colors.backgroundPrimary }]}>
|