-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from NIAEFEUP/feature/ticket-selection-page
Feature/ticket-selection-page
- Loading branch information
Showing
18 changed files
with
299 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ APP_KEY= | |
NODE_ENV=development | ||
SESSION_DRIVER=cookie | ||
|
||
FROM_EMAIL= | ||
FROM_EMAIL=[email protected] | ||
SMTP_HOST=localhost | ||
SMTP_PORT=1025 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
node_modules | ||
build | ||
tmp | ||
.adonisjs | ||
|
||
# Secrets | ||
.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Ticket from '#models/ticket' | ||
import type { HttpContext } from '@adonisjs/core/http' | ||
|
||
export default class TicketsController { | ||
async index({ inertia }: HttpContext) { | ||
const ticketTypes = await Ticket.all() | ||
|
||
return inertia.render('tickets', { ticketTypes }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { DateTime } from 'luxon' | ||
import { BaseModel, column } from '@adonisjs/lucid/orm' | ||
|
||
export default class Ticket extends BaseModel { | ||
@column({ isPrimary: true }) | ||
declare id: number | ||
|
||
@column() | ||
declare name: string | null | ||
|
||
@column() | ||
declare description: string | ||
|
||
@column() | ||
declare price: number | ||
|
||
@column() | ||
declare stock: number | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
declare createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
declare updatedAt: DateTime | null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineConfig } from '@tuyau/core' | ||
|
||
const tuyauConfig = defineConfig({ | ||
codegen: { | ||
/** | ||
* Filters the definitions and named routes to be generated | ||
*/ | ||
// definitions: { | ||
// only: [], | ||
// } | ||
// routes: { | ||
// only: [], | ||
// } | ||
}, | ||
}) | ||
|
||
export default tuyauConfig |
21 changes: 21 additions & 0 deletions
21
website/database/migrations/1734798835308_create_tickets_table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BaseSchema } from '@adonisjs/lucid/schema' | ||
|
||
export default class extends BaseSchema { | ||
protected tableName = 'tickets' | ||
|
||
async up() { | ||
this.schema.createTable(this.tableName, (table) => { | ||
table.increments('id') | ||
table.string('name').nullable() | ||
table.text('description') | ||
table.float('price').notNullable() | ||
table.integer('stock').notNullable() | ||
table.timestamp('created_at') | ||
table.timestamp('updated_at') | ||
}) | ||
} | ||
|
||
async down() { | ||
this.schema.dropTable(this.tableName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { BaseSeeder } from '@adonisjs/lucid/seeders' | ||
import Ticket from '#models/ticket' | ||
|
||
export default class extends BaseSeeder { | ||
async run() { | ||
await Ticket.createMany([ | ||
{ | ||
name: 'Bilhete - Com Alojamento', | ||
description: | ||
'Inclui:\n• Pequenos-almoços, almoços e jantares durante o período do evento\n• Acesso a coffee breaks e sessão de cocktails\n• Acesso a workshops, palestras e outros\n• Acesso a festas noturnas e outras atividades recreativas (exceto Rally Tascas) \n• Alojamento em Pavilhão', | ||
price: 35, | ||
stock: 150, | ||
}, | ||
{ | ||
name: 'Bilhete - Sem Alojamento', | ||
description: | ||
'Inclui:\n• Pequenos-almoços, almoços e jantares durante o período do evento\n• Acesso a coffee breaks e sessão de cocktails\n• Acesso a workshops, palestras e outros\n• Acesso a festas noturnas e outras atividades recreativas (exceto Rally Tascas)', | ||
price: 30, | ||
stock: 50, | ||
}, | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createTuyau } from '@tuyau/client' | ||
import { api } from '#.adonisjs/api' | ||
|
||
export const tuyau = createTuyau({ | ||
api, | ||
baseUrl: import.meta.env.BASE_URL || 'http://localhost:3333', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use client' | ||
|
||
import { InferPageProps } from '@adonisjs/inertia/types' | ||
import { Link } from '@tuyau/inertia/react' | ||
import { Card, CardDescription, CardHeader, CardTitle } from '~/components/ui/card' | ||
import TicketsController from '#controllers/tickets_controller' | ||
|
||
export default function SelectTicketsPage(props: InferPageProps<TicketsController, 'index'>) { | ||
const imageSrc = `favicon.svg` | ||
|
||
return ( | ||
<div className="container mx-auto p-4 flex flex-col items-center"> | ||
<h1 className="text-3xl font-bold text-center mb-6">Seleciona o teu bilhete</h1> | ||
<p className="text-center text-gray-600 mb-8"> | ||
Seleciona o teu bilhete e clica em comprar para continuar. | ||
</p> | ||
|
||
<div className="grid gap-6 grid-cols-1 md:w-1/2"> | ||
{props.ticketTypes.map((ticket) => ( | ||
<Link route="checkout" params={{ id: ticket.id }} key={ticket.id}> | ||
<Card className="hover:shadow-lg"> | ||
<div className="flex items-center justify-between p-6"> | ||
<CardHeader> | ||
<CardTitle>{ticket.name}</CardTitle> | ||
<CardDescription className="whitespace-pre-wrap"> | ||
{ticket.description} | ||
</CardDescription> | ||
<p className="text-2xl font-bold">{ticket.price}€</p> | ||
</CardHeader> | ||
<img className="hidden md:block" src={imageSrc} alt={ticket.name || undefined} /> | ||
</div> | ||
</Card> | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.