Implemented phase 3 for the POC prototype in the Website service.
This commit is contained in:
1 parent
b1ceed7790
commit
0dc3fe6bea
29 files changed
+4089
-66
No files matched your search
@@ -0,0 +1,75 @@
|
||||
import Elementary
|
||||
import Persistence
|
||||
|
||||
/// The seller's answer to an open offer: accept or decline, each a form.
|
||||
struct AnswerOffer: HTML {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The offer answered.
|
||||
let offer: Offer
|
||||
|
||||
/// The path to return to afterwards; accepting leads to the sale record instead.
|
||||
let returnPath: String
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
var body: some HTML {
|
||||
form(
|
||||
.class("answer"),
|
||||
.action(.Route.answer(offer: offer.id)),
|
||||
.method(.post)
|
||||
) {
|
||||
input(
|
||||
.type(.hidden),
|
||||
.name("return"),
|
||||
.value(returnPath)
|
||||
)
|
||||
button(
|
||||
.class("button button--primary button--sm"),
|
||||
.type(.submit),
|
||||
.name("answer"),
|
||||
.custom(name: "value", value: "accept")
|
||||
) {
|
||||
"Accept"
|
||||
}
|
||||
button(
|
||||
.class("button button--sm"),
|
||||
.type(.submit),
|
||||
.name("answer"),
|
||||
.custom(name: "value", value: "decline")
|
||||
) {
|
||||
"Decline"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Extensions
|
||||
|
||||
extension Offer.Status {
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The status in a word.
|
||||
var label: String {
|
||||
switch self {
|
||||
case .open: "Open"
|
||||
case .accepted: "Accepted"
|
||||
case .declined: "Declined"
|
||||
case .expired: "Expired"
|
||||
}
|
||||
}
|
||||
|
||||
/// The chip colouring for the status.
|
||||
var tone: Chip.Tone {
|
||||
switch self {
|
||||
case .open: .warn
|
||||
case .accepted: .good
|
||||
case .declined: .bad
|
||||
case .expired: .neutral
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user