From a50aceb419bd355974d903f27d668dd8a6965b4d Mon Sep 17 00:00:00 2001 From: degoNDL Date: Sun, 26 Apr 2026 17:46:53 -0300 Subject: [PATCH 1/3] =?UTF-8?q?SCRUM-41:=20integra=20dashboard=20de=20rela?= =?UTF-8?q?t=C3=B3rios=20com=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- app/(report)/negativePoints.tsx | 56 ++++++++++++++++------- app/(report)/positivePoints.tsx | 56 ++++++++++++++++------- app/(report)/recomendations.tsx | 56 ++++++++++++++++------- app/(report)/report.tsx | 60 ++++++++++++++++++++----- components/report/CardList.tsx | 80 ++++++++++++++++----------------- services/reports.ts | 18 ++++++++ types/Report.ts | 15 +++++++ 7 files changed, 241 insertions(+), 100 deletions(-) create mode 100644 services/reports.ts create mode 100644 types/Report.ts diff --git a/app/(report)/negativePoints.tsx b/app/(report)/negativePoints.tsx index 12fb5d8..c678e33 100644 --- a/app/(report)/negativePoints.tsx +++ b/app/(report)/negativePoints.tsx @@ -1,20 +1,44 @@ import { Container } from '@/components/general/container'; import { Header } from '@/components/general/header'; -import { NegativeFeedbackList } from '@/components/report/NegativeFeedbackList'; -import { View } from 'react-native'; +import { CardItemFeedback } from '@/components/report/CardItemFeedback'; +import { CardListSkeleton } from '@/components/report/cardListSkeleton'; +import { getReport } from '@/services/reports'; +import { AIReportDetail } from '@/types/Report'; +import { useLocalSearchParams } from 'expo-router'; +import { useEffect, useState } from 'react'; +import { ScrollView, View } from 'react-native'; -export default function NegativePoints () { - return( - - -
+export default function NegativePoints() { + const { report_id } = useLocalSearchParams<{ report_id: string }>(); + const [report, setReport] = useState(null); + const [loading, setLoading] = useState(true); - ''} /> - - - ) -} \ No newline at end of file + useEffect(() => { + if (!report_id) return; + getReport(report_id) + .then(setReport) + .finally(() => setLoading(false)); + }, [report_id]); + + return ( + + +
+ + {loading ? ( + + ) : report ? ( + {}} + /> + ) : null} + + + + ); +} diff --git a/app/(report)/positivePoints.tsx b/app/(report)/positivePoints.tsx index ef7dbc0..dfe0c01 100644 --- a/app/(report)/positivePoints.tsx +++ b/app/(report)/positivePoints.tsx @@ -1,20 +1,44 @@ import { Container } from '@/components/general/container'; import { Header } from '@/components/general/header'; -import { PositiveFeedbackList } from '@/components/report/PositiveFeedbackList'; -import { View } from 'react-native'; +import { CardItemFeedback } from '@/components/report/CardItemFeedback'; +import { CardListSkeleton } from '@/components/report/cardListSkeleton'; +import { getReport } from '@/services/reports'; +import { AIReportDetail } from '@/types/Report'; +import { useLocalSearchParams } from 'expo-router'; +import { useEffect, useState } from 'react'; +import { ScrollView, View } from 'react-native'; -export default function PositivePoints () { - return( - - -
+export default function PositivePoints() { + const { report_id } = useLocalSearchParams<{ report_id: string }>(); + const [report, setReport] = useState(null); + const [loading, setLoading] = useState(true); - ''} /> - - - ) -} \ No newline at end of file + useEffect(() => { + if (!report_id) return; + getReport(report_id) + .then(setReport) + .finally(() => setLoading(false)); + }, [report_id]); + + return ( + + +
+ + {loading ? ( + + ) : report ? ( + {}} + /> + ) : null} + + + + ); +} diff --git a/app/(report)/recomendations.tsx b/app/(report)/recomendations.tsx index 7923d7d..bfb33bb 100644 --- a/app/(report)/recomendations.tsx +++ b/app/(report)/recomendations.tsx @@ -1,20 +1,44 @@ import { Container } from '@/components/general/container'; import { Header } from '@/components/general/header'; -import { RecommendationFeedbackList } from '@/components/report/RecommendationFeedbackList'; -import { View } from 'react-native'; +import { CardItemFeedback } from '@/components/report/CardItemFeedback'; +import { CardListSkeleton } from '@/components/report/cardListSkeleton'; +import { getReport } from '@/services/reports'; +import { AIReportDetail } from '@/types/Report'; +import { useLocalSearchParams } from 'expo-router'; +import { useEffect, useState } from 'react'; +import { ScrollView, View } from 'react-native'; -export default function Recomendations () { - return( - - -
+export default function Recomendations() { + const { report_id } = useLocalSearchParams<{ report_id: string }>(); + const [report, setReport] = useState(null); + const [loading, setLoading] = useState(true); - ''} /> - - - ) -} \ No newline at end of file + useEffect(() => { + if (!report_id) return; + getReport(report_id) + .then(setReport) + .finally(() => setLoading(false)); + }, [report_id]); + + return ( + + +
+ + {loading ? ( + + ) : report ? ( + {}} + /> + ) : null} + + + + ); +} diff --git a/app/(report)/report.tsx b/app/(report)/report.tsx index 5112d90..d67c847 100644 --- a/app/(report)/report.tsx +++ b/app/(report)/report.tsx @@ -1,27 +1,65 @@ import { Container } from '@/components/general/container'; +import GeneralButton from '@/components/general/generalButton'; import { Header } from '@/components/general/header'; import { CardList } from '@/components/report/CardList'; import { CardListSkeleton } from '@/components/report/cardListSkeleton'; -import { ChatButton } from '@/components/report/chatButton'; -import { useState } from 'react'; -import { View } from 'react-native'; +import { generateReport, getReportsByEnterprise } from '@/services/reports'; +import { AIReportSummary } from '@/types/Report'; +import { useEffect, useState } from 'react'; +import { Text, View } from 'react-native'; + +const ENTERPRISE_ID = 'caa68f64-b68e-4327-90f0-264ca1bb73e2'; export default function Report() { - const [loading, setLoading] = useState(false) + const [report, setReport] = useState(null); + const [loading, setLoading] = useState(true); + const [generating, setGenerating] = useState(false); + + useEffect(() => { + fetchLatestReport(); + }, []); - const handlePress = ()=> { - setLoading //to do + const fetchLatestReport = async () => { + try { + setLoading(true); + const reports = await getReportsByEnterprise(ENTERPRISE_ID); + if (reports.length > 0) { + setReport(reports[reports.length - 1]); + } + } finally { + setLoading(false); } - - return ( + }; + + const handleGenerate = async () => { + try { + setGenerating(true); + const newReport = await generateReport(ENTERPRISE_ID); + setReport(newReport); + } finally { + setGenerating(false); + } + }; + + return (
- {loading ? ( - + + ) : report ? ( + ) : ( - + + + Nenhum relatório gerado ainda. Gere o primeiro relatório do seu negócio. + + + )} diff --git a/components/report/CardList.tsx b/components/report/CardList.tsx index a960d12..5d18dac 100644 --- a/components/report/CardList.tsx +++ b/components/report/CardList.tsx @@ -1,45 +1,43 @@ +import { AIReportSummary } from '@/types/Report' import { router } from 'expo-router' import { View } from 'react-native' import { CardItem } from './CardItem' -export const CardList = ()=> { - const handlePresPositive = ()=> { - router.navigate('/(report)/positivePoints') - } - const handlePresNegative = ()=> { - router.navigate('/(report)/negativePoints') - } - const handlePresRecomendation = ()=> { - router.navigate('/(report)/recomendations') - } - return( - - - - - - ) -} \ No newline at end of file +type Props = { + report: AIReportSummary +} + +export const CardList = ({ report }: Props) => { + const handlePressPositive = () => { + router.navigate({ pathname: '/positivePoints' as any, params: { report_id: report.id_relatorio } }) + } + const handlePressNegative = () => { + router.navigate({ pathname: '/negativePoints' as any, params: { report_id: report.id_relatorio } }) + } + const handlePressRecomendation = () => { + router.navigate({ pathname: '/recomendations' as any, params: { report_id: report.id_relatorio } }) + } + + return ( + + + + + + ) +} diff --git a/services/reports.ts b/services/reports.ts new file mode 100644 index 0000000..4094995 --- /dev/null +++ b/services/reports.ts @@ -0,0 +1,18 @@ +import axios from 'axios' +import { API_URL } from '@/constants/api' +import { AIReportDetail, AIReportSummary } from '@/types/Report' + +export const generateReport = async (empresaId: string): Promise => { + const { data } = await axios.post(`${API_URL}/reports/generate/${empresaId}`) + return data +} + +export const getReportsByEnterprise = async (empresaId: string): Promise => { + const { data } = await axios.get(`${API_URL}/reports/by-enterprise/${empresaId}`) + return data +} + +export const getReport = async (reportId: string): Promise => { + const { data } = await axios.get(`${API_URL}/reports/${reportId}`) + return data +} diff --git a/types/Report.ts b/types/Report.ts new file mode 100644 index 0000000..5891303 --- /dev/null +++ b/types/Report.ts @@ -0,0 +1,15 @@ +export type AIReportSummary = { + id_relatorio: string + empresa_id: string + contexto_id: string + pontos_positivos_resumo: string + melhorias_resumo: string + recomendacoes_resumo: string + criado_em: string +} + +export type AIReportDetail = AIReportSummary & { + pontos_positivos_detalhado: string + melhorias_detalhado: string + recomendacoes_detalhado: string +} From 563508023cab518a5072c491278c3df059b1cb0b Mon Sep 17 00:00:00 2001 From: degoNDL Date: Sun, 26 Apr 2026 18:30:45 -0300 Subject: [PATCH 2/3] SCRUM-41: substitui axios por fetch no reports service Co-Authored-By: Claude Sonnet 4.6 --- services/reports.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/services/reports.ts b/services/reports.ts index 4094995..cffa10f 100644 --- a/services/reports.ts +++ b/services/reports.ts @@ -1,18 +1,17 @@ -import axios from 'axios' import { API_URL } from '@/constants/api' import { AIReportDetail, AIReportSummary } from '@/types/Report' export const generateReport = async (empresaId: string): Promise => { - const { data } = await axios.post(`${API_URL}/reports/generate/${empresaId}`) - return data + const res = await fetch(`${API_URL}/reports/generate/${empresaId}`, { method: 'POST' }) + return res.json() } export const getReportsByEnterprise = async (empresaId: string): Promise => { - const { data } = await axios.get(`${API_URL}/reports/by-enterprise/${empresaId}`) - return data + const res = await fetch(`${API_URL}/reports/by-enterprise/${empresaId}`) + return res.json() } export const getReport = async (reportId: string): Promise => { - const { data } = await axios.get(`${API_URL}/reports/${reportId}`) - return data + const res = await fetch(`${API_URL}/reports/${reportId}`) + return res.json() } From e298935d7b9808d622354151ceab600426353470 Mon Sep 17 00:00:00 2001 From: degoNDL Date: Sun, 26 Apr 2026 19:56:34 -0300 Subject: [PATCH 3/3] =?UTF-8?q?SCRUM-41:=20integra=C3=A7=C3=A3o=20relatori?= =?UTF-8?q?o=20e=20dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants/api.ts b/constants/api.ts index b85468d..91a4616 100644 --- a/constants/api.ts +++ b/constants/api.ts @@ -1,2 +1,2 @@ export const API_URL = - process.env.EXPO_PUBLIC_API_URL ?? 'http://localhost:8000'; + process.env.EXPO_PUBLIC_API_URL ?? 'https://mandaca-backend-production.onrender.com';