Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 222 additions & 190 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"bootstrap-icons": "^1.11.3",
"cropperjs": "^1.6.2",
"dompurify": "^3.1.5",
"firebase": "^10.12.2",
"firebase": "^10.12.3",
"image-conversion": "^2.1.1",
"install": "^0.13.0",
"marked": "^13.0.1",
Expand Down
8 changes: 3 additions & 5 deletions src/components/EventDetails/EventDetails.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@
.card-image {
pointer-events: none;
border-radius: 10px 10px 10px 10px;
/* height: 450px; */
object-fit: cover;
}
@media (min-width: 1024px) {
.card_image {
.card-image {
height: 450px;
}
}
@media (min-width: 768px) {
.card_image {
.card-image {
height: 200px;
}
}

@media (max-width: 767px) {
.card_image {
.card-image {
height: 150px;
}
}
Expand Down
79 changes: 25 additions & 54 deletions src/components/EventDetails/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,24 @@ import {
Row,
Col,
Button,
Badge,
Card,
FormControl,
InputGroup,
Spinner,
} from "react-bootstrap";
import { Image as BootstrapImage } from "react-bootstrap";
import "./EventDetails.css";
import bannerImage from "../image_assets/bannerImage.png";
import { Link, useParams } from "react-router-dom";
import { useParams } from "react-router-dom";
import { ref, get, update } from "firebase/database";
import { Zoom, toast } from "react-toastify";
import { database } from "../../firebaseConf";
import PageTitle from "../../utils/PageTitle";
import moment from "moment";
import "./EventDetails.css";

const EventDetails = () => {
const { id } = useParams();
const userUid = localStorage.getItem("userUid");
const [isHost, setIsHost] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [banner_Image, setBannerImage] = useState(bannerImage);
const [banner_Image, setBannerImage] = useState("");
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [tags, setTags] = useState([]);
Expand All @@ -40,16 +36,14 @@ const EventDetails = () => {
);

useEffect(() => {
if (userUid == null) {
if (!userUid) {
window.location.href = "#/dashboard";
toast.warn("You are not signed in", { transition: Zoom });
}
const fetchData = async () => {
const eventRef = ref(database, "events/" + id);
const eventRef = ref(database, `events/${id}`);
const snapshot = await get(eventRef);
if (snapshot.exists()) {
const eventData = snapshot.val();

setBannerImage(eventData.banner);
setTitle(eventData.title);
setDescription(eventData.description);
Expand All @@ -65,35 +59,25 @@ const EventDetails = () => {
}
if (eventData.registrants) {
setRegisteredUsers(eventData.registrants.split(","));

if (
(!eventData.registrants.split(",").includes(userUid) ||
userUid == null) &&
!eventData.registrants.split(",").includes(userUid) &&
userUid !== eventData.host
) {
window.location.href = "#/dashboard";
toast.warn("You are not registered for this event", {
transition: Zoom,
});
}
}
if (eventData.googleMeetLink) {
setGoogleMeetLink(eventData.googleMeetLink);
}
setIsLoading(false);
} else {
toast.error("Event not found", { transition: Zoom });
}
};
fetchData();
}, [id, userUid]);

const addMeetingLink = () => {
const eventRef = ref(database, "events/" + id);
update(eventRef, {
googleMeetLink: googleMeetLink,
});
toast.success("Google Meet link added successfully", { transition: Zoom });
const eventRef = ref(database, `events/${id}`);
update(eventRef, { googleMeetLink });
};

return (
Expand All @@ -103,9 +87,7 @@ const EventDetails = () => {
{isLoading ? (
<div
className="d-flex justify-content-center align-items-center"
style={{
paddingTop: "9.5em",
}}
style={{ paddingTop: "9.5em" }}
>
<Spinner animation="border" />
</div>
Expand All @@ -118,7 +100,7 @@ const EventDetails = () => {
variant="top"
src={banner_Image}
alt="Event Header"
className="card-image"
className="card_image"
/>
<Card.Body>
<Card.Title>{title}</Card.Title>
Expand All @@ -137,7 +119,7 @@ const EventDetails = () => {
<Col>
Host:{" "}
<a
href={"#/profile/" + host}
href={`#/profile/${host}`}
className="link-primary"
>
{hostName}
Expand Down Expand Up @@ -168,40 +150,29 @@ const EventDetails = () => {
<Card.Body>
<div>
{isHost ? (
<>
<InputGroup className="mb-3">
<InputGroup.Text>
Google Meet link :
</InputGroup.Text>
<FormControl
type="text"
value={googleMeetLink}
onChange={(e) =>
setGoogleMeetLink(e.target.value)
}
/>
<Button
onClick={() => {
addMeetingLink();
}}
variant="primary"
>
Add Link
</Button>
</InputGroup>
</>
<InputGroup className="mb-3">
<InputGroup.Text>Google Meet link :</InputGroup.Text>
<FormControl
type="text"
value={googleMeetLink}
onChange={(e) => setGoogleMeetLink(e.target.value)}
/>
<Button onClick={addMeetingLink} variant="primary">
Add Link
</Button>
</InputGroup>
) : (
<>
<span>
Google Meet link :{" "}
{googleMeetLink ===
"Nothing yet, ask the host to add one" ? (
"Nothing yet, ask the host to add one"
googleMeetLink
) : (
<a href={googleMeetLink} className="link-primary">
{googleMeetLink}
</a>
)}
</>
</span>
)}
</div>
</Card.Body>
Expand Down
Loading