Skip to content

Commit

Permalink
Fix: editarEvento não atualizava o objeto, notificação e styles
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoFacB committed Dec 8, 2024
1 parent fef905e commit afa7393
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
11 changes: 3 additions & 8 deletions src/app/private/pages/cadastrarEvento.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,9 @@ import { Try } from "expo-router/build/views/Try";
},
header: {
backgroundColor: "#2CCDB5",
width: "100%",
flexDirection: "row",
justifyContent: "space-between",
paddingTop: 10,
paddingBottom: 10,
alignItems: "center",
paddingHorizontal: 15,
marginBottom: 15,
height: 60,
flexDirection: "row",
alignItems: "center",
},
tituloheader: {
fontWeight: "bold",
Expand Down
32 changes: 24 additions & 8 deletions src/app/private/pages/editarEvento.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ import {

const eventoCollection = database.get('evento') as Collection<Evento>;
await database.write(async () => {
const evento = await eventoCollection.find(params.id);
const evento = await eventoCollection.find(params.id);

await evento.update(() => {
evento.titulo = titulo;
evento.local = local;
evento.dataHora = new Date(getDateIsoString(data, hora));
evento.descricao = descricao;
evento.notificacao = notificacao;
Expand All @@ -98,9 +98,16 @@ import {
text1: "Sucesso!",
text2: "Evento atualizado com sucesso",
});

router.back();

} catch (err) {
console.log("Erro ao atualizar evento:", err);
Toast.show({
type: "error",
text1: "Erro!",
text2: "Erro ao atualizar evento",
});
} finally {
setShowLoading(false);
}
Expand Down Expand Up @@ -148,7 +155,7 @@ import {
<View style={styles.Evento}>
<TextInput
value={titulo}
onChangeText={setTitulo}
onChangeText={(NewTitulo) => {setTitulo(NewTitulo);}}
placeholder="Título do evento"
style={styles.inputTitulo}
/>
Expand Down Expand Up @@ -180,19 +187,28 @@ import {
<Text style={styles.repete}>Evento no(s) dia(s)</Text>
</View>

<View style={styles.notificacaoContainer}>
<Switch
trackColor={{ false: "#767577", true: "#2CCDB5" }}
onValueChange={setNotificacao}
value={notificacao}
/>
<Text style={styles.notificacaoText}>Ativar notificação</Text>
</View>

<View style={styles.weekDays}>
<WeekDays dias={dias} callbackFn={setDias} />
</View>
<TextInput
value={descricao}
onChangeText={setDescricao}
onChangeText={(NewDescription) => {setDescricao(NewDescription);}}
placeholder="Descrição"
style={styles.textInputDescription}
multiline={true}
numberOfLines={4}
/>
<ErrorMessage show={showErrors} text={erros.descricao} />

<Switch value={notificacao} onValueChange={setNotificacao} />


<View style={styles.linkButton}>
<CustomButton
Expand Down Expand Up @@ -306,7 +322,7 @@ import {
weekDays: {
flexDirection: "row",
marginTop: 15,
marginBottom: 30,
marginBottom: 15,
},
iconDesciption: {
width: "10%",
Expand Down Expand Up @@ -351,7 +367,7 @@ import {
alignItems: "center",
width: "100%",
fontWeight: "700",
marginBottom: 25,
marginBottom: 10,
},
notificacaoText: {
fontWeight: "600",
Expand Down

0 comments on commit afa7393

Please sign in to comment.