JavaScript workshop based on the french startuphttps:// privateaser
Table of Contentsgenerated withDocToc
- 🐣 Introduction
- 🎯 Objectives
- 👩💻 Just tell me what to do
- 🏃♀️ Steps to do
- Source and inspiration
- Licence
Privateaseris a marketplace that digitizes the world of event planning for bars, restaurants and venues (+3,000 locations), via a web application.
The Event management is a key sector of the Europe economy:
- 100 billion euros in Europe
- 20 billion euros in France
- historically complex
- not much digitized: you have to pick up your phone, wait to be called back, go to visit
Privateaseris a trusted third party between the bars and the bookers. The marketplace allows them to:
- the bookers to find, to compare or to contact a place
- the bookers to book with an one-click a place for an event
- the bookers to manage all their events expenses
- the managers to maximize the occupancy rate and therefore the revenue of their business
We focus on this marketplace feature:to book with an one-click a place for an event
.
The workshop goals are to
- compute the booking price of the
booker
- compute the profit of the
bar
- compute the profit of
privateaser
- Fork the project via
github
- Clone your forked repository project
https://github /YOUR_USERNAME/privateaser
❯cd/path/to/workspace
❯ git clone git@github:YOUR_USERNAME/privateaser.git
- Open the entry point/public/index.htmlin your browser (that loads the
index.js
file)
#macos cli
❯ open public/index.html
#linux cli
❯ xdg-open public/index.html
#or by double-clicking in your browser files
- Check the ouput in your browser console (Use
Ctrl + Shift + J
orCmd + Opt + J
to focus to your console devtools) - Solve each steps inside./public/index.jsfile with JavaScript
- Once a step is solved, commit your modification:
❯cd/path/to/workspace/privateaser
❯ git add -A&&git commit -m"feat(price): decrease pricing according people"
(why following a commit message convention?
- 5 steps, so ideally 5 commits
- Don't forget to push before the end of the workshop
❯ git push origin master
Note:if you catch an error about authentication,add your ssh to your github profile.
- Check that your codebase works by checking the console output
- If you need some helps on git commands, readgit - the simple guide
- DRY - Don't repeat yourself
- DOT - Do One Thing
- KISS - Keep It Simple Stupid
- LIM - Less Is More
- English only: codebase, variables, comments...
Focus only on coding, forgot the browser display (next workshop!).
Useconsole.log
to display results (for the moment)
Thebooker
books a place for an specific time range and a set of persons.
The booking price is the sum of the time component and the people component with
- time component:the number of booked time multiplied by the
bar
price per hour - people component:the number of persons multiplied by the
bar
price per person
booking price = time + people
Write JS code that generates the booking price for eachbooker
fromindex.js
file:
//example output from console.log
[
{
"id":"bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price":?
},
{
"id":"65203b0a-a864-4dea-81e2-e389515752a8",
...
"price":?
},
{
"id":"94dab739-bd93-44c0-9be1-52dd07baa9f6",
...
"price":?
}
]
To be as competitive as possible,Privateaser
decide to have a decreasing pricing for groups of important people
price per people
- decreases by10% after 10 persons
- decreases by30% after 20 persons
- decreases by50% after 60 persons
Adapt the booking price computation to take these new rules into account.
//example output from console.log
[
{
"id":"bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price":?
},
{
"id":"65203b0a-a864-4dea-81e2-e389515752a8",
...
"price":?
},
{
"id":"94dab739-bd93-44c0-9be1-52dd07baa9f6",
...
"price":?
}
]
Now, it's time to pay thebar
There is a 30% commission on the booking price to cover the costs.
The commission is split like this:
- insurance:half of commission
- the Treasury:1€ by person
- Privateaser:the rest
Compute the amount that belongs to theinsurance
,to theTreasury
and toPrivateaser
.
//example output from console.log
[
{
"id":"bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"commission":{
"insurance":?,
"treasury":?
"privateaser":?
}
},
...
]
In case of an accident/theft,Privateaser
applies a 5000€ deductible.
The booker can reduce the deductible amount from 5000€ to 200€ with adeductible option
for a few more euros per person.
The booker is charged an additional 1€/person when he chooses thedeductible reduction
option.
The additional charge goes toPrivateaser
,not to the bar.
Compute the new amount price if the booker subscribed todeductible option
.
//example output from console.log
[
{
"id":"bba9500c-fd9e-453f-abf1-4cd8f52af377",
'options':{
'deductibleReduction':true
},
...
"price":?
},
...
]
It's time to debit/credit each actor!
- the bookermust pay thebooking priceand the(optional) deductible reduction
- the barreceives thebooking priceminus thecommission
- the insurancereceives its part of thecommission
- the Treasuryreceives its part of the taxcommission
- Privateaser receivesits part of thecommission,plus thedeductible reduction
- Compute the debit for the
booker
- Compute the credit of the
bar
,insurance
,Treasury
andPrivateaser
.
//example output from console.log
[
{
"deliveryId":"bba9500c-fd9e-453f-abf1-4cd8f52af377",
"payment":[
{
"who":"booker",
"type":"debit",
"amount":?
},
{
"who":"bar",
"type":"credit",
"amount":?
},
{
"who":"insurance",
"type":"credit",
"amount":?
},
{
"who":"treasury",
"type":"credit",
"amount":?
},
{
"who":"privateaser",
"type":"credit",
"amount":?
}
]
},
...
]