diff --git a/src/app/featuredToursPage/[tourId]/page.tsx b/src/app/featuredToursPage/[tourId]/page.tsx new file mode 100644 index 00000000..dd1f5cbf --- /dev/null +++ b/src/app/featuredToursPage/[tourId]/page.tsx @@ -0,0 +1,137 @@ +'use client'; + +import React, { useEffect, useState } from 'react'; +import Image from 'next/image'; +import Link from 'next/link'; + +import { fetchAllDisplays } from '../../../supabase/displays/queries'; +import { fetchMedia } from '../../../supabase/media/queries'; +import { fetchTour } from '../../../supabase/tours/queries'; +import { fetchTourDisplays } from '../../../supabase/tour_displays/queries'; +import { fetchTourMedia } from '../../../supabase/tour_media/queries'; +import { + DisplayRow, + MediaRow, + TourDisplaysRow, + TourMediaRow, + TourRow, +} from '../../../types/types'; + +import BackButton from '../../../components/userComponents/BackButton/BackButton'; +import NavBar from '../../../components/userComponents/navBar/navBar'; + +/** + * @param params - + * @param params.params - + * @param params.params.tourId - The tour ID + * @returns The tour start page + */ +export default function TourStartPage({ + params, +}: { + params: { tourId: string }; +}) { + const [tour, setTour] = useState(); + const [tourDisplays, setTourDisplays] = useState([]); + const [displays, setDisplays] = useState([]); + const [tourMedia, setTourMedia] = useState([]); + const [media, setMedia] = useState([]); + + useEffect(() => { + // Fetch tour, tour displays, and tour media data + const fetchData = async () => { + const fetchedTour = await fetchTour(params.tourId); + setTour(fetchedTour); + const fetchedTourDisplays = await fetchTourDisplays(params.tourId); + setTourDisplays(fetchedTourDisplays); + const fetchedDisplays = await fetchAllDisplays(); + setDisplays(fetchedDisplays); + const fetchedTourMedia = await fetchTourMedia(params.tourId); + setTourMedia(fetchedTourMedia); + const fetchedMedia = await fetchMedia(); + setMedia(fetchedMedia); + }; + + fetchData(); + }, [params.tourId]); + + return ( + tour && ( +
+ + + + +
+ {media.length > 0 && ( + m.id === tourMedia[0]?.media_id)?.id} + src={media.find(m => m.id === tourMedia[0]?.media_id)?.url ?? ''} + alt={media.find(m => m.id === tourMedia[0]?.media_id)?.text ?? ''} + layout="fill" + objectFit="cover" + priority + /> + )} +
+ +
+
+
+

+ WELCOME TO +

+

+ {tour.name} +

+
+
+ +

+ Start Tour +

+ +
+
+ +

{tour.description}

+ +
+
+

+ In this tour +

+
+

+ {tour.stop_count} stops +

+
+
+
    + {tourDisplays.map(tourDisplay => ( +
  1. +

    + {tourDisplay.display_order != null + ? tourDisplay.display_order + 1 + : ''} + .{' '} + { + displays.find( + display => display.id === tourDisplay.display_id, + )?.title + } +

    +
  2. + ))} +
+
+
+
+ ) + ); +} diff --git a/src/app/featuredToursPage/[tourId]/tourEndPage/page.tsx b/src/app/featuredToursPage/[tourId]/tourEndPage/page.tsx new file mode 100644 index 00000000..e514f030 --- /dev/null +++ b/src/app/featuredToursPage/[tourId]/tourEndPage/page.tsx @@ -0,0 +1,142 @@ +'use client'; + +import Link from 'next/link'; +import React, { useEffect, useState } from 'react'; + +import NavBar from '../../../../components/userComponents/navBar/navBar'; +import { + MediaRow, + TourRow, + TourMediaRow, + TourDisplaysRow, +} from '../../../../types/types'; +import { fetchMedia } from '../../../../supabase/media/queries'; +import { fetchTour } from '../../../../supabase/tours/queries'; +import { fetchTourDisplays } from '../../../../supabase/tour_displays/queries'; +import { fetchTourMedia } from '../../../../supabase/tour_media/queries'; +import { + BackArrow, + Congratulations, + ExternalLinkIcon, +} from '../../../../../public/icons'; + +/** + * @param params - + * @param params.params - + * @param params.params.tourId - The tour ID + * @returns The tour end page + */ +export default function TourEndPage({ + params, +}: { + params: { tourId: string }; +}) { + const [media, setMedia] = useState([]); + const [tour, setTour] = useState(); + const [tourMedia, setTourMedia] = useState([]); + const [backLink, setBackLink] = useState( + `/featuredToursPage/${params.tourId}`, + ); + + useEffect(() => { + // Get tour + const getTour = async () => { + const fetchedTour = await fetchTour(params.tourId); + setTour(fetchedTour); + }; + + // Get tour media + const getTourMedia = async () => { + const fetchedTourMedia = await fetchTourMedia(params.tourId); + setTourMedia(fetchedTourMedia); + }; + + // Get media + const getMedia = async () => { + const fetchedMedia = await fetchMedia(); + setMedia(fetchedMedia); + }; + + /** + * @returns The link to the previous page. + */ + async function getBackLink() { + const tourDisplays: TourDisplaysRow[] = await fetchTourDisplays( + params.tourId, + ); + setBackLink( + `/featuredToursPage/${params.tourId}/${ + tourDisplays[tourDisplays.length - 1].display_id + }`, + ); + } + + getTour(); + getTourMedia(); + getMedia(); + getBackLink(); + }, [params.tourId]); + + return ( +
+ + + + + +
+
+
+
+ +

+ {`You've reached the end of this tour!`} +

+
+

+ Thanks for visiting {tour?.name}. +

+
+
+ +

+ Back to Virtual Tours +

+ +
+
+ +
+
+
+

Related Links

+
    + {tourMedia.map((tm, index) => ( +
  1. + m.id === tm.media_id)?.url ?? '-1'} + className="flex flex-col gap-1" + > +
    +

    + {media.find(m => m.id === tm.media_id)?.type} +

    + +
    +

    + {media.find(m => m.id === tm.media_id)?.title} +

    + + {index !== tourMedia.length - 1 && ( +
    + )} +
  2. + ))} +
+
+
+
+
+
+ ); +} diff --git a/src/app/featuredToursPage/page.tsx b/src/app/featuredToursPage/page.tsx new file mode 100644 index 00000000..28b7ac88 --- /dev/null +++ b/src/app/featuredToursPage/page.tsx @@ -0,0 +1,122 @@ +'use client'; + +import React, { useEffect, useState } from 'react'; +import Image from 'next/image'; +import Link from 'next/link'; + +import { fetchAllTours } from '../../supabase/tours/queries'; +import { fetchMedia } from '../../supabase/media/queries'; +import { fetchAllTourMedia } from '../../supabase/tour_media/queries'; +import { TourRow, MediaRow, TourMediaRow } from '../../types/types'; + +import { BackArrow } from '../../../public/icons'; +import NavBar from '../../components/userComponents/navBar/navBar'; +import NextButton from '../../components/userComponents/NextButton/NextButton'; + +/** + * @returns The featured tours page. + */ +export default function FeaturedToursPage() { + const [tours, setTours] = useState([]); + const [allTourMedia, setAllTourMedia] = useState([]); + const [media, setMedia] = useState([]); + + useEffect(() => { + // Fetch tour and tour media data + const fetchData = async () => { + const fetchedTours = await fetchAllTours(); + setTours(fetchedTours); + const fetchedAllTourMedia = await fetchAllTourMedia(); + setAllTourMedia(fetchedAllTourMedia); + const fetchedMedia = await fetchMedia(); + setMedia(fetchedMedia); + }; + + fetchData(); + }, []); + + return ( +
+ + +
+
+ + + +
+ +

+ Virtual Tours +

+

+ Take a virtual sneak peek behind the scenes at our Wildlife Care + Center. Here you will find outside enclosures where sick, injured, and + orphaned wildlife recuperate and acclimate before being released back + into their natural habitat. Choose your favorite animal to start the + tour. +

+ +
    + {tours.map( + tour => + tour.spotlight === false && ( +
  • + +
    + {media.length > 0 && ( + + m.id === + allTourMedia.find(tm => tm.tour_id === tour.id) + ?.media_id, + )?.url ?? '' + } + alt={ + media.find( + m => + m.id === + allTourMedia.find(tm => tm.tour_id === tour.id) + ?.media_id, + )?.text ?? '' + } + layout="fill" + objectFit="cover" + priority + /> + )} +
    +

    + {tour.stop_count} stops +

    +
    +

    + {tour.name} +

    +
    + +
    +
    +
    +
    + +
  • + ), + )} +
+
+
+ ); +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 26300222..e5f2f4e8 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,6 +3,7 @@ import type { Metadata } from 'next'; import { Inter, Lato } from 'next/font/google'; import React from 'react'; import { WindowWidthProvider } from '../context/WindowWidthContext/WindowWidthContext'; +import NavBar from '../components/userComponents/navBar/navBar'; const inter = Inter({ subsets: ['latin'] }); @@ -26,19 +27,23 @@ export default function RootLayout({ return ( + - + /> */}