Skip to content

Commit

Permalink
Merge pull request #13 from revanthkumarJ/main
Browse files Browse the repository at this point in the history
fix: Time Datatype in send Notice
  • Loading branch information
Nagarjuna0033 authored Dec 27, 2024
2 parents 70726df + a7c4a86 commit 9dc582e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/pages/SendNotice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -139,7 +149,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 }}
/>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getDesignation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export const getDesignation=(base)=>{
return "Director"
}
else
return "Mess Coordinator"
return "Admin"
}

0 comments on commit 9dc582e

Please sign in to comment.