Skip to content

Commit

Permalink
Merge branch 'justinxue/phs-49-exhibit-page' of github.com:calbluepri…
Browse files Browse the repository at this point in the history
…nt/phs into justinxue/phs-49-exhibit-page
  • Loading branch information
jxmoose committed Apr 10, 2024
2 parents 8e398fe + fce6823 commit d3b99a9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
27 changes: 0 additions & 27 deletions src/components/userComponents/SiteMap/DisplayPreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,53 +52,34 @@ function DisplayPreviewCard({
let imageUrl = '';
let displayName = '';

if ('name' in tour) {

let imageUrl = '';
let displayName = '';

if ('name' in tour) {
// Fetch images for a tour
const images = await fetchImagesForTour(tour.id);
if (images && images.length > 0) {
imageUrl = images[0].url;
imageUrl = images[0].url;
}
displayName = tour.name;
displayName = tour.name;
} else {
// Handle as an ExhibitRow
const imageObj = await fetchExhibitImage(tour.id);
const imageObj = await fetchExhibitImage(tour.id);
if (imageObj) {
imageUrl = imageObj.image;
imageUrl = imageObj.image;
}
displayName = tour.title;
displayName = tour.title;
}


// Set state variables
setPreviewImage(imageUrl);
setname1(displayName);
setLoading(false);
};


fetchDetails();
}, [tour]);


/** route this to spotlights */

return (
<div className="flex flex-col items-center justify-center w-[25rem] h-[8.25rem] max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg mx-auto p-4 pb-[2.87rem] pr-[1.19rem] pl-[1.19rem] rounded-md">
<div
className="flex flex-row items-center rounded-md overflow-hidden bg-ivory cursor-pointer w-full sm:w-4/4 md:w-5/5 lg:w-2/2 xl:w-5/5 flex-shrink-0 shadow-xl"
aria-hidden="true"
>
{!loading && (
<div className="flex flex-col items-center justify-center w-[25rem] h-[8.25rem] max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg mx-auto p-4 pb-[2.87rem] pr-[1.19rem] pl-[1.19rem] rounded-md">
<div
className="flex flex-row items-center rounded-md overflow-hidden bg-ivory cursor-pointer w-full sm:w-4/4 md:w-5/5 lg:w-2/2 xl:w-5/5 flex-shrink-0 shadow-xl"
Expand All @@ -109,7 +90,6 @@ function DisplayPreviewCard({
<Image
src={previewImage}
alt="placeholder"
alt="placeholder"
layout="fill"
objectFit="cover"
/>
Expand Down Expand Up @@ -154,24 +134,17 @@ function DisplayPreviewCard({
<h3 className="relative truncate text-asparagus pr-[0.31rem] pl-[0.75rem] pt-[0rem] uppercase font-light text-xs leading-normal">
{category}
</h3>
<h3 className="relative truncate font-medium font-lato text-night pr-[0.31rem] pl-[0.75rem] pt-[0.30rem] pb-[0rem] text-base leading-normal">
<h3 className="relative truncate font-medium font-lato text-night pr-[0.31rem] pl-[0.75rem] pt-[0.30rem] pb-[0rem] text-base leading-normal">
{name1}
</h3>


<h4 className="relative font-lato h-[2rem] pr-[0.31rem] pt-[0rem] pl-[0.75rem] pb-[2.4rem] text-shadow line-clamp-2 text-sm">
{description}
</h4>
</Link>
</div>
</div>
</div>
</div>
</Link>
</div>
</div>
</div>
</div>
);
}
Expand Down
26 changes: 0 additions & 26 deletions src/supabase/exhibits/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ export async function fetchExhibit(exhibitId: string): Promise<ExhibitRow> {
*/
export async function fetchExhibitImage(
exhibitId: string,
): Promise<{ image: string }> {
const { data, error } = await supabase
.from('exhibits')
.select('image')
.eq('id', exhibitId)
.single();
export async function fetchExhibitImage(
exhibitId: string,
): Promise<{ image: string }> {
const { data, error } = await supabase
.from('exhibits')
Expand All @@ -56,31 +48,20 @@ export async function fetchExhibitImage(
if (error) {
throw new Error(error.message);
}
if (error) {
throw new Error(error.message);
}

// Provide a default image URL if the image is null
const imageUrl =
data?.image ??
'https://buffer.com/cdn-cgi/image/w=1000,fit=contain,q=90,f=auto/library/content/images/size/w1200/2023/10/free-images.jpg'; // Adjust the default image path as needed
// Provide a default image URL if the image is null
const imageUrl =
data?.image ??
'https://buffer.com/cdn-cgi/image/w=1000,fit=contain,q=90,f=auto/library/content/images/size/w1200/2023/10/free-images.jpg'; // Adjust the default image path as needed

return { image: imageUrl };
return { image: imageUrl };
}

/**
* Inserts a single exhibit into the database.
* @param exhibitData - The exhibit to insert.
* @returns A promise that resolves to a ExhibitRow object.
*/
export async function insertExhibit(
exhibitData: ExhibitRow,
): Promise<ExhibitRow | null> {
export async function insertExhibit(
exhibitData: ExhibitRow,
): Promise<ExhibitRow | null> {
Expand All @@ -98,7 +79,6 @@ export async function insertExhibit(
*/
export async function updateExhibit(
newExhibitData: ExhibitRow,
newExhibitData: ExhibitRow,
): Promise<ExhibitRow | null> {
const { data, error } = await supabase
.from('exhibits')
Expand All @@ -115,9 +95,6 @@ export async function updateExhibit(
* @param exhibitData - The exhibit to upsert.
* @returns A promise that resolves to a ExhibitRow object.
*/
export async function upsertTour(
exhibitData: ExhibitRow,
): Promise<ExhibitRow | null> {
export async function upsertTour(
exhibitData: ExhibitRow,
): Promise<ExhibitRow | null> {
Expand All @@ -133,9 +110,6 @@ export async function upsertTour(
* @param exhibitId - The id of the exhibit to delete.
* @returns A promise that resolves to a ExhibitRow object.
*/
export async function deleteExhibit(
exhibitId: string,
): Promise<ExhibitRow | null> {
export async function deleteExhibit(
exhibitId: string,
): Promise<ExhibitRow | null> {
Expand Down

0 comments on commit d3b99a9

Please sign in to comment.