Skip to content

Commit

Permalink
Merge branch 'justinxue/phs-42-news-feed-backend' of github.com:calbl…
Browse files Browse the repository at this point in the history
…ueprint/phs into justinxue/phs-42-news-feed-backend
  • Loading branch information
jxmoose committed Mar 17, 2024
2 parents b1cf291 + ed4efd0 commit 19dbbbe
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/newsFeedPage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function BackButton() {
}

/**
* @returns The news feed page
* @returns news feed page
*/
function App() {
const [news, setNews] = useState<NewsRow[]>([]);
Expand Down
24 changes: 24 additions & 0 deletions src/app/spotlightPage/[spotlightId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import {
fetchDisplayfromSpotlight,
fetchRelatedSpotlightsfromSpotlightId,
} from '../../../supabase/tour_displays/queries';
import {
fetchDisplayfromSpotlight,
fetchRelatedSpotlightsfromSpotlightId,
} from '../../../supabase/tour_displays/queries';

/**
* @param -.params
Expand Down Expand Up @@ -38,6 +42,7 @@ export default function Page({ params }: { params: { spotlightId: string } }) {
const [displays, setDisplays] = useState<DisplayRow[]>([]);
const [displays, setDisplays] = useState<DisplayRow[]>([]);

const [relatedSpolights, setRelatedSpotlight] = useState<TourRow[]>([]);
const [relatedSpolights, setRelatedSpotlight] = useState<TourRow[]>([]);

useEffect(() => {
Expand All @@ -58,6 +63,8 @@ export default function Page({ params }: { params: { spotlightId: string } }) {
const responseDataForDisplays: DisplayRow[] =
await fetchDisplayfromSpotlight(params.spotlightId);
setDisplays(responseDataForDisplays);
const responseDataForRelatedSpotlights: TourRow[] =
await fetchRelatedSpotlightsfromSpotlightId(params.spotlightId);
const responseDataForRelatedSpotlights: TourRow[] =
await fetchRelatedSpotlightsfromSpotlightId(params.spotlightId);
setRelatedSpotlight(responseDataForRelatedSpotlights);
Expand Down Expand Up @@ -149,6 +156,23 @@ export default function Page({ params }: { params: { spotlightId: string } }) {
</li>
))}
</ul>
{relatedSpolights.map(otherSpotlight => (
<li
className="pl-[18px] w-[162px] overflow-x-auto"
key={otherSpotlight.id}
>
<Link href={`/spotlightPage/${spotlight.id}`}>
<div className="bg-[#386131] h-[169px] rounded-2xl p-[18px] flex flex-col" />
<h4 className="text-black font-Lato text-20 font-bold mt-2">
{otherSpotlight.name}
</h4>
<h2 className="text-gray font-Lato text-sm font-normal">
{otherSpotlight.description}
</h2>
</Link>
</li>
))}
</ul>
</div>
);
}
Expand Down
7 changes: 7 additions & 0 deletions src/supabase/tour_displays/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function fetchAllTourDisplays(): Promise<TourDisplaysRow[]> {
}

/**
*
*
*
* @param tourId - an id from the tours table
Expand All @@ -41,6 +42,9 @@ export async function fetchMatchingTourDisplayIdsfromSpotlight(tourId: string) {
);
}
const displayIds = data.map(item => item.display_id);
console.log('hello?');
const displayIds = data.map(item => item.display_id);
console.log('hello?');
return displayIds;
}

Expand All @@ -49,6 +53,9 @@ export async function fetchMatchingTourDisplayIdsfromSpotlight(tourId: string) {
* @returns given a spotlight ID, get all the displays
*/
export async function fetchDisplayfromSpotlight(spotlightId: string) {
const displayIds: string[] =
await fetchMatchingTourDisplayIdsfromSpotlight(spotlightId);
const displays: DisplayRow[] = await fetchDisplaysfromIds(displayIds);
const displayIds: string[] =
await fetchMatchingTourDisplayIdsfromSpotlight(spotlightId);
const displays: DisplayRow[] = await fetchDisplaysfromIds(displayIds);
Expand Down
Loading

0 comments on commit 19dbbbe

Please sign in to comment.