From d5239c50632e8dfb6e625098320055d6d0685382 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Fri, 27 Dec 2024 10:30:30 +0530 Subject: [PATCH] changed data type in notice board --- src/pages/SendNotice.js | 14 ++++++++++++-- src/utils/getDesignation.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pages/SendNotice.js b/src/pages/SendNotice.js index 4cab414..224c8b0 100644 --- a/src/pages/SendNotice.js +++ b/src/pages/SendNotice.js @@ -17,6 +17,15 @@ import { addAnnouncement } from "../api/putAnnouncement"; import { sendNotifications } from "../firebaseUtils/sendNotificatoins"; import axios from "axios"; import { getDesignation } from "../utils/getDesignation"; +import { Timestamp } from "firebase/firestore"; + +function getFormattedFirebaseTimestamp() { + const now = new Date(); + + const firebaseTimestamp = Timestamp.fromDate(now); + + return firebaseTimestamp; +} const theme = createTheme({ palette: { @@ -56,9 +65,10 @@ const SendNotice = () => { description: e.target.description.value, name: user.displayName || "N/A", designation: getDesignation(user.email.split("@")[0]), - time: new Date().toLocaleString("en-IN", { timeZone: "Asia/Kolkata" }), + time: getFormattedFirebaseTimestamp(), imageURL: user["photoURL"], }; + // console.log("Revanth",noticeData); const res = await addAnnouncement(noticeData); if (res.success) { toast.success("Announcement Sent Successfully"); @@ -138,7 +148,7 @@ const SendNotice = () => { fullWidth label="Designation" variant="outlined" - value={user.email.split("@")[0]} // Extract username from email + value={getDesignation(user.email.split("@")[0])} InputProps={{ readOnly: true }} /> diff --git a/src/utils/getDesignation.js b/src/utils/getDesignation.js index 7211472..55927b4 100644 --- a/src/utils/getDesignation.js +++ b/src/utils/getDesignation.js @@ -8,5 +8,5 @@ export const getDesignation=(base)=>{ return "Director" } else - return "Mess Coordinator" + return "Admin" } \ No newline at end of file