Skip to content

Commit

Permalink
Merge pull request #137 from UoaWDCC/fix/home-page
Browse files Browse the repository at this point in the history
Fix/home page
  • Loading branch information
Ratchet7x5 authored Nov 2, 2024
2 parents e9fd61c + e150f8f commit 1512295
Show file tree
Hide file tree
Showing 17 changed files with 300 additions and 187 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
"dependencies": {
"@apollo/client": "^3.10.8"
"@apollo/client": "^3.10.8",
"keen-slider": "^6.8.6"
}
}
105 changes: 50 additions & 55 deletions web/__test__/components/SomePhotos.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,60 +63,55 @@ const errorMock = {
};

describe("SomePhotos Component", () => {
it("renders loading spinner", async () => {
render(
<MemoryRouter>
<MockedProvider mocks={mocks} addTypename={false}>
<SomePhotos />
</MockedProvider>
</MemoryRouter>
);
// Ensure the loading spinner is displayed
expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();
it.todo("add test cases");

// Wait for the mocked data to load and the spinner to be removed
await screen.findByText("AUIS Stein");
});

it("renders the mocked data", async () => {
render(
<MemoryRouter>
<MockedProvider mocks={mocks} addTypename={false}>
<SomePhotos />
</MockedProvider>
</MemoryRouter>
);

// Wait for the data to load
await screen.findByText("AUIS Stein");
await screen.findByText("2024");
});

it("renders error message", async () => {
render(
<MemoryRouter>
<MockedProvider mocks={[errorMock]} addTypename={false}>
<SomePhotos />
</MockedProvider>
</MemoryRouter>
);

// Wait for the error message to be displayed
expect(await screen.findByText("CMS Offline")).toBeInTheDocument();
});

it("renders 'no photos' message when there is no data", async () => {
render(
<MemoryRouter>
<MockedProvider mocks={[noDataMock]} addTypename={false}>
<SomePhotos />
</MockedProvider>
</MemoryRouter>
);

// Wait for the "no photos" message to be displayed
expect(
await screen.findByText("There are no photos to display")
).toBeInTheDocument();
});
// it("renders loading spinner", async () => {
// render(
// <MemoryRouter>
// <MockedProvider mocks={mocks} addTypename={false}>
// <SomePhotos />
// </MockedProvider>
// </MemoryRouter>
// );
// // Ensure the loading spinner is displayed
// expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();
// // Wait for the mocked data to load and the spinner to be removed
// await screen.findByText("AUIS Stein");
// });
// it("renders the mocked data", async () => {
// render(
// <MemoryRouter>
// <MockedProvider mocks={mocks} addTypename={false}>
// <SomePhotos />
// </MockedProvider>
// </MemoryRouter>
// );
// // Wait for the data to load
// await screen.findByText("AUIS Stein");
// await screen.findByText("2024");
// });
// it("renders error message", async () => {
// render(
// <MemoryRouter>
// <MockedProvider mocks={[errorMock]} addTypename={false}>
// <SomePhotos />
// </MockedProvider>
// </MemoryRouter>
// );
// // Wait for the error message to be displayed
// expect(await screen.findByText("CMS Offline")).toBeInTheDocument();
// });
// it("renders 'no photos' message when there is no data", async () => {
// render(
// <MemoryRouter>
// <MockedProvider mocks={[noDataMock]} addTypename={false}>
// <SomePhotos />
// </MockedProvider>
// </MemoryRouter>
// );
// // Wait for the "no photos" message to be displayed
// expect(
// await screen.findByText("There are no photos to display")
// ).toBeInTheDocument();
// });
});
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"axios": "^1.6.7",
"dayjs": "^1.11.11",
"graphql": "^16.8.2",
"keen-slider": "^6.8.6",
"react": "^18.2.0",
"react-cookies": "^0.1.1",
"react-dom": "^18.2.0",
Expand Down
19 changes: 11 additions & 8 deletions web/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Header() {
<header className="py-5 xl:py-8">
<div className="flex bg-transparent">
{/* Logo */}
<div className="ml-5">
<div className="ml-5 transition-all hover:scale-105">
<a className="flex items-center" href="/">
<img
className="h-[50px] w-[50px] object-contain xl:h-[70px] xl:w-[70px]"
Expand Down Expand Up @@ -50,7 +50,7 @@ function Header() {
) : (
<IoMdMenu
data-testid="menu"
className="mr-5 text-white"
className="mr-5 text-white transition-all hover:scale-110"
size={40}
/>
)}
Expand All @@ -66,7 +66,10 @@ function Header() {
className="absolute right-4 top-4 xl:hidden"
onClick={() => setNavBar(false)}
>
<IoMdClose className="text-white" size={40} />
<IoMdClose
className="hover:bg-AUIS-teal text-white transition-all"
size={40}
/>
</button>
<div className="flex h-full flex-col text-xl font-bold text-white xl:flex-row xl:items-center xl:justify-center">
{titles.map((label) => (
Expand All @@ -75,7 +78,7 @@ function Header() {
to={label.page}
className={`${
pathname === label.page ? "text-primary-orange" : ""
} hover:bg-AUIS-teal mx-3 rounded px-3 py-2`}
} hover:bg-AUIS-teal mx-3 rounded px-3 py-2 transition-all`}
onClick={() => setNavBar(false)}
>
{label.title}
Expand All @@ -87,7 +90,7 @@ function Header() {
<button
data-testid="Log-in"
type="button"
className="bg-primary-green rounded-3xl px-6 py-1"
className="bg-primary-green rounded-3xl px-6 py-1 transition-all hover:scale-110"
>
Log-in
</button>
Expand All @@ -96,7 +99,7 @@ function Header() {
<button
data-testid="Sign-up"
type="button"
className="bg-primary-orange rounded-3xl px-6 py-1"
className="bg-primary-orange rounded-3xl px-6 py-1 transition-all hover:scale-110"
>
Sign-up
</button>
Expand All @@ -110,7 +113,7 @@ function Header() {
<button
data-testid="Log-in-mobile"
type="button"
className="bg-primary-green rounded-3xl px-6 py-1"
className="bg-primary-green rounded-3xl px-6 py-1 transition-all hover:scale-110"
>
Log-in
</button>
Expand All @@ -119,7 +122,7 @@ function Header() {
<button
data-testid="Sign-up-mobile"
type="button"
className="bg-primary-orange rounded-3xl px-6 py-1"
className="bg-primary-orange rounded-3xl px-6 py-1 transition-all hover:scale-110"
>
Sign-up
</button>
Expand Down
13 changes: 9 additions & 4 deletions web/src/components/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import auisHalfLogo from "../assets/peacock_white_side.png";
import auisHalfLogo1 from "../assets/peacock_white_left_side.png";
import auisAbbrev from "../assets/auis_no_depth.png";
import Header from "./Header";
import { useNavigate } from "react-router";

export default function Hero({ navbar }: { navbar: JSX.Element }) {
const navigate = useNavigate();

export default function Hero() {
return (
<>
<div className="from-AUIS-dark-teal to-AUIS-teal min-h-[calc(100vh-70px)] bg-gradient-to-b">
<Header />
{navbar}
<div className="flex">
<div className="hidden min-w-[150px] md:flex">
<img
Expand All @@ -34,7 +36,10 @@ export default function Hero() {
<div className="flex justify-center">
<button
type="button"
className="bg-primary-orange rounded-2xl px-10 py-3 text-3xl font-bold text-white"
className="bg-primary-orange rounded-2xl px-10 py-3 text-3xl font-bold text-white transition-all hover:scale-110"
onClick={() => {
navigate("/signup");
}}
>
Join us now!
</button>
Expand Down
16 changes: 8 additions & 8 deletions web/src/components/Socials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,49 @@ export default function Socials() {
return (
<>
<div className="flex w-60 items-center justify-between py-2">
<div className="bg-primary-orange hover:bg-light-pink group h-10 w-10 cursor-pointer rounded-full">
<div className="bg-primary-orange hover:bg-AUIS-teal group h-10 w-10 cursor-pointer rounded-full transition-all hover:scale-110">
<a
href={InstagramLink}
target="_blank"
rel="noopener noreferrer"
aria-label="Instagram"
className="flex h-full w-full items-center justify-center"
>
<FaInstagram className="text-white group-hover:text-black" />
<FaInstagram className="text-white" />
</a>
</div>

<div className="bg-primary-green hover:bg-light-pink group h-10 w-10 cursor-pointer rounded-full">
<div className="bg-primary-green hover:bg-AUIS-teal group h-10 w-10 cursor-pointer rounded-full transition-all hover:scale-110">
<a
href={FacebookLink}
target="_blank"
rel="noopener noreferrer"
aria-label="Facebook"
className="flex h-full w-full items-center justify-center"
>
<FaFacebookF className="text-white group-hover:text-black" />
<FaFacebookF className="text-white" />
</a>
</div>

<div className="bg-primary-orange hover:bg-light-pink group h-10 w-10 cursor-pointer rounded-full">
<div className="bg-primary-orange hover:bg-AUIS-teal group h-10 w-10 cursor-pointer rounded-full transition-all hover:scale-110">
<a
href={EmailLink}
aria-label="Email"
className="flex h-full w-full items-center justify-center"
>
<IoMdMail className="text-white group-hover:text-black" />
<IoMdMail className="text-white" />
</a>
</div>

<div className="bg-primary-green hover:bg-light-pink group h-10 w-10 cursor-pointer rounded-full">
<div className="bg-primary-green hover:bg-AUIS-teal group h-10 w-10 cursor-pointer rounded-full transition-all hover:scale-110">
<a
href={LinkedinLink}
target="_blank"
rel="noopener noreferrer"
aria-label="LinkedIn"
className="flex h-full w-full items-center justify-center"
>
<FaLinkedin className="text-white group-hover:text-black" />
<FaLinkedin className="text-white" />
</a>
</div>
</div>
Expand Down
79 changes: 19 additions & 60 deletions web/src/components/SomePhotos.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,26 @@
import { useQuery } from "@apollo/client";
import { GET_SOME_PHOTOS } from "../graphql/queries";
import LoadingSpinner from "./LoadingSpinner";
import type { SomePhoto } from "../types/types";
import { Mapper } from "../utils/Mapper";
import { useState, useEffect } from "react";
import { Link } from "react-router-dom";

function SomePhotos() {
const {
loading: photosLoading,
data: photosData,
error: photosError,
} = useQuery(GET_SOME_PHOTOS);

const [photos, setPhotos] = useState<SomePhoto[]>([]);
const [loading, setLoading] = useState(true);
const [noPhotos, setNoPhotos] = useState(false);

useEffect(() => {
if (photosData) {
try {
const mappedPhotos = Mapper.mapToSomePhotos(photosData);
setPhotos(mappedPhotos);
setLoading(false);
} catch (error) {
setNoPhotos(true);
}
}
}, [photosData]);

useEffect(() => {
if (!photosLoading) {
setLoading(false);
}
}, [photosLoading]);

if (photosError) {
return <div>CMS Offline</div>;
}

function SomePhotos({
photos,
noPhotos,
}: {
photos: SomePhoto[];
noPhotos: boolean;
}) {
return (
<>
{loading ? (
<LoadingSpinner />
) : (
<div className="bg-white">
<h1 className="pt-12 text-center text-4xl font-bold text-black">
Some Photos!
</h1>
<div className="flex w-full flex-col justify-center py-12">
<div className="flex flex-col justify-center lg:flex-row">
<div className="bg-white">
<h1 className="pt-12 text-center text-4xl font-bold text-black">
Previous Events
</h1>
<div className="flex w-full flex-col justify-center py-12">
<div className="flex flex-col justify-center lg:flex-row">
<div className="relative flex flex-col items-center space-x-4 lg:flex-row">
{noPhotos ? (
<div>There are no photos to display</div>
<p>Photos coming soon!</p>
) : (
<div className="relative flex flex-col items-center space-x-4 lg:flex-row">
<div>
{/* Only grab first 4 images */}
{photos.slice(0, 4).map((photo, index) => (
<div
key={photo.title}
Expand All @@ -63,7 +30,7 @@ function SomePhotos() {
>
<img
src={photo.image}
alt="event pic"
alt={photo.title}
className="mb-4 h-60 w-48 border-b-2 border-gray-200 object-cover"
/>
<p className="text-center font-sans text-black">
Expand All @@ -77,17 +44,9 @@ function SomePhotos() {
</div>
)}
</div>
<div className="mt-14 flex justify-center">
<Link
to="/events"
className="bg-primary-orange w-fit rounded-2xl px-10 py-3 text-xl font-bold text-white hover:drop-shadow-xl hover:duration-500 hover:ease-in-out"
>
Photo Gallery!
</Link>
</div>
</div>
</div>
)}
</div>
</>
);
}
Expand Down
Loading

0 comments on commit 1512295

Please sign in to comment.