Skip to content

Commit

Permalink
CadastrarEvento base
Browse files Browse the repository at this point in the history
  • Loading branch information
jvopBR committed Dec 6, 2024
1 parent 9aae55a commit 8dcee6f
Show file tree
Hide file tree
Showing 10 changed files with 610 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ docker compose -f docker-compose.test.yml up
![IOS](https://github.com/fga-eps-mds/2023-2-GEROcuidado-Front/assets/51385738/1a9562d5-dec5-485d-999a-59f2f16e2427)
### Android
![Android](https://github.com/fga-eps-mds/2023-2-GEROcuidado-Front/assets/51385738/9a6d23c0-2f88-42de-ac26-719e6faa9fd3)
### 📝 Notes
### 📝 Notes.

- [Expo Router: Docs](https://expo.github.io/router)
- [Expo Router: Repo](https://github.com/expo/router)
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@
"expo": "^51.0.39",
"expo-build-properties": "~0.12.5",
"expo-constants": "~16.0.2",
"expo-dev-client": "~4.0.23",
"expo-dev-client": "~4.0.29",
"expo-device": "~6.0.2",
"expo-image": "~1.12.13",
"expo-doctor": "^1.12.4",
"expo-image": "~1.13.0",
"expo-image-picker": "~15.0.7",
"expo-jwt": "^1.6.5",
"expo-linking": "~6.3.1",
"expo-notifications": "~0.28.15",
"expo-router": "^3.5.23",
"expo-splash-screen": "~0.27.5",
"expo-notifications": "~0.28.19",
"expo-router": "~3.5.24",
"expo-splash-screen": "~0.27.7",
"expo-status-bar": "~1.12.1",
"expo-updates": "~0.25.22",
"expo-updates": "~0.25.27",
"jest": "^29.2.1",
"jest-expo": "~51.0.3",
"jest-expo": "~51.0.4",
"jest-mock-extended": "^3.0.5",
"jest-sonar": "^0.2.16",
"jest-sonar-reporter": "^2.0.0",
Expand All @@ -53,6 +54,7 @@
"react-native-gesture-handler": "~2.16.1",
"react-native-mask-input": "^1.2.3",
"react-native-paper": "^5.11.2",
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-swiper": "^1.6.0",
Expand Down
3 changes: 2 additions & 1 deletion src/app/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Idoso from '../model/Idoso'
import Rotina from '../model/Rotina'
import Metrica from '../model/Metrica'
import ValorMetrica from '../model/ValorMetrica'
import Evento from '../model/Evento'
// import Post from './model/Post' // ⬅️ You'll import your Models here

// First, create the adapter to the underlying database:
Expand All @@ -31,7 +32,7 @@ const database = new Database({
adapter,
modelClasses: [
// Post, // ⬅️ You'll add Models to Watermelon here
Usuario, Idoso, Rotina, Metrica, ValorMetrica
Usuario, Idoso, Rotina, Metrica, ValorMetrica, Evento
],
});

Expand Down
12 changes: 9 additions & 3 deletions src/app/db/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ export default schemaMigrations({
{
type: 'create_table',
schema: tableSchema({
name: 'valor_metrica',
name: 'evento',
columns: [
{ name: 'metrica_id', type: 'string', isIndexed: true },
{ name: 'valor', type: 'string' },
{ name: 'titulo', type: 'string' },
{ name: 'descricao', type: 'string' },
{ name: 'categoria', type: 'string' },
{ name: 'dataHora', type: 'number' },
{ name: 'notificacao', type: 'boolean' },
{ name: 'token', type: 'string' },
{ name: 'idoso_id', type: 'string', isIndexed: true },
{ name: 'created_at', type: 'number' },
{ name: 'updated_at', type: 'number' },
],
}),
},
Expand Down
18 changes: 16 additions & 2 deletions src/app/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,19 @@ export default appSchema({
{ name: 'updated_at', type: 'number' },
],
}),
],
});
tableSchema({
name: 'evento',
columns: [
{ name: 'titulo', type: 'string' },
{ name: 'descricao', type: 'string' },
{ name: 'categoria', type: 'string' },
{ name: 'dataHora', type: 'number' },
{ name: 'notificacao', type: 'boolean' },
{ name: 'token', type: 'string' },
{ name: 'idoso_id', type: 'string', isIndexed: true },
{ name: 'created_at', type: 'number' },
{ name: 'updated_at', type: 'number' },
],
}),
],
});
4 changes: 3 additions & 1 deletion src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { Image, StyleSheet, Text, View } from "react-native";

import LinkButton from "./components/LinkButton";
import React from "react";
import 'react-native-gesture-handler';
import Reanimated from 'react-native-reanimated';

export default function Home() {
return (
<View style={styles.center}>
<Image source={require("../../assets/logo.png")} />
<Text style={styles.titulo}> Seja um GEROcuidador! </Text>
<LinkButton title="Acessar Fórum" href="/private/tabs/forum" />
<LinkButton title="Login" href="/public/login" />
<LinkButton title="Login" href="/public/login"/>
<LinkButton
title="Cadastre-se"
backgroundColor="#B47B9D"
Expand Down
39 changes: 39 additions & 0 deletions src/app/interfaces/evento.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export interface IEvento {
id: number;
titulo: string;
descricao: string;
dataHora: string;
categoria: string;
local: string;
participantes: string[];
createdAt: string;
updatedAt: string;
}

export interface IEventoBody {
titulo: string;
descricao: string;
dataHora: string;
categoria: string;
local: string;
participantes: string[];
}

export interface IEventoFilter {
titulo?: string;
categoria?: string;
dataHora?: string;
local?: string;
}

export interface IOrder {
field: string;
direction: 'asc' | 'desc';
}

export interface IResponse<T> {
status: string;
message: string;
data: T;
}

26 changes: 26 additions & 0 deletions src/app/model/Evento.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Model } from "@nozbe/watermelondb";
import { field, text, date, readonly, json, relation } from "@nozbe/watermelondb/decorators";
import Idoso from "./Idoso";

const sanitizeStringArray = (rawParticipantes: any): string[] => {
return Array.isArray(rawParticipantes) ? rawParticipantes.map(String) : [];
};

export default class Evento extends Model {
static table = 'evento';

@text('titulo') titulo!: string;
@text('descricao') descricao!: string;
@date('dataHora') dataHora!: Date;
@text('categoria') categoria!: string;
@text('local') local!: string;
@json('participantes', sanitizeStringArray) participantes!: string[];

@readonly @date('created_at') createdAt!: Date;
@readonly @date('updated_at') updatedAt!: Date;

@relation('idoso', 'idoso_id') idoso!: Idoso;
token: string | undefined;
notificacao!: boolean;
idIdoso: string | undefined;
}
Loading

0 comments on commit 8dcee6f

Please sign in to comment.