adicionar condóminos
This commit is contained in:
35
script.js
35
script.js
@@ -21,16 +21,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
function setupEventListeners() {
|
||||
|
||||
|
||||
document.getElementById('login-form').addEventListener('submit', handleLogin);
|
||||
|
||||
|
||||
|
||||
document.getElementById('form-morador').addEventListener('submit', saveMorador);
|
||||
document.getElementById('form-transacao').addEventListener('submit', saveTransacao);
|
||||
document.getElementById('form-ocorrencia').addEventListener('submit', saveOcorrencia);
|
||||
document.getElementById('form-aviso').addEventListener('submit', saveAviso);
|
||||
|
||||
|
||||
|
||||
if (sessionStorage.getItem('condoProUser')) {
|
||||
renderDashboard();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ function showToast(message, type = 'primary') {
|
||||
async function dbSelect(table, orderBy = null) {
|
||||
if (IS_MOCK) {
|
||||
const data = JSON.parse(localStorage.getItem(`condopro_${table}`)) || [];
|
||||
if (orderBy) {
|
||||
if (orderBy) {
|
||||
data.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
|
||||
}
|
||||
return { data, error: null };
|
||||
@@ -492,3 +492,30 @@ function exportPDF(tableId, filename) {
|
||||
}
|
||||
import { db } from "./firebase.js";
|
||||
import { collection, addDoc } from "https://www.gstatic.com/firebasejs/12.1.0/firebase-firestore.js";
|
||||
|
||||
import { db } from "./firebase.js";
|
||||
import { collection, addDoc } from "https://www.gstatic.com/firebasejs/12.1.0/firebase-firestore.js";
|
||||
|
||||
document.getElementById("btnAdicionar").onclick = () => {
|
||||
document.getElementById("formCondominio").style.display = "block";
|
||||
};
|
||||
|
||||
document.getElementById("guardar").onclick = async () => {
|
||||
const fracao = document.getElementById("fracao").value;
|
||||
const proprietario = document.getElementById("proprietario").value;
|
||||
const contacto = document.getElementById("contacto").value;
|
||||
|
||||
try {
|
||||
await addDoc(collection(db, "condominios"), {
|
||||
fracao,
|
||||
proprietario,
|
||||
contacto,
|
||||
estado: "Pago",
|
||||
divida: 0
|
||||
});
|
||||
|
||||
alert("Guardado com sucesso!");
|
||||
} catch (e) {
|
||||
alert("Erro: " + e.message);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user