You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import { initializeApp } from "firebase/app";
|
|
|
|
|
import { getFirestore, doc, setDoc } from "firebase/firestore";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const firebaseConfig = {
|
|
|
|
|
apiKey: "AIzaSyD1VzUKXt0JskwyfjfIAbdROzPNB3fTIw0",
|
|
|
|
|
authDomain: "uc-24070-thegreattipsy.firebaseapp.com",
|
|
|
|
|
projectId: "uc-24070-thegreattipsy",
|
|
|
|
|
storageBucket: "uc-24070-thegreattipsy.firebasestorage.app",
|
|
|
|
|
messagingSenderId: "772804793020",
|
|
|
|
|
appId: "1:772804793020:web:258003100900c20e0fb6b9",
|
|
|
|
|
measurementId: "G-1CRHMJY4L9"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CollectionName="records";
|
|
|
|
|
|
|
|
|
|
// Initialize Firebase
|
|
|
|
|
const app = initializeApp(firebaseConfig);
|
|
|
|
|
|
|
|
|
|
export async function updateUser(id, data){
|
|
|
|
|
if(!id || !data) {
|
|
|
|
|
console.error("Invalid id or data for updateUser");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try{
|
|
|
|
|
const db = getFirestore(app);
|
|
|
|
|
await setDoc(doc(db, CollectionName, id), data, { merge: true });
|
|
|
|
|
|
|
|
|
|
console.log("Document successfully written!");
|
|
|
|
|
|
|
|
|
|
}catch(error){
|
|
|
|
|
console.error("Error writing document: ", error);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|