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 Name | Data Type | Description |
|---|---|---|
| is_preview | boolean | for show preview package on web app if the value was true |
API Blueprint
| Method | Path | URL | Description |
|---|---|---|---|
| GET | /restaurant_packages/{restaurant_package_id}.json | add new response "is_preview" | |
| GET | /restaurant_packages.json | add 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)orrestaurant.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)orrestaurant.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
| NO | Date Time | What Chaged | Description |
|---|---|---|---|
| 1 | 8 Nov 2022 | - | Initial Document |
How to use this feature
- Check
is previewon 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:
- On the restaurant detail page: {{base_api}}/restaurant_packages.json
- 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.