@vendure/dashboard 3.4.3-master-202509230228 → 3.4.3-master-202509250229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/index.html +11 -12
  2. package/package.json +4 -4
  3. package/src/app/common/use-page-title.test.ts +263 -0
  4. package/src/app/common/use-page-title.ts +86 -0
  5. package/src/app/routes/__root.tsx +4 -4
  6. package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history-container.tsx +2 -2
  7. package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history-types.ts +5 -0
  8. package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history-utils.tsx +124 -0
  9. package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history.tsx +91 -59
  10. package/src/app/routes/_authenticated/_customers/components/customer-history/default-customer-history-components.tsx +176 -0
  11. package/src/app/routes/_authenticated/_customers/components/customer-history/index.ts +4 -2
  12. package/src/app/routes/_authenticated/_customers/customers.graphql.ts +2 -0
  13. package/src/app/routes/_authenticated/_orders/components/order-history/default-order-history-components.tsx +98 -0
  14. package/src/app/routes/_authenticated/_orders/components/order-history/order-history-container.tsx +9 -7
  15. package/src/app/routes/_authenticated/_orders/components/order-history/order-history-types.ts +5 -0
  16. package/src/app/routes/_authenticated/_orders/components/order-history/order-history-utils.tsx +173 -0
  17. package/src/app/routes/_authenticated/_orders/components/order-history/order-history.tsx +64 -408
  18. package/src/app/routes/_authenticated/_orders/orders.graphql.ts +4 -0
  19. package/src/app/routes/_authenticated/_orders/utils/order-detail-loaders.tsx +9 -4
  20. package/src/app/routes/_authenticated/_shipping-methods/components/metadata-badges.tsx +15 -0
  21. package/src/app/routes/_authenticated/_shipping-methods/components/price-display.tsx +21 -0
  22. package/src/app/routes/_authenticated/_shipping-methods/components/shipping-method-test-result-wrapper.tsx +87 -0
  23. package/src/app/routes/_authenticated/_shipping-methods/components/test-address-form.tsx +255 -0
  24. package/src/app/routes/_authenticated/_shipping-methods/components/test-order-builder.tsx +243 -0
  25. package/src/app/routes/_authenticated/_shipping-methods/components/test-shipping-methods-result.tsx +97 -0
  26. package/src/app/routes/_authenticated/_shipping-methods/components/test-shipping-methods-sheet.tsx +41 -0
  27. package/src/app/routes/_authenticated/_shipping-methods/components/test-shipping-methods.tsx +74 -0
  28. package/src/app/routes/_authenticated/_shipping-methods/components/test-single-method-result.tsx +90 -0
  29. package/src/app/routes/_authenticated/_shipping-methods/components/test-single-shipping-method-sheet.tsx +56 -0
  30. package/src/app/routes/_authenticated/_shipping-methods/components/test-single-shipping-method.tsx +82 -0
  31. package/src/app/routes/_authenticated/_shipping-methods/components/use-shipping-method-test-state.ts +67 -0
  32. package/src/app/routes/_authenticated/_shipping-methods/shipping-methods.graphql.ts +27 -0
  33. package/src/app/routes/_authenticated/_shipping-methods/shipping-methods.tsx +2 -2
  34. package/src/app/routes/_authenticated/_shipping-methods/shipping-methods_.$id.tsx +24 -4
  35. package/src/lib/components/shared/history-timeline/history-note-entry.tsx +65 -0
  36. package/src/lib/components/shared/history-timeline/history-timeline-with-grouping.tsx +141 -0
  37. package/src/lib/components/shared/history-timeline/use-history-note-editor.ts +26 -0
  38. package/src/lib/framework/extension-api/define-dashboard-extension.ts +5 -0
  39. package/src/lib/framework/extension-api/extension-api-types.ts +7 -0
  40. package/src/lib/framework/extension-api/logic/history-entries.ts +24 -0
  41. package/src/lib/framework/extension-api/logic/index.ts +1 -0
  42. package/src/lib/framework/extension-api/types/history-entries.ts +120 -0
  43. package/src/lib/framework/extension-api/types/index.ts +1 -0
  44. package/src/lib/framework/history-entry/history-entry-extensions.ts +11 -0
  45. package/src/lib/framework/history-entry/history-entry.tsx +129 -0
  46. package/src/lib/framework/registry/registry-types.ts +2 -0
  47. package/src/lib/index.ts +5 -1
  48. package/src/app/routes/_authenticated/_shipping-methods/components/test-shipping-method-dialog.tsx +0 -32
  49. package/src/lib/components/shared/history-timeline/history-entry.tsx +0 -188
