Skip to content

Commit

Permalink
Tela de evento funcional
Browse files Browse the repository at this point in the history
  • Loading branch information
jvopBR committed Dec 7, 2024
1 parent 9cb28e7 commit 7ae6db5
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 12 deletions.
42 changes: 41 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,44 @@ ios
android

/.idea
/reports
/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
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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);
7 changes: 7 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/app/components/CardEvento.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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<string>("");
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<string>("");
const [token, setToken] = useState<string>("");
const [timer, setTimer] = useState<NodeJS.Timeout | null>(null);


const editar = () => {
const evento = item as unknown as Evento;
Expand Down
2 changes: 1 addition & 1 deletion src/app/db/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb';


export default appSchema({
version: 7,
version: 8,
tables: [
tableSchema({
name: 'usuario',
Expand Down
8 changes: 5 additions & 3 deletions src/app/private/pages/cadastrarEvento.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,7 +95,7 @@ import {
};

const salvarNoBancoLocal = async () => {
const eventoCollection = database.get("evento") as Collection<Evento>;
const eventoCollection = database.get('evento') as Collection<Evento>;

await database.write(async () => {
await eventoCollection.create((evento) => {
Expand All @@ -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);
Expand Down Expand Up @@ -399,4 +402,3 @@ import {
marginBottom: 30,
},
});
}

0 comments on commit 7ae6db5

Please sign in to comment.