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

Added Train-A project #1683

Merged
merged 3 commits into from
Aug 13, 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
157 changes: 157 additions & 0 deletions tasks/train-a/admin/carriages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Carriages (manager)

**Browser path:** _/admin/carriages_

**Score**: 60

**Access**: only for manager (run by guards)

## Description

Each train can consist of carriages of different types. Manager can create several types of carriages and then compose trains from them for different routes.

### Main designation of carriage elements

Carriage is composed with parameters:

- **code** - auto-generated unique code for item. User to update carriage.
- **name** - unique name of the carriage type.
- **rows** - number of rows (16 in example below)
- **leftSeats** - - the number of seats to the left of the aisle in a row (2 in example below)
- **rightSeats** - the number of seats to the right of the aisle in a row (3 in example below)

![Designation of carriage elements](../designs/search-details/carriage%20hints.png)

### Requirements

#### Requirement 1: Page layout

- The page must display a "Create" button at the top.
- Below the "Create" button, there must be a list of already created carriages displayed vertically.
- Each carriage in the list must include:
- The name of the carriage type.
- A rendered picture of the train car based on its configuration parameters: rows, leftSeats, and rightSeats.
- If the manager clicks the "Create" button or the "Update" button for any existing carriage, a form must appear at the top of the page.

#### Requirement 2: Carriage configuration form

- The form must include fields for configuring the carriage:
- rows: Number of rows in the carriage.
- leftSeats: Number of seats to the left of the aisle.
- rightSeats: Number of seats to the right of the aisle.
- The form must include a "Save" button.
- As the manager fills out the form, a dynamically rendered prototype of the carriage must be displayed to visualize the configuration.

#### Requirement 3: Saving and updating carriages

- When the manager clicks the "Save" button, the new or updated carriage must be inserted into the list of carriages.
- After saving, the form must disappear.

### Acceptance Criteria (60)

#### Acceptance Criteria 1: Page layout (10)

- The page must display a "Create" button at the top.
- Below the "Create" button, a list of existing carriages must be displayed vertically, each with:
- The name of the carriage type.
- A rendered picture of the carriage based on its configuration parameters.
- "Update" button for each item.

#### Acceptance Criteria 2: Displaying carriage configuration form (15)

- When the manager clicks the "Create" button:
- A form must appear at the top with fields for rows, leftSeats, and rightSeats.
- A "Save" button must be present in the form.
- A dynamically rendered prototype of the carriage must be displayed based on the values entered in the form fields.
- When the manager clicks the "Update" button for an existing carriage:
- The form must appear at the top with the fields pre-filled with the current configuration of the selected carriage.
- A "Update" button must be present in the form.
- The dynamically rendered prototype must update according to changes made in the form.

#### Acceptance Criteria 3: Dynamically rendering prototype (25)

- As the manager fills out or updates the rows, leftSeats, and rightSeats fields in the form:
- The prototype of the carriage must dynamically update to reflect the changes.

#### Acceptance Criteria 4: Saving and displaying new/updated carriages (10)

- When the manager clicks the "Save" button:
- If creating a new carriage:
- The new carriage must be added to the top of the list of carriages.
- The form must disappear.
- If updating an existing carriage:
- The updated carriage must replace the old one in the list.
- The form must disappear.

## API

### Retrieve carriage list

> `(GET) /api/carriage`

- Response 200 (application/json)
- Attributes (array[object])
- code: `type5` (string) - Carriage unique identifier
- name: `Only-women` (string) - Carriage name
- rows: `18` (number) - amount of rows in carriage
- leftSeats: `2` (number) - amount of seats to the left of the aisle
- rightSeats: `2` (number) - amount of seats to the right of the aisle

### Create new carriage type

> `(POST) /api/carriage`

- Request (application/json)

- Body (object)
- name: `Only-women` (string) - Carriage name
- rows: `18` (number) - amount of rows in carriage
- leftSeats: `2` (number) - amount of seats to the left of the aisle
- rightSeats: `2` (number) - amount of seats to the right of the aisle

- Response 201 (application/json)

- Attributes (object)
- code: `type18` (string) - Carriage unique identifier

- Response 401 (application/json)
- Attributes (object)
- error:
- message: `Access is not granted` (string) - Error message
- reason: `invalidAccessToken` (string) - Wrong token idintifier

### Update carriage type