@@ -1,188 +0,0 @@
1
- import { Badge } from '@/vdb/components/ui/badge.js';
2
- import { Button } from '@/vdb/components/ui/button.js';
3
- import {
4
- DropdownMenu,
5
- DropdownMenuContent,
6
- DropdownMenuItem,
7
- DropdownMenuTrigger,
8
- } from '@/vdb/components/ui/dropdown-menu.js';
9
- import { Separator } from '@/vdb/components/ui/separator.js';
10
- import { Trans } from '@/vdb/lib/trans.js';
11
- import { cn } from '@/vdb/lib/utils.js';
12
- import { MoreVerticalIcon, PencilIcon, TrashIcon } from 'lucide-react';
13
- import { HistoryEntryDate } from './history-entry-date.js';
14
-
15
- export interface HistoryEntryItem {
16
- id: string;
17
- type: string;
18
- createdAt: string;
19
- isPublic: boolean;
20
- administrator?: {
21
- id: string;
22
- firstName: string;
23
- lastName: string;
24
- } | null;
25
- data: any;
26
- }
27
-
28
- interface OrderCustomer {
29
- firstName: string;
30
- lastName: string;
31
- }
32
-
33
- interface HistoryEntryProps {
34
- entry: HistoryEntryItem;
35
- isNoteEntry: boolean;
36
- timelineIcon: React.ReactNode;
37
- title: string | React.ReactNode;
38
- children: React.ReactNode;
39
- isPrimary?: boolean;
40
- customer?: OrderCustomer | null;
41
- onEditNote?: (noteId: string, note: string, isPrivate: boolean) => void;
42
- onDeleteNote?: (noteId: string) => void;
43
- }
44
-
45
- export function HistoryEntry({
46
- entry,
47
- isNoteEntry,
48
- timelineIcon,
49
- title,
50
- children,
51
- isPrimary = true,
52
- customer,
53
- onEditNote,
54
- onDeleteNote,
55
- }: Readonly<HistoryEntryProps>) {
56
- const getIconColor = (type: string) => {
57
- // Check for success states (payment settled, order delivered)
58
- if (type === 'ORDER_PAYMENT_TRANSITION' && entry.data.to === 'Settled') {
59
- return 'bg-success text-success-foreground';
60
- }
61
- if (type === 'ORDER_STATE_TRANSITION' && entry.data.to === 'Delivered') {
62
- return 'bg-success text-success-foreground';
63
- }
64
- if (type === 'ORDER_FULFILLMENT_TRANSITION' && entry.data.to === 'Delivered') {
65
- return 'bg-success text-success-foreground';
66
- }
67
-
68
- // Check for destructive states (cancellations)
69
- if (type === 'ORDER_CANCELLATION') {
70
- return 'bg-destructive text-destructive-foreground';
71
- }
72
- if (type === 'ORDER_STATE_TRANSITION' && entry.data.to === 'Cancelled') {
73
- return 'bg-destructive text-destructive-foreground';
74
- }
75
- if (type === 'ORDER_PAYMENT_TRANSITION' && (entry.data.to === 'Declined' || entry.data.to === 'Cancelled')) {
76
- return 'bg-destructive text-destructive-foreground';
77
- }
78
-
79
- // All other entries use neutral colors
80
- return 'bg-muted text-muted-foreground';
81
- };
82
-
83
- const getActorName = () => {
84
- if (entry.administrator) {
85
- return `${entry.administrator.firstName} ${entry.administrator.lastName}`;
86
- } else if (customer) {
87
- return `${customer.firstName} ${customer.lastName}`;
88
- }
89
- return '';
90
- };
91
-
92
- return (
93
- <div key={entry.id} className="relative group">
94
- <div
95
- className={`flex gap-3 p-3 rounded-lg hover:bg-muted/30 transition-colors ${!isPrimary ? 'opacity-75' : ''}`}
96
- >
97
- <div className={cn(`relative z-10 flex-shrink-0 ${isNoteEntry ? 'ml-2' : ''}`, isPrimary ? '-ml-1' : '')}>
98
- <div
99
- className={`rounded-full flex items-center justify-center ${isPrimary ? 'h-8 w-8' : 'h-6 w-6'} ${getIconColor(entry.type)} border-2 border-background ${isPrimary ? 'shadow-sm' : 'shadow-none'}`}
100
- >
101
- <div className={isPrimary ? 'text-current' : 'text-current scale-75'}>
102
- {timelineIcon}
103
- </div>
104
- </div>
105
- </div>
106
-
107
- <div className="flex-1 min-w-0">
108
- <div className="flex items-start justify-between">
109
- <div className="flex-1 min-w-0">
110
- <h4
111
- className={`text-sm ${isPrimary ? 'font-medium text-foreground' : 'font-normal text-muted-foreground'}`}
112
- >
113
- {title}
114
- </h4>
115
- <div className="mt-1">
116
- {entry.type === 'ORDER_NOTE' ? (
117
- <div className={`space-y-${isPrimary ? '2' : '1'}`}>
118
- <p className={`${isPrimary ? 'text-sm' : 'text-xs'} text-foreground`}>
119
- {entry.data.note}
120
- </p>
121
- <div className="flex items-center gap-2">
122
- <Badge
123
- variant={entry.isPublic ? 'outline' : 'secondary'}
124
- className="text-xs"
125
- >
126
- {entry.isPublic ? 'Public' : 'Private'}
127
- </Badge>
128
- {isPrimary && onEditNote && onDeleteNote && (
129
- <DropdownMenu>
130
- <DropdownMenuTrigger asChild>
131
- <Button variant="ghost" size="sm" className="h-6 w-6 p-0">
132
- <MoreVerticalIcon className="h-3 w-3" />
133
- </Button>
134
- </DropdownMenuTrigger>
135
- <DropdownMenuContent align="end">
136
- <DropdownMenuItem
137
- onClick={() => {
138
- onEditNote(
139
- entry.id,
140
- entry.data.note,
141
- !entry.isPublic,
142
- );
143
- }}
144
- className="cursor-pointer"
145
- >
146
- <PencilIcon className="mr-2 h-4 w-4" />
147
- <Trans>Edit</Trans>
148
- </DropdownMenuItem>
149
- <Separator className="my-1" />
150
- <DropdownMenuItem
151
- onClick={() => onDeleteNote(entry.id)}
152
- className="cursor-pointer text-red-600 focus:text-red-600"
153
- >
154
- <TrashIcon className="mr-2 h-4 w-4" />
155
- <span>Delete</span>
156
- </DropdownMenuItem>
157
- </DropdownMenuContent>
158
- </DropdownMenu>
159
- )}
160
- </div>
161
- </div>
162
- ) : (
163
- children
164
- )}
165
- </div>
166
- </div>
167
-
168
- <div className="flex items-center gap-2 ml-4 flex-shrink-0">
169
- <div className="text-right">
170
- <HistoryEntryDate
171
- date={entry.createdAt}
172
- className={`text-xs cursor-help ${isPrimary ? 'text-muted-foreground' : 'text-muted-foreground/70'}`}
173
- />
174
- {getActorName() && (
175
- <div
176
- className={`text-xs ${isPrimary ? 'text-muted-foreground' : 'text-muted-foreground/70'}`}
177
- >
178
- {getActorName()}
179
- </div>
180
- )}
181
- </div>
182
- </div>
183
- </div>
184
- </div>
185
- </div>
186
- </div>
187
- );
188
- }