voluntree-uk / app-next

NextJS Application for Voluntree
https://platform.voluntree.net
1 stars 0 forks source link

Correct BookingDetails query & interface #18

Closed harryndavies closed 5 months ago

harryndavies commented 2 years ago

Only one workshop and slot will be returned per booking, so property names should be singular (workshop and slot inside the select are aliases).

Also, it's worth noting that we are only returning a few properties, and not the complete interface. Might be worth just returning the complete workshop and slot data for now to avoid issues with trying to access properties that don't exist?

Query should read

const { data: bookings } = await supabase
    .from("bookings")
    .select(`
      *,
      workshop:workshop_id(name),
      slot:slot_id(date, start_time, end_time)
    `)
    .eq("user_id", user?.id);

Interface should read

export interface BookingDetails extends Booking {
  workshop: Workshop;
  slot: Slot;
}
mika018 commented 8 months ago

I don't think that this is possible as those are table references. It will only work if we rename tables to be singular as well.

mika018 commented 5 months ago

Makes sense to do this sooner rather than later. Definitely don't want to do it after the release.

Just need to track all the places where the change needs to happen: