From 7ae6db563f4dae5933654958979ad38e628cbc69 Mon Sep 17 00:00:00 2001 From: jvopBR Date: Fri, 6 Dec 2024 21:47:02 -0300 Subject: [PATCH] Tela de evento funcional --- .gitignore | 42 ++++++++++++++++++++++- index.js | 8 +++++ metro.config.js | 7 ++++ package-lock.json | 8 +++-- src/app/components/CardEvento.tsx | 17 +++++++-- src/app/db/migrations.ts | 2 +- src/app/db/schema.ts | 2 +- src/app/private/pages/cadastrarEvento.tsx | 8 +++-- 8 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 index.js create mode 100644 metro.config.js diff --git a/.gitignore b/.gitignore index 56471116..c02fdd80 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,44 @@ ios android /.idea -/reports \ No newline at end of file +/reports +# @generated expo-cli sync-b5df6a44d8735348b729920a7406b633cfb74d4c +# The following patterns were generated by expo-cli + +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ + +# Native +*.orig.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo + +# @end expo-cli \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 00000000..1d6e981e --- /dev/null +++ b/index.js @@ -0,0 +1,8 @@ +import { registerRootComponent } from 'expo'; + +import App from './App'; + +// registerRootComponent calls AppRegistry.registerComponent('main', () => App); +// It also ensures that whether you load the app in Expo Go or in a native build, +// the environment is set up appropriately +registerRootComponent(App); diff --git a/metro.config.js b/metro.config.js new file mode 100644 index 00000000..07c9fce6 --- /dev/null +++ b/metro.config.js @@ -0,0 +1,7 @@ +// Learn more https://docs.expo.io/guides/customizing-metro +const { getDefaultConfig } = require('expo/metro-config'); + +/** @type {import('expo/metro-config').MetroConfig} */ +const config = getDefaultConfig(__dirname); + +module.exports = config; diff --git a/package-lock.json b/package-lock.json index f26d3778..8bd50bb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17934,9 +17934,10 @@ "dev": true }, "node_modules/moment": { - "version": "2.29.4", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", - "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "license": "MIT", "engines": { "node": "*" } @@ -19434,6 +19435,7 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "license": "MIT", "dependencies": { "loose-envify": "^1.1.0" }, diff --git a/src/app/components/CardEvento.tsx b/src/app/components/CardEvento.tsx index fa75a359..e873dfcb 100644 --- a/src/app/components/CardEvento.tsx +++ b/src/app/components/CardEvento.tsx @@ -3,6 +3,7 @@ import { View, Text, StyleSheet, Pressable, Dimensions } from "react-native"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { router } from "expo-router"; import { IEvento } from "../interfaces/evento.interface"; +import { updateEvento } from "../services/evento.service" import database from "../db"; import { Collection } from "@nozbe/watermelondb"; import Evento from "../model/Evento"; @@ -13,9 +14,19 @@ interface IProps { date: Date; } -export default function CardEvento({ item, index }: IProps) { - const [nameIcon, setNameIcon] = useState("calendar-outline"); - const [time, setTime] = useState(""); + export default function CardEvento({ item, index, date }: IProps) { + const dateString = date.toLocaleString("pt-BR", { + year: "numeric", + month: "2-digit", + day: "2-digit", + }); + + const [nameIcon, setnameIcon] = useState("view-grid-outline"); + const [check, setCheck] = useState(false); + const [time, setTime] = useState(""); + const [token, setToken] = useState(""); + const [timer, setTimer] = useState(null); + const editar = () => { const evento = item as unknown as Evento; diff --git a/src/app/db/migrations.ts b/src/app/db/migrations.ts index 18473b5b..1c83130b 100644 --- a/src/app/db/migrations.ts +++ b/src/app/db/migrations.ts @@ -5,7 +5,7 @@ import { tableSchema } from '@nozbe/watermelondb'; export default schemaMigrations({ migrations: [ { - toVersion: 3, + toVersion: 8, steps: [ // Passo para adicionar as colunas à tabela 'usuario' se elas ainda não existirem { diff --git a/src/app/db/schema.ts b/src/app/db/schema.ts index 437b94ce..adf37b06 100644 --- a/src/app/db/schema.ts +++ b/src/app/db/schema.ts @@ -2,7 +2,7 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb'; export default appSchema({ - version: 7, + version: 8, tables: [ tableSchema({ name: 'usuario', diff --git a/src/app/private/pages/cadastrarEvento.tsx b/src/app/private/pages/cadastrarEvento.tsx index a19273a1..84352241 100644 --- a/src/app/private/pages/cadastrarEvento.tsx +++ b/src/app/private/pages/cadastrarEvento.tsx @@ -28,6 +28,7 @@ import { import { handleNotificacao, validateFields } from "../../shared/helpers/useNotification"; import CustomButton from "../../components/CustomButton"; import WeekDays from "../../components/weekDay"; +import { Try } from "expo-router/build/views/Try"; interface IErrors { titulo?: string; @@ -94,7 +95,7 @@ import { }; const salvarNoBancoLocal = async () => { - const eventoCollection = database.get("evento") as Collection; + const eventoCollection = database.get('evento') as Collection; await database.write(async () => { await eventoCollection.create((evento) => { @@ -107,7 +108,9 @@ import { evento.idIdoso = String(idoso?.id); }); }); - + console.log("Estado atual do banco:", await eventoCollection.query().fetch()); + } + const salvar = async () => { if (Object.keys(erros).length > 0) { setShowErrors(true); @@ -399,4 +402,3 @@ import { marginBottom: 30, }, }); -} \ No newline at end of file