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/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';
diff --git a/services/reports.ts b/services/reports.ts
new file mode 100644
index 0000000..cffa10f
--- /dev/null
+++ b/services/reports.ts
@@ -0,0 +1,17 @@
+import { API_URL } from '@/constants/api'
+import { AIReportDetail, AIReportSummary } from '@/types/Report'
+
+export const generateReport = async (empresaId: string): Promise => {
+ const res = await fetch(`${API_URL}/reports/generate/${empresaId}`, { method: 'POST' })
+ return res.json()
+}
+
+export const getReportsByEnterprise = async (empresaId: string): Promise => {
+ const res = await fetch(`${API_URL}/reports/by-enterprise/${empresaId}`)
+ return res.json()
+}
+
+export const getReport = async (reportId: string): Promise => {
+ const res = await fetch(`${API_URL}/reports/${reportId}`)
+ return res.json()
+}
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
+}