Skip to content

Commit bdb4146

Browse files
Copilotsinedied
andauthored
feat: add optional nickname parameter to orders (#4)
* Initial plan * Add optional nickname field to orders across all layers Co-authored-by: sinedied <[email protected]> * Add example request with nickname in api.http Co-authored-by: sinedied <[email protected]> * Update nickname display: 10 chars, no # prefix for nicknames Co-authored-by: sinedied <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: sinedied <[email protected]>
1 parent 93f006e commit bdb4146

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed

packages/burger-api/api.http

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ Content-Type: application/json
8080
]
8181
}
8282

83+
### Create a new order with nickname
84+
POST {{api_host}}/api/orders
85+
Content-Type: application/json
86+
87+
{
88+
"userId": "user123",
89+
"nickname": "Alice",
90+
"items": [
91+
{
92+
"burgerId": "1",
93+
"quantity": 2
94+
}
95+
]
96+
}
97+
8398
### Delete/cancel an order
8499
DELETE {{api_host}}/api/orders/12345?userId=user123
85100

packages/burger-api/openapi.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ components:
486486
format: date-time
487487
description: ISO date string for when the order was ready (undefined until ready)
488488
example: '2025-04-10T15:05:00Z'
489+
nickname:
490+
type: string
491+
description: Optional nickname for the order
492+
example: 'John'
489493
totalPrice:
490494
type: number
491495
format: float
@@ -520,6 +524,9 @@ components:
520524
type: string
521525
format: date-time
522526
description: ISO date string for when the order was completed (undefined until completed)
527+
nickname:
528+
type: string
529+
description: Optional nickname for the order
523530
totalPrice:
524531
type: number
525532
format: float
@@ -538,6 +545,10 @@ components:
538545
userId:
539546
type: string
540547
example: 'user123'
548+
nickname:
549+
type: string
550+
description: Optional nickname for the order (only first 10 chars displayed)
551+
example: 'John'
541552
items:
542553
type: array
543554
description: List of burger items (maximum 50 burgers total across all items)

packages/burger-api/src/functions/orders-post.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface CreateOrderRequest {
1010
quantity: number;
1111
extraToppingIds?: string[];
1212
}>;
13+
nickname?: string;
1314
}
1415

1516
// Helper function for topping validation
@@ -176,6 +177,7 @@ app.http('orders-post', {
176177
estimatedCompletionAt: estimatedCompletionAt.toISOString(),
177178
totalPrice,
178179
status: OrderStatus.Pending,
180+
nickname: requestBody.nickname,
179181
completedAt: undefined,
180182
});
181183

packages/burger-api/src/order.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface Order {
2020
estimatedCompletionAt: string; // ISO date string for estimated completion time
2121
totalPrice: number;
2222
status: OrderStatus;
23+
nickname?: string; // Optional nickname for the order
2324
readyAt?: string; // ISO date string for when the order was ready (undefined until ready)
2425
completedAt?: string; // ISO date string for when the order was completed (undefined until completed)
2526
}

packages/burger-mcp/src/tools.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const tools = [
7979
description: 'Place a new order with burgers (requires userId)',
8080
schema: z.object({
8181
userId: z.string().describe('ID of the user placing the order'),
82+
nickname: z.string().optional().describe('Optional nickname for the order (only first 10 chars displayed)'),
8283
items: z
8384
.array(
8485
z.object({

packages/burger-webapp/src/components/burger-dashboard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ export class BurgerDashboard extends LitElement {
112112

113113
protected renderOrder = (order: BurgerOrder, isLeaving = false) => {
114114
const animClass = isLeaving ? 'fade-out' : '';
115+
const displayId = order.nickname ? order.nickname.slice(0, 10) : `#${order.id.slice(-6)}`;
115116
return html`
116117
<div
117118
data-order-id="${order.id}"
118119
class="order-anim ${animClass}"
119120
@animationend=${isLeaving ? () => this.handleFadeOutEnd(order.id) : undefined}
120121
>
121122
<div class="${this.getOrderBoxClass(order)}">
122-
<div class="order-id">#${order.id.slice(-6)}</div>
123+
<div class="order-id">${displayId}</div>
123124
<div class="order-status">
124125
<div class="order-status-inner">${this.getOrderDisplayStatus(order)}</div>
125126
</div>

packages/burger-webapp/src/orders.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface BurgerOrder {
99
estimatedCompletionAt: string;
1010
totalPrice: number;
1111
status: string;
12+
nickname?: string;
1213
readyAt?: string;
1314
completedAt?: string;
1415
}

0 commit comments

Comments
 (0)