Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make schema updates #22

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/supabase/queries/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export async function fetchAllEvents() {
return data;
}

// fetches all events that have event_status = 'ACTIVE'
// fetches all events that have event_status = 'Active'
export async function fetchAllActiveEvents() {
const { data, error } = await supabase
.from('events')
.select('*')
.eq('event_status', 'ACTIVE');
.eq('event_status', 'Active');
if (error) {
throw new Error(error.message);
}
Expand Down
7 changes: 5 additions & 2 deletions app/activeEvents/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function Page() {
setEvents(fetchedActiveEvents);
};
getActiveEvents();
}, [events]);
}, []);

return (
<Container>
Expand All @@ -53,7 +53,10 @@ export default function Page() {
</TitleBar>
<EventListingDiv>
{events.map(event => (
<EventListingCard key={event.event_id} genre={event.genre} />
<EventListingCard
key={event.event_id}
performance_type={event.performance_type}
/>
))}
</EventListingDiv>
</Container>
Expand Down
4 changes: 2 additions & 2 deletions app/events/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Page() {
<th>facility_id</th>
<th>start_date_time</th>
<th>end_date_time</th>
<th>type_of_act</th>
<th>performance_type</th>
<th>genre</th>
<th>needs_host</th>
<th>performer_type</th>
Expand All @@ -36,7 +36,7 @@ export default function Page() {
<td>{d.facility_id}</td>
<td>{d.start_date_time}</td>
<td>{d.end_date_time}</td>
<td>{d.type_of_act}</td>
<td>{d.performance_type}</td>
<td>{d.genre}</td>
<td>{d.needs_host}</td>
<td>{d.performer_type}</td>
Expand Down
9 changes: 7 additions & 2 deletions components/EventListingCard/EventListingCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import React from 'react';
import { PerformanceType } from '@/types/schema';
import { EventListing } from './styles';

export default function EventListingCard({ genre }: { genre: string }) {
return <EventListing> {genre} </EventListing>;
export default function EventListingCard({
performance_type,
}: {
performance_type: PerformanceType;
}) {
return <EventListing> {performance_type} </EventListing>;
}
86 changes: 48 additions & 38 deletions types/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { UUID } from 'crypto';

// used for events and volunteer_preference tables
export type TypeOfAct =
export type PerformanceType =
| 'Music'
| 'Dance'
| 'Poetry'
Expand All @@ -15,7 +15,7 @@ export type TypeOfAct =
| 'Puppetry';

// used for volunteers_preference and facilities table
export type TypeOfFacility =
export type FacilityType =
| 'Assisted Living'
| "Children's Day Care"
| 'Detention Center'
Expand Down Expand Up @@ -53,43 +53,49 @@ export type Genre =
| 'Standards';

// used for events table
export type EventStatus = 'ACTIVE' | 'INACTIVE';
export type EventStatus = 'Active' | 'Inactive';

// used for event_signups table
export type Role = 'Host' | 'Performer';

// used for availabilities table
export type Day =
| 'Monday'
| 'Tuesday'
| 'Wednesday'
| 'Thursday'
| 'Friday'
| 'Saturday'
| 'Sunday';

export type TypeOfPerformer = 'Solo' | 'Duo' | 'Band';
export type PerformerType =
| 'Solo'
| 'Duo'
| 'Trio'
| 'Quartet'
| 'Five or More';

export interface Availabilities {
availability_id: UUID;
facility_id: UUID;
date: Date; // date
day_of_week: Day;
start_time: string; // timestamptz
end_time: string; // timestamptz
is_recurring: boolean;
name: string;
additional_info: string;
}

export interface AvailableDates {
date_id: UUID;
availability_id: UUID;
available_date: string; //date
}

export interface Timeslots {
timeslot_id: UUID;
date_id: UUID;
start_time: string; //timestamptz
end_time: string; //timestamptz
}

export interface Event {
event_id: UUID;
facility_id: UUID;
start_date_time: string; //timestamptz
end_date_time: string; //timestamptz
type_of_act: TypeOfAct;
genre: Genre;
performance_type: PerformanceType;
genre?: Genre;
needs_host: boolean;
performer_type: TypeOfPerformer;
event_status: EventStatus;
performer_type: PerformerType;
notes?: string;
}

export interface EventSignups {
Expand All @@ -99,27 +105,30 @@ export interface EventSignups {
is_accepted: boolean;
}

export interface Facilities {
export interface FacilityContacts {
user_id: UUID;
facility_id: UUID;
name: string;
email: string;
first_name: string;
last_name: string;
phone_number: string;
state: string;
}

export interface Facilities {
facility_id: UUID;
name: string;
county: string;
city: string;
street_address_1: string;
street_address_2?: string;
postal_code: string;
audience: Audience;
type: TypeOfFacility;
type: FacilityType;
host_name?: string;
host_contact?: string;
poc_name: string;
poc_contact: string;
notifications_opt_in: boolean;
}

export interface Volunteers {
volunteer_id: UUID;
user_id: UUID;
first_name: string;
last_name: string;
email: string;
Expand All @@ -128,11 +137,12 @@ export interface Volunteers {
}

export interface VolunteersPreferences {
volunteer_id: UUID;
city?: string;
genre?: Genre;
instruments?: Instruments;
type_of_act?: TypeOfAct;
audience?: Audience;
facility_type?: TypeOfFacility;
user_id: UUID;
role?: Role[];
performance_type?: PerformanceType[];
facility_type?: FacilityType[];
locations?: string[];
audience?: Audience[];
genre?: Genre[];
additional_info?: string;
}