> `(PUT) /api/carriage/{code}`

- Request (application/json)

- Parameters: (object)
- code: `type18` (string) - Carriage unique identifierØ
- Body: (object)
- name: `Only-women` (string) - Carriage name
- rows: `16` (number) - amount of rows in carriage
- leftSeats: `2` (number) - amount of seats to the left of the aisle
- rightSeats: `3` (number) - amount of seats to the right of the aisle

- Response 200 (application/json)

- Attributes: (object)
- code: `type18` (string) - Carriage unique identifier

- Response 401 (application/json)

- Attributes: (object)
- error:
- message: `Access is not granted` (string) - Error message
- reason: `invalidAccessToken` (string) - Wrong token idintifier

- Response 400 (application/json)
- Attributes: (object)
- error:
- message: `Carriage not found` (string) - Error message
- reason: `recordNotFound` (string) - Wrong token idintifier

## Next section

- [Routes](./routes.md)
27 changes: 27 additions & 0 deletions tasks/train-a/admin/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Manager/Administrator page

## Description

The page is designed for managing trips and train movement infrastructure, with the ability to create any type of carriage, place stations, and set up routes.

> There is only 1 user with this role:
> _email:_ admin@admin.com
> _password:_ my-password

### Pages

#### [Stations](./stations.md)

List of all stations in cities than can be connected to each other and makes single thread of road.

> One city can have only 1 train station!

#### [Carriages](./carriages.md)

Manager can create few types of carriages to use them composing the routes.

#### [Routes](./routes.md)

On the routes page, manager can plan a trip between stations and create a composition of carriages to form a train.

Additionally, for each route, a train schedule must be created, and the fare between stations for each type of carriage must be specified.
193 changes: 193 additions & 0 deletions tasks/train-a/admin/ride.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# Schedule

**Browser path:** _/admin/routes/{id}_

**Score**: 100

**Access**: only for manager (run by guards)

## Description

After creating the general route, the manager must set up the train schedule and specify the fare.

To allow users to travel any number of stations and pay only for that portion of the journey rather than the entire route, the manager needs to specify the price for each segment between stations and for each type of carriage present on the train.

Travel time is indicated for each station as _arrival time_ (except for the first one) and _departure time_ (except for the last one).

**Segment** is a part of the route between stations that has its own fare for each type of carriage.

### Requirements

#### Requirement 1: Navigation

- The page must include a "Back" button that navigates the manager back to the route page.

#### Requirement 2: Page title

- The page title must include the route index.

#### Requirement 3: List of rides

- The page must display a list of ride cards, each with:
- Ride id in the title.
- A list of stations, arrival/departure time and prices.

#### Requirement 4: Editing times

- Each cell for arrival/departure times must have an "Edit" button.
- Clicking the "Edit" button must allow the manager to edit the time and save the changes.

#### Requirement 5: Editing prices

- Each cell for prices must have an "Edit" button.
- Clicking the "Edit" button must allow the manager to edit the prices and save the changes.

#### Requirement 6: Creating new rides

- The page must include a "Create" button.
- Clicking the "Create" button must create a new ride list with:
- Predefined stations vertically.
- Form fields for entering departure/arrival times.
- Form fields for entering prices.

### Acceptance Criteria (100)

#### Acceptance Criteria 1: Navigation (5)

- When the "Back" button is clicked, the manager must be navigated back to the route page.

#### Acceptance Criteria 2: Page title (5)

- The page title must include the route id, displaying it clearly at the top.

#### Acceptance Criteria 3: List of rides (30)

- Each ride card in the list must display:
- The ride id in the title.
- A vertical list of stations as the first column.
- The arrival time (except for the first station) and departure time (except for the last station) for each station as the second column.
- Prices for all carriage types in the middle of the previous and next station rows.

#### Acceptance Criteria 4: Editing times (20)

- Each cell for arrival/departure time must include an "Edit" button.
- When the "Edit" button is clicked, the cell must become editable.
- The manager must be able to edit the time and save the changes.
- After saving, the updated time must be displayed in the cell.

#### Acceptance Criteria 5: Editing prices (20)

- Each cell for prices must include an "Edit" button.
- When the "Edit" button is clicked, the cell must become editable.
- The manager must be able to edit the prices for each carriage type and save the changes.
- After saving, the updated prices must be displayed in the cell.

