Implemented phase 6 for the POC prototype in the Website service.

This commit is contained in:
javier committed 2026-09-21 13:53:13 +02:00
1 parent 256d22df40
commit f2f445827b
40 files changed
+1906 -37

No files matched your search

@@ -12,6 +12,9 @@ struct SellerDashboardPage {
let assetVersion: String?
let locale: Locale
/// The upcoming events, each with whether the shop trades there.
let events: [(event: Event, isTrading: Bool)]
/// The shop's listings still for sale, newest first.
let listings: [Listing]
@@ -38,6 +41,7 @@ struct SellerDashboardPage {
/// - offers: the offers waiting for the seller's answer, the soonest to expire first.
/// - sales: the shop's sales, the latest agreed first.
/// - listings: the shop's listings still for sale, newest first.
/// - events: the upcoming events; none by default.
/// - viewer: the signed-in viewer.
/// - now: the moment stamps are read relative to; the present by default.
/// - assetVersion: the version token appended to the page's asset URLs, or `nil` (the default) to leave them unversioned.
@@ -47,6 +51,7 @@ struct SellerDashboardPage {
offers: [Offer],
sales: [Sale],
listings: [Listing],
events: [Event] = [],
viewer: Viewer? = nil,
now: Date = .init(),
assetVersion: String? = nil,
@@ -54,6 +59,7 @@ struct SellerDashboardPage {
) {
self.analytics = analytics
self.assetVersion = assetVersion
self.events = events.map { event in (event, event.shops.contains { $0.slug == shop.slug }) }
self.listings = listings
self.locale = .init(identifier: "en")
self.now = now
@@ -231,6 +237,43 @@ extension SellerDashboardPage: Page {
}
}
}
if !events.isEmpty {
form(
.class("card sell__panel"),
.action("\(String.Route.sellerDashboard)/events"),
.method(.post)
) {
div(.class("section-head")) {
h2(.class("type-panel")) {
"Events you'll trade at"
}
span(.class("type-small")) {
"Buyers can agree online and collect at the con"
}
}
div(.class("listing-form__checks")) {
ForEach(events) { entry in
label(.class("check")) {
input(
.type(.checkbox),
.name("events"),
.value(entry.event.slug)
)
.attributes(.checked, when: entry.isTrading)
"\(entry.event.name) · \(Date.span(from: entry.event.startsOn, to: entry.event.endsOn))"
}
}
}
div(.class("listing-form__submit")) {
button(
.class("button button--dark button--sm"),
.type(.submit)
) {
"Save events"
}
}
}
}
}
}
}