Skip to content
Closed
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
133 changes: 0 additions & 133 deletions api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ channels:
- $ref: "#/components/messages/weighingFailed"
- $ref: "#/components/messages/paymentSuccess"
- $ref: "#/components/messages/paymentFailure"
- $ref: "#/components/messages/showDialog"
- $ref: "#/components/messages/closeDialog"
- $ref: "#/components/messages/apiError"
- $ref: "#/components/messages/apiWarning"
subscribe:
Expand All @@ -76,7 +74,6 @@ channels:
- $ref: "#/components/messages/weighArticle"
- $ref: "#/components/messages/startPayment"
- $ref: "#/components/messages/printReceipt"
- $ref: "#/components/messages/userInput"
- $ref: "#/components/messages/reset"
- $ref: "#/components/messages/apiError"
- $ref: "#/components/messages/apiWarning"
Expand Down Expand Up @@ -310,37 +307,6 @@ components:
- message
additionalProperties: false

Dialog:
type: object
properties:
id:
type: string
description: Identifier for this kind of dialog. E.g. `cardReaderError`.
title:
$ref: "#/components/schemas/I18ned"
description: Title of the dialog.
body:
$ref: "#/components/schemas/I18ned"
description: Dialog body to display to the customer.
buttons:
type: array
items:
type: object
properties:
action:
type: string
description: Action the button will trigger when pressed.
label:
$ref: "#/components/schemas/I18ned"
description: Label to display on the button.
required:
- action
- label
required:
- id
- title
- body
additionalProperties: false

messages:
syncArticles:
Expand Down Expand Up @@ -825,102 +791,3 @@ components:
- event
additionalProperties: false

showDialog:
summary: Show a dialog that requires user interaction.
description: >
The dialog will be rendered based on the data, including all buttons.
It will report back the button that was pressed with the action that is
attached to the button. The dialog will be closed automatically after
a button was pressed. In case a new dialog should be opened, a new
message has to be sent. The dialog can only be shown during checkout
and not during scanning.
payload:
type: object
properties:
event:
type: string
const: showDialog
data:
$ref: "#/components/schemas/Dialog"
required:
- event
- data
additionalProperties: false
examples:
- payload:
event: "showDialog"
data:
id: "survey"
title:
en: "Survey"
de: "Umfrage"
body:
en: "How satisfied are you with the interface?"
de: "Wie zufrieden sind Sie mit der Schnittstelle?"
buttons:
- action: "-1"
label:
en: "Not at all"
de: "Gar nicht"
- action: "+1"
label:
en: "A lot"
de: "Sehr"

closeDialog:
summary: Close any currently open dialog.
payload:
type: object
properties:
event:
type: string
const: closeDialog
data:
type: object
properties:
id:
type: string
description: Identifier for this kind of dialog. E.g. `cardReaderError`.
required:
- id
required:
- event
- data
additionalProperties: false
examples:
- payload:
event: "closeDialog"
data:
id: "survey"

userInput:
summary: Report the user's response to a dialog.
description: >
Reports the action of the button that was pressed in a dialog.
The actions corresponds to what was set in the `showDialog` message.
payload:
type: object
properties:
event:
type: string
const: userInput
data:
type: object
properties:
id:
type: string
action:
type: string
required:
- id
- action
required:
- event
- data
additionalProperties: false
examples:
- payload:
event: "userInput"
data:
id: "survey"
action: "+1"
6 changes: 0 additions & 6 deletions example-client/src/CashRegisterSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ const CashRegisterSimulator = ({ipAddress}: Props) => {
<Button variant="contained" onClick={() => cashRegister?.guestRemoved()}>
Guest Removed
</Button>
<Button variant="contained" onClick={() => cashRegister?.showDialog()}>
Show Dialog
</Button>
<Button variant="contained" onClick={() => cashRegister?.closeDialog()}>
Close Dialog
</Button>
</Stack>
<Stack spacing={2} sx={{minWidth: 450}}>
<Divider>Basket</Divider>
Expand Down
62 changes: 2 additions & 60 deletions example-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from "lodash";
import useCashRegisterStore from "./store";
import {
PaymentFailure, PaymentSuccess, StartPayment, Reset, CloseDialog, SetBasket, ShowDialog, SyncArticles, UserInput,
PaymentFailure, PaymentSuccess, StartPayment, Reset, SetBasket, SyncArticles,
ArticleWeighed, WeighingFailed, WeighArticle, ApiError, AddArticles, GuestAuthenticated, GuestRemoved, ApiWarning, UpdateBasket, BasketArticle, ScanArticle, SyncedArticle, I18Ned
} from "./types";

Expand Down Expand Up @@ -165,52 +165,6 @@ export class CashRegister {
await this.send(message)
}


async showDialog() {
const message: ShowDialog = {
event: "showDialog",
data: {
id: "survey",
title: {
en: "Survey",
de: "Umfrage",
},
body: {
en: "How satisfied are you with the interface?",
de: "Wie zufrieden sind Sie mit der Schnittstelle?",
},
buttons: [
{
action: "-1",
label: {
en: "Not at all",
de: "Gar nicht",
}
},
{
action: "+1",
label: {
en: "A lot",
de: "Sehr",
}
}
],
}
}
await this.send(message)
}

async closeDialog() {
const message: CloseDialog = {
event: "closeDialog",
data: {
id: "survey",
}
}
await this.send(message)
}


async onSetBasket(message: SetBasket) {
const ScanArticles = this.toBasketArticles(message.data.articles)
if (_.isEmpty(ScanArticles)) {
Expand Down Expand Up @@ -265,15 +219,6 @@ export class CashRegister {
useCashRegisterStore.getState().reset()
}

async onUserInput(message: UserInput) {
if (message.data.id === "survey") {
useCashRegisterStore.setState({
surveyResult: useCashRegisterStore.getState().surveyResult
+ parseInt(message.data.action)
})
}
}

private async weighArticle(parsedMessage: WeighArticle) {
useCashRegisterStore.setState({ scaleArticlePlu: parsedMessage.data.article.priceLookup })
}
Expand All @@ -285,7 +230,7 @@ export class CashRegister {
}

private async receiveMessage(message: MessageEvent<string>) {
const parsedMessage = JSON.parse(message.data) as SetBasket | AddArticles | StartPayment | Reset | UserInput | WeighArticle | ApiError | ApiWarning
const parsedMessage = JSON.parse(message.data) as SetBasket | AddArticles | StartPayment | Reset | WeighArticle | ApiError | ApiWarning
console.log("Received message:", message.data)
switch (parsedMessage.event) {
case "setBasket":
Expand All @@ -300,9 +245,6 @@ export class CashRegister {
case "reset":
await this.onReset()
break;
case "userInput":
await this.onUserInput(parsedMessage)
break;
case "weighArticle":
await this.weighArticle(parsedMessage)
break;
Expand Down
2 changes: 0 additions & 2 deletions example-client/src/generateTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import * as fs from "fs/promises"
import parser from '@asyncapi/parser';
import { compile } from 'json-schema-to-typescript'
Expand Down
Loading
Loading