Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Preview Package

Title

Preview new package on existing restaurant

Description / Background

When admin create new package, they want to check how the package look like, so they want to have “preview”

Objectives

  • admin/operation team can preview their package before deliver to user
  • add a checkbox on setting package when assign to the restaurant
  • on front end need to show the preview package if it pick to preview on admin side

Scope

  • For all platform
  • Restaurant package

Sequence Diagram / Flow

ERD

DB Schema / Database Migration

Column NameData TypeDescription
is_previewbooleanfor show preview package on web app if the value was true

API Blueprint

MethodPathURLDescription
GET/restaurant_packages/{restaurant_package_id}.jsonadd new response "is_preview"
GET/restaurant_packages.jsonadd new response "is_preview"

New Query

On Restaurant Package API:

  • if is_preview is true it will get restaurant from : restaurant.restaurant_packages.where(is_visible: true) or restaurant.all_restaurant_packages.where(is_visible: true).limit(5).order('end_date desc').select {|rp| rp.package.present? }
  • if is_preview is false : restaurant.restaurant_packages.where(is_visible: true, is_preview: false) or restaurant.all_restaurant_packages.where(is_visible: true, is_preview: false).order('end_date desc').select {|rp| rp.package.present? }

On Restaurant API

if preview == true
  rest_packs = HhPackage::RestaurantPackage.where(slug: slugs)
else
  rest_packs = HhPackage::RestaurantPackage.where(slug: slugs, is_preview: false)
end

Notes, Constraint & Assumptions

TODO / Task List / Action Items

[

3.basecamp.com

https://3.basecamp.com/5190892/buckets/29794160/todosets/5438309787

](https://3.basecamp.com/5190892/buckets/29794160/todosets/5438309787)

References

Change History

NODate TimeWhat ChagedDescription
18 Nov 2022-Initial Document

How to use this feature

  • Check is preview on edit package if you want to show the package as preview on web app
  • Login web app using Hungryhub email
  • Find the restaurant
  • Find the package

Backend Implementation

Backend should handle is_preview package in 2 APIs:

  1. On the restaurant detail page: {{base_api}}/restaurant_packages.json
  2. On find available package by date time {{base_api}}/restaurants/{res_id}/find_available_packages.json API need to hide that package or don't give data to the user unless client sends an additional parameter is_preview = true.

Frontend Implementation

Frontend need to handle send is_preview = true if user login user email @hungryhub.com on those 2 APIs. For the default, don't send any is_preview parameter.