#### Acceptance Criteria 6: Creating new rides (10)

- When the "Create" button is clicked, a new ride list must be created with:
- Predefined stations listed as the first column.
- Form fields for entering departure and arrival times as the second column.
- Form fields for entering prices as the third column.

#### Acceptance Criteria 7: Deleting a ride (10)

- Rides departing from the first station in the future contain a "Delete" button
- When the "Delete" button is clicked:
- A confirmation modal must appear.
- Upon confirming the deletion, the ride must be removed from the list.

## API

### Retrieve route information

> `(GET) /api/route/{id}`

- Request (application/json)
- Parameters:

- id: `17` (number, required) - Identifier of the route

- Response 200 (application/json)
- Attributes: (array[object])
- id: `64` (number) - Route identifier
- path: `[33, 5, 62, 11, 48, 34]` (array[number]) - List of station identifiers
- carriages: `['carriage_type_2', 'carriage_type_2', 'carriage_type_2', 'carriage_type_2', 'carriage_type_7', 'carriage_type_7', 'carriage_type_7', 'carriage_type_7']` (array[string]) - List of carriage types for the train
- schedule: (array[object]) - List of potential rides
- rideId: `44` (number) - Identifier of certain schedule for the route
- segments: (array[object]) - List of road section between each station. Always 1 less than the number of stations on the route
- time: `['2024-08-08T22:19:57.708Z', '2024-08-12T03:29:57.708Z']` ([string, string]) - dates of the start of movement on the section and the end of movement on the section in string form - [departure_from_prev_station, arrival_at_next_station]
- price: (object) - set of prices for all carriage types on this route. It has vary size depending on the train configuration
- dynamic-carriage-type-1: `210` (number) - the price of 210 units for _dynamic-carriage-type-1_ carriage type on current section

### Create new ride

> `(POST) /api/route/{routeId}/ride`

- Request (application/json)

- Parameters:
- routeId: `17` (number, required) - Identifier of the route
- Body (object)
- segments: (array[object])
- time: `['2024-08-08T22:19:57.708Z', '2024-08-12T03:29:57.708Z']` ([string, string]) - dates of the start of movement on the section and the end of movement on the section in string form - [departure_from_prev_station, arrival_at_next_station]
- price: (object) - set of prices for all carriage types on this route. It has vary size depending on the train configuration
- dynamic-carriage-type-1: `210` (number) - the price of 210 units for _dynamic-carriage-type-1_ carriage type on current section

- Response 201 (application/json)

- Attributes (object)
- id: `215` (number) - New ride identifier

- Response 401 (application/json)

- Attributes (object)
- error:
- message: `Access is not granted` (string) - Error message
- reason: `invalidAccessToken` (string) - Wrong token idintifier

- Response 400 (application/json)
- Attributes (object)
- error:
- message: `Route not found` (string) - Error message if routeId is wrong
- reason: `recordNotFound` (string) - Wrong token idintifier

### Update ride

> `(PUT) /api/route/{routeId}/ride/{rideId}`

- Request (application/json)

- Parameters:
- routeId: `17` (number, required) - Identifier of the route
- rideId: `215` (number, required) - Identifier of the ride
- Body (object)
- segments: (array[object])
- time: `['2024-08-08T22:19:57.708Z', '2024-08-12T03:29:57.708Z']` ([string, string]) - dates of the start of movement on the section and the end of movement on the section in string form - [departure_from_prev_station, arrival_at_next_station]
- price: (object) - set of prices for all carriage types on this route. It has vary size depending on the train configuration
- dynamic-carriage-type-1: `210` (number) - the price of 210 units for _dynamic-carriage-type-1_ carriage type on current section

- Response 200 (application/json)

- Attributes (object)

- Response 401 (application/json)

- Attributes (object)
- error:
- message: `Access is not granted` (string) - Error message
- reason: `invalidAccessToken` (string) - Wrong token idintifier

- Response 400 (application/json)
- Attributes (object)
- error:
- message: `Ride not found` (string) - Error message if routeId or rideId is wrong
- reason: `recordNotFound` (string) - Wrong token idintifier

## Design example

> [!WARNING]
> All mockups should not be considered as final versions! We are providing an idea; you can come up with any design as long as it meets the functional requirements.

### Ride list with edit field

![Ride page](../designs/rides/update.png)
Loading
Loading