Spaces:
Paused
Paused
File size: 4,103 Bytes
c62de68 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import { initializeApp } from "firebase/app";
import { getDatabase } from "firebase/database";
const firebaseConfig = {
apiKey: "AIzaSyDEHS1jJRVF1_UWpvZymM4y3Bw2P93s-BA",
authDomain: "caja-f2d3a.firebaseapp.com",
databaseURL: "https://caja-f2d3a-default-rtdb.firebaseio.com",
projectId: "caja-f2d3a",
storageBucket: "caja-f2d3a.firebasestorage.app",
messagingSenderId: "320783018594",
appId: "1:320783018594:web:a6e17e4cda5d7a03847f3b",
measurementId: "G-9V1SB7CTVD"
};
const app = initializeApp(firebaseConfig);
export const database = getDatabase(app);
// Seed exact sample clients & box opening data to Firebase directly from frontend if database is fresh
export const seedInitialFirebaseData = async () => {
try {
const res = await fetch("https://caja-f2d3a-default-rtdb.firebaseio.com/clients.json");
const data = await res.json();
if (!data) {
const clientsData = {
"c1": { id: "CRMDN97100230M800", curp: "CRMDN97100230M800", name: "DIANA DE LA CRUZ RAMIREZ", phone: "2322613408", address: "BENITO JUAREZ NUM. 418", municipio: "MARTINEZ DE LA TORRE", colonia: "VILLA INDEPENDENCIA", asesor: "RICARDO MARTINEZ ARRAZOLA", status: "Activo" },
"c2": { id: "UTSNDG98032030M200", curp: "UTSNDG98032030M200", name: "DIOGENES ADRIANA UTRERA SANTIAGO", phone: "2321486541", address: "SALVADOR ALLENDE NUM. 1009", municipio: "MARTINEZ DE LA TORRE", colonia: "EJIDAL", asesor: "RICARDO MARTINEZ ARRAZOLA", status: "Activo" },
"c3": { id: "PEAGJN90011614M600", curp: "PEAGJN90011614M600", name: "JOANA JAZMIN PEÑA AGUILERA", phone: "2321183247", address: "JUAN DE DIOS PEZA NUM 711, COL. SOLEDAD", municipio: "MARTINEZ DE LA TORRE", colonia: "SOLEDAD", asesor: "RUBEN ZAMUDIO ORTIZ", status: "Activo" },
"c4": { id: "HRCRJN97061430H800", curp: "HRCRJN97061430H800", name: "JUAN CARLOS HERNANDEZ CRUZ", phone: "2283061266", address: "AVENIDA C. ANTONIO SOTO Y GAMA COL EJIDAL", municipio: "MARTINEZ DE LA TORRE", colonia: "CONGRESO DE LA UNION", asesor: "RICARDO MARTINEZ ARRAZOLA", status: "Activo" },
"c5": { id: "FLHRLL89092830M900", curp: "FLHRLL89092830M900", name: "LLUNERY MARGARITA FLORES HERRERA", phone: "2321722088", address: "AVENIDA 2 DE OCTUBRE NUM 508", municipio: "MARTINEZ DE LA TORRE", colonia: "EJIDAL", asesor: "RICARDO MARTINEZ ARRAZOLA", status: "Activo" },
"c6": { id: "GMHDLC88021821M300", curp: "GMHDLC88021821M300", name: "LUCIA GOMEZ HIDALGO", phone: "2321258210", address: "20 DE NOVIEMBRE NUM. 16", municipio: "MARTINEZ DE LA TORRE", colonia: "VILLA INDEPENDENCIA", asesor: "RICARDO MARTINEZ ARRAZOLA", status: "Activo" },
"c7": { id: "HRPESN97081530M700", curp: "HRPESN97081530M700", name: "SENYAZET HERNANDEZ PEÑA", phone: "2322272117", address: "JUVENTINO ROSAS NUM. 200 VILLA INDEPENDENCIA", municipio: "MARTINEZ DE LA TORRE", colonia: "VILLA INDEPENDENCIA", asesor: "RUBEN ZAMUDIO ORTIZ", status: "Activo" }
};
await fetch("https://caja-f2d3a-default-rtdb.firebaseio.com/clients.json", {
method: "PUT",
body: JSON.stringify(clientsData)
});
}
const resApertura = await fetch("https://caja-f2d3a-default-rtdb.firebaseio.com/apertura_caja.json");
const dataApertura = await resApertura.json();
if (!dataApertura) {
const boxOpeningData = {
"b3": { id: "b3", concepto: "APERTURA DE CAJA", descripcion: "APERTURA DE CAJA DEL DIA 15 DE AGOSTO DE 2026", monto: 1.00, fecha: "15/08/2026 13:13" },
"b2": { id: "b2", concepto: "APERTURA DE CAJA", descripcion: "APERTURA DE CAJA DEL DIA 24 DE JUNIO DE 2026", monto: 11134.00, fecha: "24/06/2026 11:09" },
"b1": { id: "b1", concepto: "APERTURA DE CAJA", descripcion: "APERTURA DE CAJA DEL DIA 22 DE JUNIO DE 2026", monto: 18904.00, fecha: "22/06/2026 00:52" }
};
await fetch("https://caja-f2d3a-default-rtdb.firebaseio.com/apertura_caja.json", {
method: "PUT",
body: JSON.stringify(boxOpeningData)
});
}
} catch (e) {
console.error("Auto seeding error:", e);
}
};
seedInitialFirebaseData();
export default app;
|