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 16, 2024
2 parents 152d2fa + 0ecddad commit fa220ef
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

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

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
4 changes: 4 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 Down Expand Up @@ -52,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
95 changes: 95 additions & 0 deletions src/types/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type Json =
| { [key: string]: Json | undefined }
| Json[];
| Json[];
| Json[];

export type Database = {
public: {
Expand Down Expand Up @@ -76,6 +77,13 @@ export type Database = {
id: string;
title: string;
updated_at: string | null;
};
coordinates: Json | null;
created_at: string;
description: string;
id: string;
title: string;
updated_at: string | null;
};
Insert: {
coordinates?: Json | null;
Expand All @@ -84,6 +92,13 @@ export type Database = {
id: string;
title?: string;
updated_at?: string | null;
};
coordinates?: Json | null;
created_at?: string;
description?: string;
id: string;
title?: string;
updated_at?: string | null;
};
Update: {
coordinates?: Json | null;
Expand All @@ -94,6 +109,15 @@ export type Database = {
updated_at?: string | null;
};
Relationships: [];
};
coordinates?: Json | null;
created_at?: string;
description?: string;
id?: string;
title?: string;
updated_at?: string | null;
};
Relationships: [];
};
media: {
Row: {
Expand All @@ -118,6 +142,13 @@ export type Database = {
title?: string | null;
type?: string | null;
url?: string;
};
created_at?: string;
id?: string;
text?: string | null;
title?: string | null;
type?: string | null;
url?: string;
};
Update: {
created_at?: string;
Expand All @@ -128,6 +159,15 @@ export type Database = {
url?: string;
};
Relationships: [];
};
created_at?: string;
id?: string;
text?: string | null;
title?: string | null;
type?: string | null;
url?: string;
};
Relationships: [];
};
spotlight_recommendations: {
Row: {
Expand Down Expand Up @@ -325,8 +365,47 @@ export type Database = {
id: string;
title: string;
updated_at: string | null;
};
created_at: string;
description: string | null;
id: string;
name: string | null;
spotlight: boolean;
stop_count: number | null;
};
Insert: {
created_at?: string;
description?: string | null;
id?: string;
name?: string | null;
spotlight?: boolean;
stop_count?: number | null;
};
Update: {
created_at?: string;
description?: string | null;
id?: string;
name?: string | null;
spotlight?: boolean;
stop_count?: number | null;
};
Relationships: [];
};
news: {
Row: {
content_link: string;
created_at: string;
id: string;
title: string;
updated_at: string | null;
};
Insert: {
content_link?: string;
created_at?: string;
id?: string;
title?: string;
updated_at?: string | null;
};
content_link?: string;
created_at?: string;
id?: string;
Expand All @@ -342,6 +421,15 @@ export type Database = {
};
Relationships: [];
};
};
content_link?: string;
created_at?: string;
id?: string;
title?: string;
updated_at?: string | null;
};
Relationships: [];
};
};
Views: {
[_ in never]: never;
Expand Down Expand Up @@ -383,9 +471,16 @@ export type Database = {
};
Enums: {
media_type: 'image' | 'video' | 'link';
};
media_type: 'image' | 'video' | 'link';
};
CompositeTypes: {
[_ in never]: never;
};
};
}

[_ in never]: never;
};
};
}
1 change: 1 addition & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type TourMediaRow = Database['public']['Tables']['tour_media']['Row'];
export type TourRow = Database['public']['Tables']['tours']['Row'];
export type NewsRow = Database['public']['Tables']['news']['Row'];
export type SpotlightWithMediaRow = TourRow & { media_url: string };
export type NewsRow = Database['public']['Tables']['news']['Row'];
export type SpotlightRow = {
tour_row: TourRow;
url: string;
Expand Down

0 comments on commit fa220ef

Please sign in to comment.