fixed some login and booking bugs

This commit is contained in:
tumillanino
2025-10-28 13:36:05 +11:00
parent dad3ec655f
commit 5d7f0a8eb3
11 changed files with 402 additions and 141 deletions

View File

@@ -12,29 +12,33 @@ import (
)
const createBooking = `-- name: CreateBooking :one
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id, user_id, service_id, event_date, address, notes, created_at, status
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status, service_option, event_type)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
`
type CreateBookingParams struct {
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
Status sql.NullString `json:"status"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
Status sql.NullString `json:"status"`
ServiceOption sql.NullString `json:"service_option"`
EventType sql.NullString `json:"event_type"`
}
type CreateBookingRow struct {
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ServiceOption sql.NullString `json:"service_option"`
EventType sql.NullString `json:"event_type"`
}
func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (CreateBookingRow, error) {
@@ -45,6 +49,8 @@ func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (C
arg.Address,
arg.Notes,
arg.Status,
arg.ServiceOption,
arg.EventType,
)
var i CreateBookingRow
err := row.Scan(
@@ -56,25 +62,29 @@ func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (C
&i.Notes,
&i.CreatedAt,
&i.Status,
&i.ServiceOption,
&i.EventType,
)
return i, err
}
const getBooking = `-- name: GetBooking :one
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
SELECT id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
FROM bookings
WHERE id = $1
`
type GetBookingRow struct {
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ServiceOption sql.NullString `json:"service_option"`
EventType sql.NullString `json:"event_type"`
}
func (q *Queries) GetBooking(ctx context.Context, id int64) (GetBookingRow, error) {
@@ -89,26 +99,30 @@ func (q *Queries) GetBooking(ctx context.Context, id int64) (GetBookingRow, erro
&i.Notes,
&i.CreatedAt,
&i.Status,
&i.ServiceOption,
&i.EventType,
)
return i, err
}
const listBookingsByUser = `-- name: ListBookingsByUser :many
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
SELECT id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
FROM bookings
WHERE user_id = $1
ORDER BY event_date DESC
`
type ListBookingsByUserRow struct {
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Address sql.NullString `json:"address"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ServiceOption sql.NullString `json:"service_option"`
EventType sql.NullString `json:"event_type"`
}
func (q *Queries) ListBookingsByUser(ctx context.Context, userID sql.NullInt64) ([]ListBookingsByUserRow, error) {
@@ -129,6 +143,8 @@ func (q *Queries) ListBookingsByUser(ctx context.Context, userID sql.NullInt64)
&i.Notes,
&i.CreatedAt,
&i.Status,
&i.ServiceOption,
&i.EventType,
); err != nil {
return nil, err
}
@@ -153,6 +169,8 @@ SELECT
b.notes,
b.created_at,
b.status,
b.service_option,
b.event_type,
s.name as service_name,
s.description as service_description,
s.price_cents as service_price_cents
@@ -171,6 +189,8 @@ type ListBookingsWithServiceByUserRow struct {
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Status sql.NullString `json:"status"`
ServiceOption sql.NullString `json:"service_option"`
EventType sql.NullString `json:"event_type"`
ServiceName string `json:"service_name"`
ServiceDescription sql.NullString `json:"service_description"`
ServicePriceCents int32 `json:"service_price_cents"`
@@ -194,6 +214,8 @@ func (q *Queries) ListBookingsWithServiceByUser(ctx context.Context, userID sql.
&i.Notes,
&i.CreatedAt,
&i.Status,
&i.ServiceOption,
&i.EventType,
&i.ServiceName,
&i.ServiceDescription,
&i.ServicePriceCents,

View File

@@ -10,14 +10,16 @@ import (
)
type Booking struct {
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Address sql.NullString `json:"address"`
Status sql.NullString `json:"status"`
ID int64 `json:"id"`
UserID sql.NullInt64 `json:"user_id"`
ServiceID sql.NullInt64 `json:"service_id"`
EventDate time.Time `json:"event_date"`
Notes sql.NullString `json:"notes"`
CreatedAt sql.NullTime `json:"created_at"`
Address sql.NullString `json:"address"`
Status sql.NullString `json:"status"`
ServiceOption sql.NullString `json:"service_option"`
EventType sql.NullString `json:"event_type"`
}
type GalleryPhoto struct {

View File

@@ -1,10 +1,10 @@
-- name: CreateBooking :one
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id, user_id, service_id, event_date, address, notes, created_at, status;
INSERT INTO bookings (user_id, service_id, event_date, address, notes, status, service_option, event_type)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
RETURNING id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type;
-- name: ListBookingsByUser :many
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
SELECT id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
FROM bookings
WHERE user_id = $1
ORDER BY event_date DESC;
@@ -19,6 +19,8 @@ SELECT
b.notes,
b.created_at,
b.status,
b.service_option,
b.event_type,
s.name as service_name,
s.description as service_description,
s.price_cents as service_price_cents
@@ -28,6 +30,6 @@ WHERE b.user_id = $1
ORDER BY b.event_date DESC;
-- name: GetBooking :one
SELECT id, user_id, service_id, event_date, address, notes, created_at, status
SELECT id, user_id, service_id, event_date, address, notes, created_at, status, service_option, event_type
FROM bookings
WHERE id = $1;