Skip to content

Commit

Permalink
hotfix: annoucement times reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
zacktraczyk committed Jan 20, 2024
1 parent 5e08c90 commit d14640c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/components/Announcements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const Announcements: React.FC = () => {
{announcements && announcements.length > 0 ? (
<ul className='flex h-80 grow flex-col gap-5 overflow-y-scroll rounded py-5 md:bg-[#D9D9D91A] md:p-10'>
{announcements
.toReversed()
.slice()
.reverse()
.map((announcement: Announcement, key: number) => {
return (
<li className='border-b border-[#D7D7D7]' key={key}>
Expand Down
39 changes: 22 additions & 17 deletions src/utils/apis/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,34 +518,39 @@ export const inviteTeamMember = async (user: User, email: string) => {
if (email == user.email)
throw new Error("Cannot invite yourself to the team")



let otherUserDocRef = doc(db, `users/${email}/user_items/team`)
let otherUserDocSnap = await getDoc(otherUserDocRef)

const otherUserRoleDocRef = doc(db, `users/${email}/user_items/role`)
const otherUserRoleDocSnap = await getDoc(otherUserRoleDocRef)
const role = otherUserRoleDocSnap.data()?.role.toLowerCase()

if (!otherUserRoleDocSnap.exists())
{throw new Error("Invited user does not exist")
if (!otherUserRoleDocSnap.exists()) {
throw new Error("Invited user does not exist")
}
if (!otherUserDocSnap.exists()) {
await setDoc(otherUserDocRef, {
invites: [],
teamLeader: "",
teamName: "",
}, {merge:true})
await setDoc(
otherUserDocRef,
{
invites: [],
teamLeader: "",
teamName: "",
},
{ merge: true }
)

otherUserDocRef = doc(db, `users/${email}/user_items/team`)
otherUserDocSnap = await getDoc(otherUserDocRef)
otherUserDocRef = doc(db, `users/${email}/user_items/team`)
otherUserDocSnap = await getDoc(otherUserDocRef)
}
if (otherUserDocSnap.data()?.teamName === userTeamName) {
throw new Error("User is already on the team")
}
if (otherUserDocSnap.data()?.teamName !== "") {
throw new Error("Invited user is already on a team")
}
if (role !== "hacker") {
throw new Error("Invited user is not a participant of the hackathon")
}
if (otherUserDocSnap.data()?.teamName === userTeamName)
{throw new Error("User is already on the team")}
if (otherUserDocSnap.data()?.teamName !== "")
{ throw new Error("Invited user is already on a team")}
if (role !== "hacker")
{throw new Error("Invited user is not a participant of the hackathon")}

const teamName = userDocSnap.data()?.teamName

Expand Down

0 comments on commit d14640c

Please sign in to comment.