From 869f21ee2efaefed6a5aa4fbd417c25df8dec02a Mon Sep 17 00:00:00 2001 From: soryu Date: Sun, 18 Jan 2026 17:44:50 +0000 Subject: Add React Native mobile app for Makima (#3) * [WIP] Heartbeat checkpoint - 2026-01-18 02:58:27 UTC * feat(mobile): complete mobile app integration and verification - Add ThemeColors type export to Colors.ts for type safety - Export SUPABASE_URL from supabase.ts and use environment variables - Update .env.example with correct default URLs - Add comprehensive README.md with setup instructions Verified: - TypeScript compiles without errors - App exports successfully for iOS and Android - All screens accessible (login, dashboard, tasks, settings, task detail) - Auth flow working with Zustand store and Supabase Co-Authored-By: Claude Opus 4.5 * Task completion checkpoint --------- Co-authored-by: Claude Opus 4.5 --- apps/mobile/hooks/useQuestions.ts | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 apps/mobile/hooks/useQuestions.ts (limited to 'apps/mobile/hooks/useQuestions.ts') diff --git a/apps/mobile/hooks/useQuestions.ts b/apps/mobile/hooks/useQuestions.ts new file mode 100644 index 0000000..af77a51 --- /dev/null +++ b/apps/mobile/hooks/useQuestions.ts @@ -0,0 +1,44 @@ +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { listPendingQuestions, answerQuestion, type PendingQuestion } from '../lib/api'; + +// Query keys for questions +export const questionKeys = { + all: ['questions'] as const, + lists: () => [...questionKeys.all, 'list'] as const, + list: () => [...questionKeys.lists()] as const, +}; + +/** + * Hook to fetch pending questions + * Polls every 5 seconds for updates + */ +export function usePendingQuestions() { + return useQuery({ + queryKey: questionKeys.list(), + queryFn: listPendingQuestions, + refetchInterval: 5000, + }); +} + +/** + * Hook to answer a pending question + */ +export function useAnswerQuestion() { + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: ({ questionId, response }: { questionId: string; response: string }) => + answerQuestion(questionId, response), + onSuccess: () => { + // Invalidate questions list to refetch + queryClient.invalidateQueries({ queryKey: questionKeys.lists() }); + }, + }); +} + +/** + * Get the count of pending questions + */ +export function getQuestionCount(questions: PendingQuestion[] | undefined): number { + return questions?.length ?? 0; +} -- cgit v1.2.3