@j3m-quantum/ui 1.7.0 → 1.8.0
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.
- package/dist/index.cjs +1507 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +375 -1
- package/dist/index.d.ts +375 -1
- package/dist/index.js +1492 -183
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React27 = require('react');
|
|
4
4
|
var reactSlot = require('@radix-ui/react-slot');
|
|
5
5
|
var classVarianceAuthority = require('class-variance-authority');
|
|
6
6
|
var clsx = require('clsx');
|
|
@@ -63,7 +63,7 @@ function _interopNamespace(e) {
|
|
|
63
63
|
return Object.freeze(n);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
var
|
|
66
|
+
var React27__namespace = /*#__PURE__*/_interopNamespace(React27);
|
|
67
67
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
68
68
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
69
69
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
@@ -96,8 +96,8 @@ var ResizablePrimitive__namespace = /*#__PURE__*/_interopNamespace(ResizablePrim
|
|
|
96
96
|
// src/hooks/use-mobile.ts
|
|
97
97
|
var MOBILE_BREAKPOINT = 768;
|
|
98
98
|
function useIsMobile() {
|
|
99
|
-
const [isMobile, setIsMobile] =
|
|
100
|
-
|
|
99
|
+
const [isMobile, setIsMobile] = React27__namespace.useState(void 0);
|
|
100
|
+
React27__namespace.useEffect(() => {
|
|
101
101
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
102
102
|
const onChange = () => {
|
|
103
103
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
@@ -138,7 +138,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
);
|
|
141
|
-
var Button =
|
|
141
|
+
var Button = React27__namespace.forwardRef(
|
|
142
142
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
143
143
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
144
144
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -502,7 +502,7 @@ function Slider({
|
|
|
502
502
|
max = 100,
|
|
503
503
|
...props
|
|
504
504
|
}) {
|
|
505
|
-
const _values =
|
|
505
|
+
const _values = React27__namespace.useMemo(
|
|
506
506
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
507
507
|
[value, defaultValue, min, max]
|
|
508
508
|
);
|
|
@@ -788,7 +788,7 @@ function Toggle({
|
|
|
788
788
|
}
|
|
789
789
|
);
|
|
790
790
|
}
|
|
791
|
-
var ToggleGroupContext =
|
|
791
|
+
var ToggleGroupContext = React27__namespace.createContext({
|
|
792
792
|
size: "default",
|
|
793
793
|
variant: "default",
|
|
794
794
|
spacing: 0
|
|
@@ -825,7 +825,7 @@ function ToggleGroupItem({
|
|
|
825
825
|
size,
|
|
826
826
|
...props
|
|
827
827
|
}) {
|
|
828
|
-
const context =
|
|
828
|
+
const context = React27__namespace.useContext(ToggleGroupContext);
|
|
829
829
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
830
830
|
ToggleGroupPrimitive__namespace.Item,
|
|
831
831
|
{
|
|
@@ -855,7 +855,7 @@ function ThemeSwitch({
|
|
|
855
855
|
className,
|
|
856
856
|
size = "default"
|
|
857
857
|
}) {
|
|
858
|
-
const [isChecked, setIsChecked] =
|
|
858
|
+
const [isChecked, setIsChecked] = React27__namespace.useState(defaultChecked);
|
|
859
859
|
const isControlled = checked !== void 0;
|
|
860
860
|
const currentChecked = isControlled ? checked : isChecked;
|
|
861
861
|
const handleClick = () => {
|
|
@@ -1275,7 +1275,7 @@ function Label2({
|
|
|
1275
1275
|
);
|
|
1276
1276
|
}
|
|
1277
1277
|
var Form = reactHookForm.FormProvider;
|
|
1278
|
-
var FormFieldContext =
|
|
1278
|
+
var FormFieldContext = React27__namespace.createContext(
|
|
1279
1279
|
{}
|
|
1280
1280
|
);
|
|
1281
1281
|
var FormField = ({
|
|
@@ -1284,8 +1284,8 @@ var FormField = ({
|
|
|
1284
1284
|
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.Controller, { ...props }) });
|
|
1285
1285
|
};
|
|
1286
1286
|
var useFormField = () => {
|
|
1287
|
-
const fieldContext =
|
|
1288
|
-
const itemContext =
|
|
1287
|
+
const fieldContext = React27__namespace.useContext(FormFieldContext);
|
|
1288
|
+
const itemContext = React27__namespace.useContext(FormItemContext);
|
|
1289
1289
|
const { getFieldState } = reactHookForm.useFormContext();
|
|
1290
1290
|
const formState = reactHookForm.useFormState({ name: fieldContext.name });
|
|
1291
1291
|
const fieldState = getFieldState(fieldContext.name, formState);
|
|
@@ -1302,11 +1302,11 @@ var useFormField = () => {
|
|
|
1302
1302
|
...fieldState
|
|
1303
1303
|
};
|
|
1304
1304
|
};
|
|
1305
|
-
var FormItemContext =
|
|
1305
|
+
var FormItemContext = React27__namespace.createContext(
|
|
1306
1306
|
{}
|
|
1307
1307
|
);
|
|
1308
1308
|
function FormItem({ className, ...props }) {
|
|
1309
|
-
const id =
|
|
1309
|
+
const id = React27__namespace.useId();
|
|
1310
1310
|
return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1311
1311
|
"div",
|
|
1312
1312
|
{
|
|
@@ -1554,7 +1554,7 @@ function FieldError({
|
|
|
1554
1554
|
errors,
|
|
1555
1555
|
...props
|
|
1556
1556
|
}) {
|
|
1557
|
-
const content =
|
|
1557
|
+
const content = React27.useMemo(() => {
|
|
1558
1558
|
if (children) {
|
|
1559
1559
|
return children;
|
|
1560
1560
|
}
|
|
@@ -2408,8 +2408,8 @@ function CalendarDayButton({
|
|
|
2408
2408
|
modifiers,
|
|
2409
2409
|
...props
|
|
2410
2410
|
}) {
|
|
2411
|
-
const ref =
|
|
2412
|
-
|
|
2411
|
+
const ref = React27__namespace.useRef(null);
|
|
2412
|
+
React27__namespace.useEffect(() => {
|
|
2413
2413
|
if (modifiers.focused) ref.current?.focus();
|
|
2414
2414
|
}, [modifiers.focused]);
|
|
2415
2415
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2430,9 +2430,9 @@ function CalendarDayButton({
|
|
|
2430
2430
|
}
|
|
2431
2431
|
);
|
|
2432
2432
|
}
|
|
2433
|
-
var CarouselContext =
|
|
2433
|
+
var CarouselContext = React27__namespace.createContext(null);
|
|
2434
2434
|
function useCarousel() {
|
|
2435
|
-
const context =
|
|
2435
|
+
const context = React27__namespace.useContext(CarouselContext);
|
|
2436
2436
|
if (!context) {
|
|
2437
2437
|
throw new Error("useCarousel must be used within a <Carousel />");
|
|
2438
2438
|
}
|
|
@@ -2454,20 +2454,20 @@ function Carousel({
|
|
|
2454
2454
|
},
|
|
2455
2455
|
plugins
|
|
2456
2456
|
);
|
|
2457
|
-
const [canScrollPrev, setCanScrollPrev] =
|
|
2458
|
-
const [canScrollNext, setCanScrollNext] =
|
|
2459
|
-
const onSelect =
|
|
2457
|
+
const [canScrollPrev, setCanScrollPrev] = React27__namespace.useState(false);
|
|
2458
|
+
const [canScrollNext, setCanScrollNext] = React27__namespace.useState(false);
|
|
2459
|
+
const onSelect = React27__namespace.useCallback((api2) => {
|
|
2460
2460
|
if (!api2) return;
|
|
2461
2461
|
setCanScrollPrev(api2.canScrollPrev());
|
|
2462
2462
|
setCanScrollNext(api2.canScrollNext());
|
|
2463
2463
|
}, []);
|
|
2464
|
-
const scrollPrev =
|
|
2464
|
+
const scrollPrev = React27__namespace.useCallback(() => {
|
|
2465
2465
|
api?.scrollPrev();
|
|
2466
2466
|
}, [api]);
|
|
2467
|
-
const scrollNext =
|
|
2467
|
+
const scrollNext = React27__namespace.useCallback(() => {
|
|
2468
2468
|
api?.scrollNext();
|
|
2469
2469
|
}, [api]);
|
|
2470
|
-
const handleKeyDown =
|
|
2470
|
+
const handleKeyDown = React27__namespace.useCallback(
|
|
2471
2471
|
(event) => {
|
|
2472
2472
|
if (event.key === "ArrowLeft") {
|
|
2473
2473
|
event.preventDefault();
|
|
@@ -2479,11 +2479,11 @@ function Carousel({
|
|
|
2479
2479
|
},
|
|
2480
2480
|
[scrollPrev, scrollNext]
|
|
2481
2481
|
);
|
|
2482
|
-
|
|
2482
|
+
React27__namespace.useEffect(() => {
|
|
2483
2483
|
if (!api || !setApi) return;
|
|
2484
2484
|
setApi(api);
|
|
2485
2485
|
}, [api, setApi]);
|
|
2486
|
-
|
|
2486
|
+
React27__namespace.useEffect(() => {
|
|
2487
2487
|
if (!api) return;
|
|
2488
2488
|
onSelect(api);
|
|
2489
2489
|
api.on("reInit", onSelect);
|
|
@@ -2616,9 +2616,9 @@ function CarouselNext({
|
|
|
2616
2616
|
);
|
|
2617
2617
|
}
|
|
2618
2618
|
var THEMES = { light: "", dark: ".dark" };
|
|
2619
|
-
var ChartContext =
|
|
2619
|
+
var ChartContext = React27__namespace.createContext(null);
|
|
2620
2620
|
function useChart() {
|
|
2621
|
-
const context =
|
|
2621
|
+
const context = React27__namespace.useContext(ChartContext);
|
|
2622
2622
|
if (!context) {
|
|
2623
2623
|
throw new Error("useChart must be used within a <ChartContainer />");
|
|
2624
2624
|
}
|
|
@@ -2631,7 +2631,7 @@ function ChartContainer({
|
|
|
2631
2631
|
config,
|
|
2632
2632
|
...props
|
|
2633
2633
|
}) {
|
|
2634
|
-
const uniqueId =
|
|
2634
|
+
const uniqueId = React27__namespace.useId();
|
|
2635
2635
|
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
2636
2636
|
return /* @__PURE__ */ jsxRuntime.jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2637
2637
|
"div",
|
|
@@ -2692,7 +2692,7 @@ function ChartTooltipContent({
|
|
|
2692
2692
|
labelKey
|
|
2693
2693
|
}) {
|
|
2694
2694
|
const { config } = useChart();
|
|
2695
|
-
const tooltipLabel =
|
|
2695
|
+
const tooltipLabel = React27__namespace.useMemo(() => {
|
|
2696
2696
|
if (hideLabel || !payload?.length) {
|
|
2697
2697
|
return null;
|
|
2698
2698
|
}
|
|
@@ -3494,8 +3494,8 @@ function TooltipContent({
|
|
|
3494
3494
|
) });
|
|
3495
3495
|
}
|
|
3496
3496
|
function useDetectTheme() {
|
|
3497
|
-
const [theme, setTheme] =
|
|
3498
|
-
|
|
3497
|
+
const [theme, setTheme] = React27__namespace.useState("light");
|
|
3498
|
+
React27__namespace.useEffect(() => {
|
|
3499
3499
|
const isDark = document.documentElement.classList.contains("dark");
|
|
3500
3500
|
setTheme(isDark ? "dark" : "light");
|
|
3501
3501
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -4144,7 +4144,7 @@ function CommandShortcut({
|
|
|
4144
4144
|
}
|
|
4145
4145
|
);
|
|
4146
4146
|
}
|
|
4147
|
-
var SearchTrigger =
|
|
4147
|
+
var SearchTrigger = React27__namespace.forwardRef(
|
|
4148
4148
|
({
|
|
4149
4149
|
className,
|
|
4150
4150
|
placeholder = "Search...",
|
|
@@ -4180,7 +4180,7 @@ var SearchTrigger = React22__namespace.forwardRef(
|
|
|
4180
4180
|
);
|
|
4181
4181
|
SearchTrigger.displayName = "SearchTrigger";
|
|
4182
4182
|
function useSearchShortcut(onOpen, key = "k") {
|
|
4183
|
-
|
|
4183
|
+
React27__namespace.useEffect(() => {
|
|
4184
4184
|
const down = (e) => {
|
|
4185
4185
|
if (e.key.toLowerCase() === key.toLowerCase() && (e.metaKey || e.ctrlKey)) {
|
|
4186
4186
|
e.preventDefault();
|
|
@@ -5155,9 +5155,9 @@ var SIDEBAR_WIDTH = "16rem";
|
|
|
5155
5155
|
var SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
5156
5156
|
var SIDEBAR_WIDTH_ICON = "3rem";
|
|
5157
5157
|
var SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
5158
|
-
var SidebarContext =
|
|
5158
|
+
var SidebarContext = React27__namespace.createContext(null);
|
|
5159
5159
|
function useSidebar() {
|
|
5160
|
-
const context =
|
|
5160
|
+
const context = React27__namespace.useContext(SidebarContext);
|
|
5161
5161
|
if (!context) {
|
|
5162
5162
|
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
5163
5163
|
}
|
|
@@ -5173,10 +5173,10 @@ function SidebarProvider({
|
|
|
5173
5173
|
...props
|
|
5174
5174
|
}) {
|
|
5175
5175
|
const isMobile = useIsMobile();
|
|
5176
|
-
const [openMobile, setOpenMobile] =
|
|
5177
|
-
const [_open, _setOpen] =
|
|
5176
|
+
const [openMobile, setOpenMobile] = React27__namespace.useState(false);
|
|
5177
|
+
const [_open, _setOpen] = React27__namespace.useState(defaultOpen);
|
|
5178
5178
|
const open = openProp ?? _open;
|
|
5179
|
-
const setOpen =
|
|
5179
|
+
const setOpen = React27__namespace.useCallback(
|
|
5180
5180
|
(value) => {
|
|
5181
5181
|
const openState = typeof value === "function" ? value(open) : value;
|
|
5182
5182
|
if (setOpenProp) {
|
|
@@ -5188,10 +5188,10 @@ function SidebarProvider({
|
|
|
5188
5188
|
},
|
|
5189
5189
|
[setOpenProp, open]
|
|
5190
5190
|
);
|
|
5191
|
-
const toggleSidebar =
|
|
5191
|
+
const toggleSidebar = React27__namespace.useCallback(() => {
|
|
5192
5192
|
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
5193
5193
|
}, [isMobile, setOpen, setOpenMobile]);
|
|
5194
|
-
|
|
5194
|
+
React27__namespace.useEffect(() => {
|
|
5195
5195
|
const handleKeyDown = (event) => {
|
|
5196
5196
|
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
5197
5197
|
event.preventDefault();
|
|
@@ -5202,7 +5202,7 @@ function SidebarProvider({
|
|
|
5202
5202
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
5203
5203
|
}, [toggleSidebar]);
|
|
5204
5204
|
const state = open ? "expanded" : "collapsed";
|
|
5205
|
-
const contextValue =
|
|
5205
|
+
const contextValue = React27__namespace.useMemo(
|
|
5206
5206
|
() => ({
|
|
5207
5207
|
state,
|
|
5208
5208
|
open,
|
|
@@ -5660,7 +5660,7 @@ function SidebarMenuSkeleton({
|
|
|
5660
5660
|
showIcon = false,
|
|
5661
5661
|
...props
|
|
5662
5662
|
}) {
|
|
5663
|
-
const width =
|
|
5663
|
+
const width = React27__namespace.useMemo(() => {
|
|
5664
5664
|
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
5665
5665
|
}, []);
|
|
5666
5666
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -5803,7 +5803,7 @@ var sectionVariants = classVarianceAuthority.cva(
|
|
|
5803
5803
|
}
|
|
5804
5804
|
);
|
|
5805
5805
|
var isGlassVariant = (variant) => variant?.startsWith("glass-") ?? false;
|
|
5806
|
-
var Section =
|
|
5806
|
+
var Section = React27__namespace.forwardRef(
|
|
5807
5807
|
({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5808
5808
|
"section",
|
|
5809
5809
|
{
|
|
@@ -5815,7 +5815,7 @@ var Section = React22__namespace.forwardRef(
|
|
|
5815
5815
|
)
|
|
5816
5816
|
);
|
|
5817
5817
|
Section.displayName = "Section";
|
|
5818
|
-
var SectionHeader =
|
|
5818
|
+
var SectionHeader = React27__namespace.forwardRef(
|
|
5819
5819
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5820
5820
|
"div",
|
|
5821
5821
|
{
|
|
@@ -5830,7 +5830,7 @@ var SectionHeader = React22__namespace.forwardRef(
|
|
|
5830
5830
|
)
|
|
5831
5831
|
);
|
|
5832
5832
|
SectionHeader.displayName = "SectionHeader";
|
|
5833
|
-
var SectionTitle =
|
|
5833
|
+
var SectionTitle = React27__namespace.forwardRef(
|
|
5834
5834
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5835
5835
|
"h2",
|
|
5836
5836
|
{
|
|
@@ -5844,7 +5844,7 @@ var SectionTitle = React22__namespace.forwardRef(
|
|
|
5844
5844
|
)
|
|
5845
5845
|
);
|
|
5846
5846
|
SectionTitle.displayName = "SectionTitle";
|
|
5847
|
-
var SectionDescription =
|
|
5847
|
+
var SectionDescription = React27__namespace.forwardRef(
|
|
5848
5848
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5849
5849
|
"p",
|
|
5850
5850
|
{
|
|
@@ -5858,7 +5858,7 @@ var SectionDescription = React22__namespace.forwardRef(
|
|
|
5858
5858
|
)
|
|
5859
5859
|
);
|
|
5860
5860
|
SectionDescription.displayName = "SectionDescription";
|
|
5861
|
-
var SectionContent =
|
|
5861
|
+
var SectionContent = React27__namespace.forwardRef(
|
|
5862
5862
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5863
5863
|
"div",
|
|
5864
5864
|
{
|
|
@@ -5872,7 +5872,7 @@ var SectionContent = React22__namespace.forwardRef(
|
|
|
5872
5872
|
)
|
|
5873
5873
|
);
|
|
5874
5874
|
SectionContent.displayName = "SectionContent";
|
|
5875
|
-
var SectionFooter =
|
|
5875
|
+
var SectionFooter = React27__namespace.forwardRef(
|
|
5876
5876
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5877
5877
|
"div",
|
|
5878
5878
|
{
|
|
@@ -6097,7 +6097,7 @@ function SiteHeader({
|
|
|
6097
6097
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-[var(--header-height,3.5rem)] w-full items-center gap-[var(--j3m-spacing-s)] px-[var(--j3m-spacing-m)]", children: [
|
|
6098
6098
|
trigger,
|
|
6099
6099
|
trigger && /* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "vertical", className: "mr-[var(--j3m-spacing-s)] h-4" }),
|
|
6100
|
-
/* @__PURE__ */ jsxRuntime.jsx(Breadcrumb, { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbList, { children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6100
|
+
/* @__PURE__ */ jsxRuntime.jsx(Breadcrumb, { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbList, { children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React27__namespace.Fragment, { children: [
|
|
6101
6101
|
index > 0 && /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbSeparator, {}),
|
|
6102
6102
|
/* @__PURE__ */ jsxRuntime.jsx(BreadcrumbItem, { children: item.href ? /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbLink, { href: item.href, children: item.label }) : /* @__PURE__ */ jsxRuntime.jsx(BreadcrumbPage, { children: item.label }) })
|
|
6103
6103
|
] }, index)) }) }),
|
|
@@ -6704,11 +6704,11 @@ function PlanningWeekCommentPopover({
|
|
|
6704
6704
|
open,
|
|
6705
6705
|
onOpenChange
|
|
6706
6706
|
}) {
|
|
6707
|
-
const [newCommentText, setNewCommentText] =
|
|
6708
|
-
const [selectedLocationId, setSelectedLocationId] =
|
|
6709
|
-
const [viewCommentsOpen, setViewCommentsOpen] =
|
|
6710
|
-
const [showAddForm, setShowAddForm] =
|
|
6711
|
-
const selectedLocation =
|
|
6707
|
+
const [newCommentText, setNewCommentText] = React27__namespace.useState("");
|
|
6708
|
+
const [selectedLocationId, setSelectedLocationId] = React27__namespace.useState("");
|
|
6709
|
+
const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
|
|
6710
|
+
const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
|
|
6711
|
+
const selectedLocation = React27__namespace.useMemo(() => {
|
|
6712
6712
|
return locationOptions.find((opt) => opt.id === selectedLocationId);
|
|
6713
6713
|
}, [locationOptions, selectedLocationId]);
|
|
6714
6714
|
const handleSubmit = () => {
|
|
@@ -6752,8 +6752,8 @@ function PlanningWeekCommentPopover({
|
|
|
6752
6752
|
minute: "2-digit"
|
|
6753
6753
|
}).format(date);
|
|
6754
6754
|
};
|
|
6755
|
-
const prevOpenRef =
|
|
6756
|
-
|
|
6755
|
+
const prevOpenRef = React27__namespace.useRef(open);
|
|
6756
|
+
React27__namespace.useEffect(() => {
|
|
6757
6757
|
const wasOpen = prevOpenRef.current;
|
|
6758
6758
|
prevOpenRef.current = open;
|
|
6759
6759
|
if (wasOpen && !open) {
|
|
@@ -6776,7 +6776,7 @@ function PlanningWeekCommentPopover({
|
|
|
6776
6776
|
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
|
|
6777
6777
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: weekLabel })
|
|
6778
6778
|
] }),
|
|
6779
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2
|
|
6779
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
|
|
6780
6780
|
/* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
|
|
6781
6781
|
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
|
|
6782
6782
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium", children: [
|
|
@@ -7107,22 +7107,22 @@ function PlanningTable({
|
|
|
7107
7107
|
stickySupplierColumn = true,
|
|
7108
7108
|
maxHeight = "600px"
|
|
7109
7109
|
} = config;
|
|
7110
|
-
const weeks =
|
|
7110
|
+
const weeks = React27__namespace.useMemo(
|
|
7111
7111
|
() => generateWeeks(startDate, weekCount),
|
|
7112
7112
|
[startDate, weekCount]
|
|
7113
7113
|
);
|
|
7114
|
-
const currentWeekKey =
|
|
7114
|
+
const currentWeekKey = React27__namespace.useMemo(() => {
|
|
7115
7115
|
const currentWeek = weeks.find((w) => w.isCurrentWeek);
|
|
7116
7116
|
return currentWeek ? getWeekKey(currentWeek.startDate) : null;
|
|
7117
7117
|
}, [weeks]);
|
|
7118
|
-
const columns =
|
|
7118
|
+
const columns = React27__namespace.useMemo(
|
|
7119
7119
|
() => generateColumns(weeks, config, suppliers),
|
|
7120
7120
|
[weeks, config, suppliers]
|
|
7121
7121
|
);
|
|
7122
|
-
const [sorting, setSorting] =
|
|
7123
|
-
const [columnFilters, setColumnFilters] =
|
|
7124
|
-
const [columnVisibility, setColumnVisibility] =
|
|
7125
|
-
const [rowSelection, setRowSelection] =
|
|
7122
|
+
const [sorting, setSorting] = React27__namespace.useState([]);
|
|
7123
|
+
const [columnFilters, setColumnFilters] = React27__namespace.useState([]);
|
|
7124
|
+
const [columnVisibility, setColumnVisibility] = React27__namespace.useState({});
|
|
7125
|
+
const [rowSelection, setRowSelection] = React27__namespace.useState({});
|
|
7126
7126
|
const table = reactTable.useReactTable({
|
|
7127
7127
|
data: suppliers,
|
|
7128
7128
|
columns,
|
|
@@ -7329,10 +7329,10 @@ function DeliveryCommentPopover({
|
|
|
7329
7329
|
onAddComment,
|
|
7330
7330
|
deliveryLabel
|
|
7331
7331
|
}) {
|
|
7332
|
-
const [open, setOpen] =
|
|
7333
|
-
const [newCommentText, setNewCommentText] =
|
|
7334
|
-
const [viewCommentsOpen, setViewCommentsOpen] =
|
|
7335
|
-
const [showAddForm, setShowAddForm] =
|
|
7332
|
+
const [open, setOpen] = React27__namespace.useState(false);
|
|
7333
|
+
const [newCommentText, setNewCommentText] = React27__namespace.useState("");
|
|
7334
|
+
const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
|
|
7335
|
+
const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
|
|
7336
7336
|
const handleSubmit = () => {
|
|
7337
7337
|
if (newCommentText.trim() && onAddComment) {
|
|
7338
7338
|
onAddComment(newCommentText.trim());
|
|
@@ -7359,8 +7359,8 @@ function DeliveryCommentPopover({
|
|
|
7359
7359
|
minute: "2-digit"
|
|
7360
7360
|
}).format(date);
|
|
7361
7361
|
};
|
|
7362
|
-
const prevOpenRef =
|
|
7363
|
-
|
|
7362
|
+
const prevOpenRef = React27__namespace.useRef(open);
|
|
7363
|
+
React27__namespace.useEffect(() => {
|
|
7364
7364
|
const wasOpen = prevOpenRef.current;
|
|
7365
7365
|
prevOpenRef.current = open;
|
|
7366
7366
|
if (wasOpen && !open) {
|
|
@@ -7382,7 +7382,7 @@ function DeliveryCommentPopover({
|
|
|
7382
7382
|
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
|
|
7383
7383
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: deliveryLabel })
|
|
7384
7384
|
] }),
|
|
7385
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2
|
|
7385
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
|
|
7386
7386
|
/* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
|
|
7387
7387
|
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
|
|
7388
7388
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium", children: [
|
|
@@ -7472,8 +7472,8 @@ function ProductionCommentSection({
|
|
|
7472
7472
|
comments = [],
|
|
7473
7473
|
onAddComment
|
|
7474
7474
|
}) {
|
|
7475
|
-
const [showAddForm, setShowAddForm] =
|
|
7476
|
-
const [newComment, setNewComment] =
|
|
7475
|
+
const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
|
|
7476
|
+
const [newComment, setNewComment] = React27__namespace.useState("");
|
|
7477
7477
|
const handleSubmit = () => {
|
|
7478
7478
|
if (newComment.trim() && onAddComment) {
|
|
7479
7479
|
onAddComment(newComment.trim());
|
|
@@ -7629,7 +7629,7 @@ function DeliveryDetailsView({
|
|
|
7629
7629
|
onAddComment
|
|
7630
7630
|
}) {
|
|
7631
7631
|
const elements = delivery.elements ?? [];
|
|
7632
|
-
const categorizedElements =
|
|
7632
|
+
const categorizedElements = React27__namespace.useMemo(() => {
|
|
7633
7633
|
const sent = [];
|
|
7634
7634
|
const notSent = [];
|
|
7635
7635
|
const moved = [];
|
|
@@ -7997,15 +7997,15 @@ function WeekDetailDialog({
|
|
|
7997
7997
|
}) {
|
|
7998
7998
|
const production = data?.production;
|
|
7999
7999
|
const initialProduced = production?.produced ?? 0;
|
|
8000
|
-
const [producedValue, setProducedValue] =
|
|
8001
|
-
const [hasChanges, setHasChanges] =
|
|
8002
|
-
const [selectedDelivery, setSelectedDelivery] =
|
|
8003
|
-
|
|
8000
|
+
const [producedValue, setProducedValue] = React27__namespace.useState(initialProduced.toString());
|
|
8001
|
+
const [hasChanges, setHasChanges] = React27__namespace.useState(false);
|
|
8002
|
+
const [selectedDelivery, setSelectedDelivery] = React27__namespace.useState(null);
|
|
8003
|
+
React27__namespace.useEffect(() => {
|
|
8004
8004
|
const newProduced = data?.production?.produced ?? 0;
|
|
8005
8005
|
setProducedValue(newProduced.toString());
|
|
8006
8006
|
setHasChanges(false);
|
|
8007
8007
|
}, [data]);
|
|
8008
|
-
|
|
8008
|
+
React27__namespace.useEffect(() => {
|
|
8009
8009
|
if (!open) {
|
|
8010
8010
|
setSelectedDelivery(null);
|
|
8011
8011
|
}
|
|
@@ -8227,13 +8227,13 @@ function CalibrationWeekCell({
|
|
|
8227
8227
|
onAddClick,
|
|
8228
8228
|
...props
|
|
8229
8229
|
}) {
|
|
8230
|
-
const inputRef =
|
|
8231
|
-
const [localValue, setLocalValue] =
|
|
8230
|
+
const inputRef = React27__namespace.useRef(null);
|
|
8231
|
+
const [localValue, setLocalValue] = React27__namespace.useState(
|
|
8232
8232
|
data.entered !== null ? String(data.entered) : ""
|
|
8233
8233
|
);
|
|
8234
|
-
const [isHovered, setIsHovered] =
|
|
8235
|
-
const [isEditing, setIsEditing] =
|
|
8236
|
-
|
|
8234
|
+
const [isHovered, setIsHovered] = React27__namespace.useState(false);
|
|
8235
|
+
const [isEditing, setIsEditing] = React27__namespace.useState(false);
|
|
8236
|
+
React27__namespace.useEffect(() => {
|
|
8237
8237
|
setLocalValue(data.entered !== null ? String(data.entered) : "");
|
|
8238
8238
|
}, [data.entered]);
|
|
8239
8239
|
const unitLabel = formatCalibrationUnit(unit);
|
|
@@ -8419,11 +8419,11 @@ function CommentPopover({
|
|
|
8419
8419
|
open,
|
|
8420
8420
|
onOpenChange
|
|
8421
8421
|
}) {
|
|
8422
|
-
const [newCommentText, setNewCommentText] =
|
|
8423
|
-
const [selectedPrefixId, setSelectedPrefixId] =
|
|
8424
|
-
const [viewCommentsOpen, setViewCommentsOpen] =
|
|
8425
|
-
const [showAddForm, setShowAddForm] =
|
|
8426
|
-
const selectedPrefixName =
|
|
8422
|
+
const [newCommentText, setNewCommentText] = React27__namespace.useState("");
|
|
8423
|
+
const [selectedPrefixId, setSelectedPrefixId] = React27__namespace.useState("");
|
|
8424
|
+
const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
|
|
8425
|
+
const [showAddForm, setShowAddForm] = React27__namespace.useState(false);
|
|
8426
|
+
const selectedPrefixName = React27__namespace.useMemo(() => {
|
|
8427
8427
|
const prefix = availablePrefixes.find((p) => p.id === selectedPrefixId);
|
|
8428
8428
|
return prefix?.name ?? "";
|
|
8429
8429
|
}, [availablePrefixes, selectedPrefixId]);
|
|
@@ -8455,8 +8455,8 @@ function CommentPopover({
|
|
|
8455
8455
|
minute: "2-digit"
|
|
8456
8456
|
}).format(date);
|
|
8457
8457
|
};
|
|
8458
|
-
const prevOpenRef =
|
|
8459
|
-
|
|
8458
|
+
const prevOpenRef = React27__namespace.useRef(open);
|
|
8459
|
+
React27__namespace.useEffect(() => {
|
|
8460
8460
|
const wasOpen = prevOpenRef.current;
|
|
8461
8461
|
prevOpenRef.current = open;
|
|
8462
8462
|
if (wasOpen && !open) {
|
|
@@ -8479,7 +8479,7 @@ function CommentPopover({
|
|
|
8479
8479
|
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-sm font-semibold", children: "Comments" }),
|
|
8480
8480
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: weekLabel })
|
|
8481
8481
|
] }),
|
|
8482
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2
|
|
8482
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 space-y-2 h-fit overflow-y-auto", children: [
|
|
8483
8483
|
/* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
|
|
8484
8484
|
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8485
8485
|
Button,
|
|
@@ -8685,7 +8685,7 @@ function CalibrationTable({
|
|
|
8685
8685
|
onAddComment,
|
|
8686
8686
|
onAddEarlierWeek
|
|
8687
8687
|
} = config;
|
|
8688
|
-
const calculatedStartDate =
|
|
8688
|
+
const calculatedStartDate = React27__namespace.useMemo(() => {
|
|
8689
8689
|
if (startDate) return startDate;
|
|
8690
8690
|
let earliest = null;
|
|
8691
8691
|
for (const prefix of prefixes) {
|
|
@@ -8706,31 +8706,31 @@ function CalibrationTable({
|
|
|
8706
8706
|
}
|
|
8707
8707
|
return earliest ?? /* @__PURE__ */ new Date();
|
|
8708
8708
|
}, [startDate, prefixes]);
|
|
8709
|
-
const [additionalWeeks, setAdditionalWeeks] =
|
|
8710
|
-
const weeks =
|
|
8709
|
+
const [additionalWeeks, setAdditionalWeeks] = React27__namespace.useState(0);
|
|
8710
|
+
const weeks = React27__namespace.useMemo(() => {
|
|
8711
8711
|
const start = new Date(calculatedStartDate);
|
|
8712
8712
|
start.setDate(start.getDate() - additionalWeeks * 7);
|
|
8713
8713
|
return generateWeeks(start, weekCount + additionalWeeks);
|
|
8714
8714
|
}, [calculatedStartDate, weekCount, additionalWeeks]);
|
|
8715
|
-
|
|
8715
|
+
React27__namespace.useMemo(() => {
|
|
8716
8716
|
const currentWeek = weeks.find((w) => w.isCurrentWeek);
|
|
8717
8717
|
return currentWeek ? getWeekKey(currentWeek.startDate) : null;
|
|
8718
8718
|
}, [weeks]);
|
|
8719
|
-
const [currentPage, setCurrentPage] =
|
|
8720
|
-
const [pageSize, setPageSize] =
|
|
8721
|
-
const [searchQuery, setSearchQuery] =
|
|
8722
|
-
const filteredPrefixes =
|
|
8719
|
+
const [currentPage, setCurrentPage] = React27__namespace.useState(0);
|
|
8720
|
+
const [pageSize, setPageSize] = React27__namespace.useState(defaultPageSize);
|
|
8721
|
+
const [searchQuery, setSearchQuery] = React27__namespace.useState("");
|
|
8722
|
+
const filteredPrefixes = React27__namespace.useMemo(() => {
|
|
8723
8723
|
if (!searchQuery) return prefixes;
|
|
8724
8724
|
const query = searchQuery.toLowerCase();
|
|
8725
8725
|
return prefixes.filter(
|
|
8726
8726
|
(p) => p.name.toLowerCase().includes(query) || p.typeCode.toLowerCase().includes(query)
|
|
8727
8727
|
);
|
|
8728
8728
|
}, [prefixes, searchQuery]);
|
|
8729
|
-
const paginatedPrefixes =
|
|
8729
|
+
const paginatedPrefixes = React27__namespace.useMemo(() => {
|
|
8730
8730
|
const start = currentPage * pageSize;
|
|
8731
8731
|
return filteredPrefixes.slice(start, start + pageSize);
|
|
8732
8732
|
}, [filteredPrefixes, currentPage, pageSize]);
|
|
8733
|
-
|
|
8733
|
+
React27__namespace.useMemo(
|
|
8734
8734
|
() => canSubmitCalibration(prefixes),
|
|
8735
8735
|
[prefixes]
|
|
8736
8736
|
);
|
|
@@ -8754,7 +8754,7 @@ function CalibrationTable({
|
|
|
8754
8754
|
}
|
|
8755
8755
|
return allComments;
|
|
8756
8756
|
};
|
|
8757
|
-
const availablePrefixes =
|
|
8757
|
+
const availablePrefixes = React27__namespace.useMemo(
|
|
8758
8758
|
() => prefixes.map((p) => ({ id: p.id, name: p.name })),
|
|
8759
8759
|
[prefixes]
|
|
8760
8760
|
);
|
|
@@ -8991,14 +8991,14 @@ function CommentDialog({
|
|
|
8991
8991
|
open,
|
|
8992
8992
|
onOpenChange
|
|
8993
8993
|
}) {
|
|
8994
|
-
const [selectedPrefixId, setSelectedPrefixId] =
|
|
8995
|
-
const [selectedWeekKey, setSelectedWeekKey] =
|
|
8996
|
-
const [commentText, setCommentText] =
|
|
8997
|
-
const currentWeek =
|
|
8994
|
+
const [selectedPrefixId, setSelectedPrefixId] = React27__namespace.useState("");
|
|
8995
|
+
const [selectedWeekKey, setSelectedWeekKey] = React27__namespace.useState("");
|
|
8996
|
+
const [commentText, setCommentText] = React27__namespace.useState("");
|
|
8997
|
+
const currentWeek = React27__namespace.useMemo(
|
|
8998
8998
|
() => weeks.find((w) => w.isCurrentWeek),
|
|
8999
8999
|
[weeks]
|
|
9000
9000
|
);
|
|
9001
|
-
|
|
9001
|
+
React27__namespace.useEffect(() => {
|
|
9002
9002
|
if (open) {
|
|
9003
9003
|
setSelectedPrefixId(prefixes[0]?.id ?? "");
|
|
9004
9004
|
setSelectedWeekKey(currentWeek ? getWeekKey(currentWeek.startDate) : weeks[0] ? getWeekKey(weeks[0].startDate) : "");
|
|
@@ -9169,6 +9169,1315 @@ function SubmitCalibrationBar({
|
|
|
9169
9169
|
);
|
|
9170
9170
|
}
|
|
9171
9171
|
|
|
9172
|
+
// src/blocks/supplier-weekly-loading/types.ts
|
|
9173
|
+
function getLoadingElementStatusLabel(status) {
|
|
9174
|
+
switch (status) {
|
|
9175
|
+
case "loaded":
|
|
9176
|
+
return "Loaded";
|
|
9177
|
+
case "missing":
|
|
9178
|
+
return "Missing";
|
|
9179
|
+
case "moved":
|
|
9180
|
+
return "Moved to another delivery";
|
|
9181
|
+
case "addon":
|
|
9182
|
+
return "Add-on";
|
|
9183
|
+
default:
|
|
9184
|
+
return status;
|
|
9185
|
+
}
|
|
9186
|
+
}
|
|
9187
|
+
function getLoadingDeliveryStatusLabel(status) {
|
|
9188
|
+
switch (status) {
|
|
9189
|
+
case "planned":
|
|
9190
|
+
return "Planned";
|
|
9191
|
+
case "in_progress":
|
|
9192
|
+
return "In Progress";
|
|
9193
|
+
case "loaded":
|
|
9194
|
+
return "Loaded";
|
|
9195
|
+
case "shipped":
|
|
9196
|
+
return "Shipped";
|
|
9197
|
+
case "delivered":
|
|
9198
|
+
return "Delivered";
|
|
9199
|
+
case "cancelled":
|
|
9200
|
+
return "Cancelled";
|
|
9201
|
+
default:
|
|
9202
|
+
return status;
|
|
9203
|
+
}
|
|
9204
|
+
}
|
|
9205
|
+
function getDeliveryVisualState(delivery) {
|
|
9206
|
+
if (delivery.status === "shipped" || delivery.status === "delivered") {
|
|
9207
|
+
return "sent";
|
|
9208
|
+
}
|
|
9209
|
+
if (delivery.isReadyToUnload) {
|
|
9210
|
+
return "ready";
|
|
9211
|
+
}
|
|
9212
|
+
return "normal";
|
|
9213
|
+
}
|
|
9214
|
+
function getLoadingISOWeek(date) {
|
|
9215
|
+
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
9216
|
+
const dayNum = d.getUTCDay() || 7;
|
|
9217
|
+
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
|
|
9218
|
+
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
|
9219
|
+
return Math.ceil(((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
|
|
9220
|
+
}
|
|
9221
|
+
function getLoadingWeekKey(date) {
|
|
9222
|
+
const year = date.getFullYear();
|
|
9223
|
+
const weekNumber = getLoadingISOWeek(date);
|
|
9224
|
+
return `${year}-W${weekNumber.toString().padStart(2, "0")}`;
|
|
9225
|
+
}
|
|
9226
|
+
function generateLoadingWeek(date) {
|
|
9227
|
+
const monday = new Date(date);
|
|
9228
|
+
const day = monday.getDay();
|
|
9229
|
+
const diff = monday.getDate() - day + (day === 0 ? -6 : 1);
|
|
9230
|
+
monday.setDate(diff);
|
|
9231
|
+
monday.setHours(0, 0, 0, 0);
|
|
9232
|
+
const friday = new Date(monday);
|
|
9233
|
+
friday.setDate(monday.getDate() + 4);
|
|
9234
|
+
const today = /* @__PURE__ */ new Date();
|
|
9235
|
+
today.setHours(0, 0, 0, 0);
|
|
9236
|
+
const isCurrentWeek = monday <= today && today <= friday;
|
|
9237
|
+
const formatDate2 = (d) => {
|
|
9238
|
+
return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
9239
|
+
};
|
|
9240
|
+
return {
|
|
9241
|
+
weekKey: getLoadingWeekKey(monday),
|
|
9242
|
+
label: `W${getLoadingISOWeek(monday).toString().padStart(2, "0")}`,
|
|
9243
|
+
startDate: monday,
|
|
9244
|
+
endDate: friday,
|
|
9245
|
+
dateRange: `${formatDate2(monday)} - ${formatDate2(friday)}`,
|
|
9246
|
+
isCurrentWeek
|
|
9247
|
+
};
|
|
9248
|
+
}
|
|
9249
|
+
function groupDeliveriesByDay(deliveries) {
|
|
9250
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
9251
|
+
for (let i = 1; i <= 5; i++) {
|
|
9252
|
+
grouped.set(i, []);
|
|
9253
|
+
}
|
|
9254
|
+
for (const delivery of deliveries) {
|
|
9255
|
+
const dayOfWeek = delivery.date.getDay();
|
|
9256
|
+
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
|
|
9257
|
+
const dayDeliveries = grouped.get(dayOfWeek) ?? [];
|
|
9258
|
+
dayDeliveries.push(delivery);
|
|
9259
|
+
grouped.set(dayOfWeek, dayDeliveries);
|
|
9260
|
+
}
|
|
9261
|
+
}
|
|
9262
|
+
return grouped;
|
|
9263
|
+
}
|
|
9264
|
+
function getDayLabel(dayOfWeek) {
|
|
9265
|
+
const labels = {
|
|
9266
|
+
1: "Monday",
|
|
9267
|
+
2: "Tuesday",
|
|
9268
|
+
3: "Wednesday",
|
|
9269
|
+
4: "Thursday",
|
|
9270
|
+
5: "Friday"
|
|
9271
|
+
};
|
|
9272
|
+
return labels[dayOfWeek] ?? "";
|
|
9273
|
+
}
|
|
9274
|
+
function getShortDayLabel(dayOfWeek) {
|
|
9275
|
+
const labels = {
|
|
9276
|
+
1: "Mon",
|
|
9277
|
+
2: "Tue",
|
|
9278
|
+
3: "Wed",
|
|
9279
|
+
4: "Thu",
|
|
9280
|
+
5: "Fri"
|
|
9281
|
+
};
|
|
9282
|
+
return labels[dayOfWeek] ?? "";
|
|
9283
|
+
}
|
|
9284
|
+
function extractPrefixes(deliveries) {
|
|
9285
|
+
const prefixMap = /* @__PURE__ */ new Map();
|
|
9286
|
+
for (const delivery of deliveries) {
|
|
9287
|
+
const prefixCode = delivery.prefixScope ?? "GENERAL";
|
|
9288
|
+
if (!prefixMap.has(prefixCode)) {
|
|
9289
|
+
prefixMap.set(prefixCode, {
|
|
9290
|
+
id: prefixCode,
|
|
9291
|
+
name: prefixCode === "GENERAL" ? "General" : prefixCode,
|
|
9292
|
+
typeCode: prefixCode,
|
|
9293
|
+
supplierId: delivery.supplierId,
|
|
9294
|
+
supplierName: delivery.supplierName,
|
|
9295
|
+
totalDeliveries: 0,
|
|
9296
|
+
sentDeliveries: 0,
|
|
9297
|
+
hasRisk: false
|
|
9298
|
+
});
|
|
9299
|
+
}
|
|
9300
|
+
const prefix = prefixMap.get(prefixCode);
|
|
9301
|
+
prefix.totalDeliveries += 1;
|
|
9302
|
+
if (delivery.status === "shipped" || delivery.status === "delivered") {
|
|
9303
|
+
prefix.sentDeliveries += 1;
|
|
9304
|
+
}
|
|
9305
|
+
if (delivery.hasProductionRisk) {
|
|
9306
|
+
prefix.hasRisk = true;
|
|
9307
|
+
}
|
|
9308
|
+
}
|
|
9309
|
+
return Array.from(prefixMap.values());
|
|
9310
|
+
}
|
|
9311
|
+
function groupDeliveriesByPrefixAndDay(deliveries) {
|
|
9312
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
9313
|
+
for (const delivery of deliveries) {
|
|
9314
|
+
const prefixCode = delivery.prefixScope ?? "GENERAL";
|
|
9315
|
+
const dayOfWeek = delivery.date.getDay();
|
|
9316
|
+
if (dayOfWeek < 1 || dayOfWeek > 5) continue;
|
|
9317
|
+
if (!grouped.has(prefixCode)) {
|
|
9318
|
+
const dayMap2 = /* @__PURE__ */ new Map();
|
|
9319
|
+
for (let i = 1; i <= 5; i++) {
|
|
9320
|
+
dayMap2.set(i, []);
|
|
9321
|
+
}
|
|
9322
|
+
grouped.set(prefixCode, dayMap2);
|
|
9323
|
+
}
|
|
9324
|
+
const dayMap = grouped.get(prefixCode);
|
|
9325
|
+
const dayDeliveries = dayMap.get(dayOfWeek) ?? [];
|
|
9326
|
+
dayDeliveries.push(delivery);
|
|
9327
|
+
dayMap.set(dayOfWeek, dayDeliveries);
|
|
9328
|
+
}
|
|
9329
|
+
return grouped;
|
|
9330
|
+
}
|
|
9331
|
+
function getLeftStrokeStyles(state, hasRisk, isHovered) {
|
|
9332
|
+
if (hasRisk) {
|
|
9333
|
+
return {
|
|
9334
|
+
stroke: "border-l-[3px] border-l-red-500",
|
|
9335
|
+
content: "text-foreground",
|
|
9336
|
+
progressBg: "bg-red-500",
|
|
9337
|
+
iconColor: "text-red-600 dark:text-red-400"
|
|
9338
|
+
};
|
|
9339
|
+
}
|
|
9340
|
+
switch (state) {
|
|
9341
|
+
case "sent":
|
|
9342
|
+
return {
|
|
9343
|
+
stroke: "border-l-[3px] border-l-green-500/50",
|
|
9344
|
+
content: "text-muted-foreground/60",
|
|
9345
|
+
progressBg: "bg-green-500",
|
|
9346
|
+
iconColor: "text-green-600 dark:text-green-400"
|
|
9347
|
+
};
|
|
9348
|
+
case "ready":
|
|
9349
|
+
return {
|
|
9350
|
+
stroke: "border-l-[3px] border-l-green-500",
|
|
9351
|
+
content: "text-foreground",
|
|
9352
|
+
progressBg: "bg-green-500",
|
|
9353
|
+
iconColor: "text-green-600 dark:text-green-400"
|
|
9354
|
+
};
|
|
9355
|
+
default:
|
|
9356
|
+
return {
|
|
9357
|
+
stroke: isHovered ? "border-l-[3px] border-l-primary/50" : "border-l-[3px] border-l-border",
|
|
9358
|
+
content: "text-foreground",
|
|
9359
|
+
progressBg: "bg-primary",
|
|
9360
|
+
iconColor: "text-muted-foreground"
|
|
9361
|
+
};
|
|
9362
|
+
}
|
|
9363
|
+
}
|
|
9364
|
+
function DeliveryBadge({
|
|
9365
|
+
delivery,
|
|
9366
|
+
onClick,
|
|
9367
|
+
className
|
|
9368
|
+
}) {
|
|
9369
|
+
const [isHovered, setIsHovered] = React27__namespace.useState(false);
|
|
9370
|
+
const hasComments = delivery.comments.length > 0;
|
|
9371
|
+
const visualState = getDeliveryVisualState(delivery);
|
|
9372
|
+
const styles = getLeftStrokeStyles(visualState, delivery.hasProductionRisk ?? false, isHovered);
|
|
9373
|
+
const prefixTitle = React27__namespace.useMemo(() => {
|
|
9374
|
+
const prefixSet = /* @__PURE__ */ new Set();
|
|
9375
|
+
if (delivery.elements && delivery.elements.length > 0) {
|
|
9376
|
+
for (const element of delivery.elements) {
|
|
9377
|
+
if (element.prefix) {
|
|
9378
|
+
prefixSet.add(element.prefix);
|
|
9379
|
+
}
|
|
9380
|
+
}
|
|
9381
|
+
}
|
|
9382
|
+
if (prefixSet.size === 0 && delivery.prefixScope) {
|
|
9383
|
+
prefixSet.add(delivery.prefixScope);
|
|
9384
|
+
}
|
|
9385
|
+
const prefixes = Array.from(prefixSet);
|
|
9386
|
+
if (prefixes.length === 0) {
|
|
9387
|
+
return delivery.label;
|
|
9388
|
+
}
|
|
9389
|
+
if (prefixes.length > 3) {
|
|
9390
|
+
return `${prefixes.slice(0, 3).join(" \xB7 ")} \xB7 +${prefixes.length - 3}`;
|
|
9391
|
+
}
|
|
9392
|
+
return prefixes.join(" \xB7 ");
|
|
9393
|
+
}, [delivery]);
|
|
9394
|
+
const productionProgress = React27__namespace.useMemo(() => {
|
|
9395
|
+
if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0 && delivery.totalTons > 0) {
|
|
9396
|
+
return Math.min(delivery.producedTons / delivery.totalTons * 100, 100);
|
|
9397
|
+
}
|
|
9398
|
+
if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0 && delivery.totalCount > 0) {
|
|
9399
|
+
return Math.min(delivery.producedCount / delivery.totalCount * 100, 100);
|
|
9400
|
+
}
|
|
9401
|
+
if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0 && delivery.totalCount > 0) {
|
|
9402
|
+
return Math.min(delivery.loadedCount / delivery.totalCount * 100, 100);
|
|
9403
|
+
}
|
|
9404
|
+
return 0;
|
|
9405
|
+
}, [delivery]);
|
|
9406
|
+
const productionDisplay = React27__namespace.useMemo(() => {
|
|
9407
|
+
if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0) {
|
|
9408
|
+
return `${delivery.producedTons}/${delivery.totalTons}t`;
|
|
9409
|
+
}
|
|
9410
|
+
if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0) {
|
|
9411
|
+
return `${delivery.producedCount}/${delivery.totalCount}`;
|
|
9412
|
+
}
|
|
9413
|
+
if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0) {
|
|
9414
|
+
return `${delivery.loadedCount}/${delivery.totalCount}`;
|
|
9415
|
+
}
|
|
9416
|
+
return null;
|
|
9417
|
+
}, [delivery]);
|
|
9418
|
+
const handleClick = (e) => {
|
|
9419
|
+
e.stopPropagation();
|
|
9420
|
+
onClick?.();
|
|
9421
|
+
};
|
|
9422
|
+
const handleKeyDown = (e) => {
|
|
9423
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9424
|
+
e.preventDefault();
|
|
9425
|
+
e.stopPropagation();
|
|
9426
|
+
onClick?.();
|
|
9427
|
+
}
|
|
9428
|
+
};
|
|
9429
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9430
|
+
"button",
|
|
9431
|
+
{
|
|
9432
|
+
type: "button",
|
|
9433
|
+
onClick: handleClick,
|
|
9434
|
+
onKeyDown: handleKeyDown,
|
|
9435
|
+
onMouseEnter: () => setIsHovered(true),
|
|
9436
|
+
onMouseLeave: () => setIsHovered(false),
|
|
9437
|
+
className: cn(
|
|
9438
|
+
// Position relative for comment dot
|
|
9439
|
+
"relative",
|
|
9440
|
+
// Full-width in cell, 90° corners
|
|
9441
|
+
"w-full rounded-none",
|
|
9442
|
+
// Sizing using Quantum tokens:
|
|
9443
|
+
// - h-[80px] card height
|
|
9444
|
+
// - px-6 = 24px horizontal (j3m.spacing.l)
|
|
9445
|
+
// - py-4 = 16px vertical (j3m.spacing.m)
|
|
9446
|
+
"h-[80px] px-6 py-4",
|
|
9447
|
+
// Layout
|
|
9448
|
+
"flex items-center",
|
|
9449
|
+
// Card base: white background, complete border
|
|
9450
|
+
"bg-background border border-border",
|
|
9451
|
+
// Left stroke for status
|
|
9452
|
+
styles.stroke,
|
|
9453
|
+
// Interactive states
|
|
9454
|
+
"cursor-pointer transition-all duration-200 ease-out",
|
|
9455
|
+
"hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
|
|
9456
|
+
"active:translate-y-0 active:shadow-sm",
|
|
9457
|
+
// Focus state
|
|
9458
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1",
|
|
9459
|
+
// Greyed out for sent state
|
|
9460
|
+
visualState === "sent" && "opacity-60",
|
|
9461
|
+
className
|
|
9462
|
+
),
|
|
9463
|
+
children: [
|
|
9464
|
+
hasComments && /* @__PURE__ */ jsxRuntime.jsx(
|
|
9465
|
+
"span",
|
|
9466
|
+
{
|
|
9467
|
+
className: "absolute -top-1 -right-1 h-3 w-3 rounded-full bg-primary ring-2 ring-background",
|
|
9468
|
+
"aria-label": "Has comments"
|
|
9469
|
+
}
|
|
9470
|
+
),
|
|
9471
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col justify-center gap-3 min-w-0 flex-1 overflow-hidden", children: [
|
|
9472
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 overflow-hidden", children: [
|
|
9473
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm font-semibold truncate", styles.content), children: prefixTitle }),
|
|
9474
|
+
visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
|
|
9475
|
+
delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
|
|
9476
|
+
delivery.supplierName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground truncate ml-auto", children: delivery.supplierName })
|
|
9477
|
+
] }),
|
|
9478
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9479
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Factory, { className: cn("h-3.5 w-3.5 shrink-0", styles.iconColor) }),
|
|
9480
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-1.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9481
|
+
"div",
|
|
9482
|
+
{
|
|
9483
|
+
className: cn("h-full rounded-full transition-all", styles.progressBg),
|
|
9484
|
+
style: { width: `${productionProgress}%` }
|
|
9485
|
+
}
|
|
9486
|
+
) }),
|
|
9487
|
+
productionDisplay && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
9488
|
+
"text-xs tabular-nums font-medium shrink-0",
|
|
9489
|
+
delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
|
|
9490
|
+
), children: productionDisplay })
|
|
9491
|
+
] })
|
|
9492
|
+
] })
|
|
9493
|
+
]
|
|
9494
|
+
}
|
|
9495
|
+
);
|
|
9496
|
+
}
|
|
9497
|
+
function WeeklyLoadingView({
|
|
9498
|
+
week,
|
|
9499
|
+
deliveries,
|
|
9500
|
+
onDeliveryClick,
|
|
9501
|
+
onWeekChange,
|
|
9502
|
+
onDayCommentClick,
|
|
9503
|
+
showNavigation = true,
|
|
9504
|
+
className
|
|
9505
|
+
}) {
|
|
9506
|
+
const weekDays = React27__namespace.useMemo(() => {
|
|
9507
|
+
const days = [];
|
|
9508
|
+
for (let i = 0; i < 5; i++) {
|
|
9509
|
+
const date = dateFns.addDays(week.startDate, i);
|
|
9510
|
+
days.push({
|
|
9511
|
+
date,
|
|
9512
|
+
dayOfWeek: i + 1,
|
|
9513
|
+
isToday: dateFns.isToday(date)
|
|
9514
|
+
});
|
|
9515
|
+
}
|
|
9516
|
+
return days;
|
|
9517
|
+
}, [week.startDate]);
|
|
9518
|
+
const deliveriesByDay = React27__namespace.useMemo(() => {
|
|
9519
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
9520
|
+
for (let i = 1; i <= 5; i++) {
|
|
9521
|
+
grouped.set(i, []);
|
|
9522
|
+
}
|
|
9523
|
+
for (const delivery of deliveries) {
|
|
9524
|
+
const dayOfWeek = delivery.date.getDay();
|
|
9525
|
+
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
|
|
9526
|
+
const dayDeliveries = grouped.get(dayOfWeek) ?? [];
|
|
9527
|
+
dayDeliveries.push(delivery);
|
|
9528
|
+
grouped.set(dayOfWeek, dayDeliveries);
|
|
9529
|
+
}
|
|
9530
|
+
}
|
|
9531
|
+
return grouped;
|
|
9532
|
+
}, [deliveries]);
|
|
9533
|
+
const commentCountByDay = React27__namespace.useMemo(() => {
|
|
9534
|
+
const counts = /* @__PURE__ */ new Map();
|
|
9535
|
+
for (let i = 1; i <= 5; i++) {
|
|
9536
|
+
counts.set(i, 0);
|
|
9537
|
+
}
|
|
9538
|
+
for (const delivery of deliveries) {
|
|
9539
|
+
const dayOfWeek = delivery.date.getDay();
|
|
9540
|
+
if (dayOfWeek >= 1 && dayOfWeek <= 5) {
|
|
9541
|
+
const current = counts.get(dayOfWeek) ?? 0;
|
|
9542
|
+
counts.set(dayOfWeek, current + delivery.comments.length);
|
|
9543
|
+
}
|
|
9544
|
+
}
|
|
9545
|
+
return counts;
|
|
9546
|
+
}, [deliveries]);
|
|
9547
|
+
const totalDeliveries = deliveries.length;
|
|
9548
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col", className), children: [
|
|
9549
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 border-b border-border p-4 lg:flex-row lg:items-center lg:justify-between", children: [
|
|
9550
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
9551
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9552
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
9553
|
+
"text-2xl font-bold tabular-nums",
|
|
9554
|
+
week.isCurrentWeek && "text-primary"
|
|
9555
|
+
), children: week.label }),
|
|
9556
|
+
week.isCurrentWeek && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex h-2.5 w-2.5", children: [
|
|
9557
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75" }),
|
|
9558
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative inline-flex rounded-full h-2.5 w-2.5 bg-primary" })
|
|
9559
|
+
] })
|
|
9560
|
+
] }),
|
|
9561
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
9562
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: week.dateRange }),
|
|
9563
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
9564
|
+
totalDeliveries,
|
|
9565
|
+
" ",
|
|
9566
|
+
totalDeliveries === 1 ? "delivery" : "deliveries"
|
|
9567
|
+
] })
|
|
9568
|
+
] })
|
|
9569
|
+
] }),
|
|
9570
|
+
showNavigation && onWeekChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9571
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9572
|
+
Button,
|
|
9573
|
+
{
|
|
9574
|
+
variant: "outline",
|
|
9575
|
+
size: "icon",
|
|
9576
|
+
className: "h-8 w-8",
|
|
9577
|
+
onClick: () => onWeekChange("prev"),
|
|
9578
|
+
children: [
|
|
9579
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
|
|
9580
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Previous week" })
|
|
9581
|
+
]
|
|
9582
|
+
}
|
|
9583
|
+
),
|
|
9584
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9585
|
+
Button,
|
|
9586
|
+
{
|
|
9587
|
+
variant: "outline",
|
|
9588
|
+
size: "sm",
|
|
9589
|
+
onClick: () => {
|
|
9590
|
+
},
|
|
9591
|
+
children: "Today"
|
|
9592
|
+
}
|
|
9593
|
+
),
|
|
9594
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9595
|
+
Button,
|
|
9596
|
+
{
|
|
9597
|
+
variant: "outline",
|
|
9598
|
+
size: "icon",
|
|
9599
|
+
className: "h-8 w-8",
|
|
9600
|
+
onClick: () => onWeekChange("next"),
|
|
9601
|
+
children: [
|
|
9602
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" }),
|
|
9603
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Next week" })
|
|
9604
|
+
]
|
|
9605
|
+
}
|
|
9606
|
+
)
|
|
9607
|
+
] })
|
|
9608
|
+
] }),
|
|
9609
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ScrollArea, { className: "flex-1", children: [
|
|
9610
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "hidden sm:block", children: [
|
|
9611
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5 border-b border-border bg-muted/30", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
|
|
9612
|
+
const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
|
|
9613
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9614
|
+
"div",
|
|
9615
|
+
{
|
|
9616
|
+
className: cn(
|
|
9617
|
+
// Relative for positioning comment button
|
|
9618
|
+
"relative",
|
|
9619
|
+
// Compact padding: py-2 px-3 (j3m.spacing.xs / j3m.spacing.s)
|
|
9620
|
+
"flex items-center justify-center gap-2 py-2 px-3",
|
|
9621
|
+
dayIsToday && "bg-primary/5"
|
|
9622
|
+
),
|
|
9623
|
+
children: [
|
|
9624
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
9625
|
+
"text-xs font-medium uppercase tracking-wide",
|
|
9626
|
+
dayIsToday ? "text-primary" : "text-muted-foreground"
|
|
9627
|
+
), children: getShortDayLabel(dayOfWeek) }),
|
|
9628
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
9629
|
+
"text-base font-semibold tabular-nums",
|
|
9630
|
+
dayIsToday ? "text-primary" : "text-foreground"
|
|
9631
|
+
), children: date.getDate() }),
|
|
9632
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9633
|
+
Button,
|
|
9634
|
+
{
|
|
9635
|
+
variant: "ghost",
|
|
9636
|
+
size: "icon",
|
|
9637
|
+
className: cn(
|
|
9638
|
+
"absolute top-1 right-1 h-7 w-7",
|
|
9639
|
+
dayCommentCount > 0 && "text-primary"
|
|
9640
|
+
),
|
|
9641
|
+
onClick: (e) => {
|
|
9642
|
+
e.stopPropagation();
|
|
9643
|
+
onDayCommentClick?.(dayOfWeek, date);
|
|
9644
|
+
},
|
|
9645
|
+
children: [
|
|
9646
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
9647
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4" }),
|
|
9648
|
+
dayCommentCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
|
|
9649
|
+
] }),
|
|
9650
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: dayCommentCount > 0 ? `${dayCommentCount} comments on ${getShortDayLabel(dayOfWeek)}` : `Add comment for ${getShortDayLabel(dayOfWeek)}` })
|
|
9651
|
+
]
|
|
9652
|
+
}
|
|
9653
|
+
)
|
|
9654
|
+
]
|
|
9655
|
+
},
|
|
9656
|
+
dayOfWeek
|
|
9657
|
+
);
|
|
9658
|
+
}) }),
|
|
9659
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5", children: weekDays.map(({ dayOfWeek, isToday: dayIsToday }) => {
|
|
9660
|
+
const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
|
|
9661
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9662
|
+
"div",
|
|
9663
|
+
{
|
|
9664
|
+
className: cn(
|
|
9665
|
+
// Column padding: p-3 = 12px (j3m.spacing.s)
|
|
9666
|
+
"flex flex-col p-3",
|
|
9667
|
+
dayIsToday && "bg-primary/5"
|
|
9668
|
+
),
|
|
9669
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9670
|
+
DeliveryBadge,
|
|
9671
|
+
{
|
|
9672
|
+
delivery,
|
|
9673
|
+
onClick: () => onDeliveryClick?.(delivery)
|
|
9674
|
+
},
|
|
9675
|
+
delivery.id
|
|
9676
|
+
)) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-6 text-sm text-muted-foreground/40", children: "\u2014" }) })
|
|
9677
|
+
},
|
|
9678
|
+
dayOfWeek
|
|
9679
|
+
);
|
|
9680
|
+
}) })
|
|
9681
|
+
] }),
|
|
9682
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden divide-y divide-border", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
|
|
9683
|
+
const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
|
|
9684
|
+
const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
|
|
9685
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9686
|
+
"div",
|
|
9687
|
+
{
|
|
9688
|
+
className: cn(
|
|
9689
|
+
dayIsToday && "bg-primary/5"
|
|
9690
|
+
),
|
|
9691
|
+
children: [
|
|
9692
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
|
|
9693
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9694
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
9695
|
+
"text-xs font-medium uppercase",
|
|
9696
|
+
dayIsToday ? "text-primary" : "text-muted-foreground"
|
|
9697
|
+
), children: getShortDayLabel(dayOfWeek) }),
|
|
9698
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
9699
|
+
"text-base font-semibold tabular-nums",
|
|
9700
|
+
dayIsToday ? "text-primary" : "text-foreground"
|
|
9701
|
+
), children: date.getDate() }),
|
|
9702
|
+
dayIsToday && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-primary font-medium", children: "Today" })
|
|
9703
|
+
] }),
|
|
9704
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
9706
|
+
dayDeliveries.length,
|
|
9707
|
+
" ",
|
|
9708
|
+
dayDeliveries.length === 1 ? "delivery" : "deliveries"
|
|
9709
|
+
] }),
|
|
9710
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9711
|
+
Button,
|
|
9712
|
+
{
|
|
9713
|
+
variant: "ghost",
|
|
9714
|
+
size: "icon",
|
|
9715
|
+
className: cn(
|
|
9716
|
+
"h-7 w-7",
|
|
9717
|
+
dayCommentCount > 0 && "text-primary"
|
|
9718
|
+
),
|
|
9719
|
+
onClick: (e) => {
|
|
9720
|
+
e.stopPropagation();
|
|
9721
|
+
onDayCommentClick?.(dayOfWeek, date);
|
|
9722
|
+
},
|
|
9723
|
+
children: [
|
|
9724
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
9725
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4" }),
|
|
9726
|
+
dayCommentCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
|
|
9727
|
+
] }),
|
|
9728
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Comments" })
|
|
9729
|
+
]
|
|
9730
|
+
}
|
|
9731
|
+
)
|
|
9732
|
+
] })
|
|
9733
|
+
] }),
|
|
9734
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3 p-3 pt-0", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9735
|
+
DeliveryBadge,
|
|
9736
|
+
{
|
|
9737
|
+
delivery,
|
|
9738
|
+
onClick: () => onDeliveryClick?.(delivery)
|
|
9739
|
+
},
|
|
9740
|
+
delivery.id
|
|
9741
|
+
)) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground/40 py-4 text-center", children: "\u2014" }) })
|
|
9742
|
+
]
|
|
9743
|
+
},
|
|
9744
|
+
dayOfWeek
|
|
9745
|
+
);
|
|
9746
|
+
}) })
|
|
9747
|
+
] })
|
|
9748
|
+
] });
|
|
9749
|
+
}
|
|
9750
|
+
function getStatusBadgeVariant2(status) {
|
|
9751
|
+
switch (status) {
|
|
9752
|
+
case "shipped":
|
|
9753
|
+
case "delivered":
|
|
9754
|
+
return "default";
|
|
9755
|
+
case "loaded":
|
|
9756
|
+
case "in_progress":
|
|
9757
|
+
return "secondary";
|
|
9758
|
+
case "cancelled":
|
|
9759
|
+
return "destructive";
|
|
9760
|
+
case "planned":
|
|
9761
|
+
default:
|
|
9762
|
+
return "outline";
|
|
9763
|
+
}
|
|
9764
|
+
}
|
|
9765
|
+
function getStatusBadgeClasses2(status) {
|
|
9766
|
+
switch (status) {
|
|
9767
|
+
case "shipped":
|
|
9768
|
+
case "delivered":
|
|
9769
|
+
return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
|
|
9770
|
+
case "loaded":
|
|
9771
|
+
return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
|
|
9772
|
+
case "in_progress":
|
|
9773
|
+
return "border-amber-500 text-amber-600 bg-amber-50 dark:bg-amber-950/50";
|
|
9774
|
+
case "cancelled":
|
|
9775
|
+
return "";
|
|
9776
|
+
case "planned":
|
|
9777
|
+
default:
|
|
9778
|
+
return "border-muted-foreground/50 text-muted-foreground";
|
|
9779
|
+
}
|
|
9780
|
+
}
|
|
9781
|
+
function getElementStatusBadgeClasses(status) {
|
|
9782
|
+
switch (status) {
|
|
9783
|
+
case "loaded":
|
|
9784
|
+
return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
|
|
9785
|
+
case "missing":
|
|
9786
|
+
return "border-muted-foreground/50 text-muted-foreground bg-muted/50";
|
|
9787
|
+
case "moved":
|
|
9788
|
+
return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
|
|
9789
|
+
case "addon":
|
|
9790
|
+
return "border-purple-500 text-purple-600 bg-purple-50 dark:bg-purple-950/50";
|
|
9791
|
+
default:
|
|
9792
|
+
return "border-muted-foreground/50 text-muted-foreground";
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
function getElementRowBg(status) {
|
|
9796
|
+
switch (status) {
|
|
9797
|
+
case "loaded":
|
|
9798
|
+
return "bg-green-50/30 dark:bg-green-950/10";
|
|
9799
|
+
case "missing":
|
|
9800
|
+
return "bg-muted/30";
|
|
9801
|
+
case "moved":
|
|
9802
|
+
return "bg-blue-50/30 dark:bg-blue-950/10";
|
|
9803
|
+
case "addon":
|
|
9804
|
+
return "bg-purple-50/30 dark:bg-purple-950/10";
|
|
9805
|
+
default:
|
|
9806
|
+
return "";
|
|
9807
|
+
}
|
|
9808
|
+
}
|
|
9809
|
+
function AddCommentDialog({
|
|
9810
|
+
open,
|
|
9811
|
+
onOpenChange,
|
|
9812
|
+
delivery,
|
|
9813
|
+
weekId,
|
|
9814
|
+
onAddComment
|
|
9815
|
+
}) {
|
|
9816
|
+
const [commentText, setCommentText] = React27__namespace.useState("");
|
|
9817
|
+
const handleSubmit = () => {
|
|
9818
|
+
if (commentText.trim() && onAddComment) {
|
|
9819
|
+
onAddComment({
|
|
9820
|
+
author: "Current User",
|
|
9821
|
+
// Would come from auth context in real app
|
|
9822
|
+
text: commentText.trim(),
|
|
9823
|
+
context: "pre_unloading",
|
|
9824
|
+
weekId,
|
|
9825
|
+
deliveryId: delivery.id,
|
|
9826
|
+
supplierId: delivery.supplierId,
|
|
9827
|
+
supplierName: delivery.supplierName,
|
|
9828
|
+
prefixId: delivery.prefixScope,
|
|
9829
|
+
prefixName: delivery.prefixScope
|
|
9830
|
+
});
|
|
9831
|
+
setCommentText("");
|
|
9832
|
+
onOpenChange(false);
|
|
9833
|
+
}
|
|
9834
|
+
};
|
|
9835
|
+
const handleKeyDown = (e) => {
|
|
9836
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
9837
|
+
e.preventDefault();
|
|
9838
|
+
handleSubmit();
|
|
9839
|
+
}
|
|
9840
|
+
};
|
|
9841
|
+
React27__namespace.useEffect(() => {
|
|
9842
|
+
if (!open) {
|
|
9843
|
+
setCommentText("");
|
|
9844
|
+
}
|
|
9845
|
+
}, [open]);
|
|
9846
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-md", children: [
|
|
9847
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
|
|
9848
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Add pre-unloading note" }),
|
|
9849
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogDescription, { children: [
|
|
9850
|
+
"Add a note for ",
|
|
9851
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: delivery.label }),
|
|
9852
|
+
" (",
|
|
9853
|
+
delivery.supplierName,
|
|
9854
|
+
delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`,
|
|
9855
|
+
")."
|
|
9856
|
+
] })
|
|
9857
|
+
] }),
|
|
9858
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
9859
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label2, { htmlFor: "comment-text", className: "text-sm font-medium", children: "Note" }),
|
|
9860
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9861
|
+
Textarea,
|
|
9862
|
+
{
|
|
9863
|
+
id: "comment-text",
|
|
9864
|
+
placeholder: "Add a note before unloading...",
|
|
9865
|
+
value: commentText,
|
|
9866
|
+
onChange: (e) => setCommentText(e.target.value),
|
|
9867
|
+
onKeyDown: handleKeyDown,
|
|
9868
|
+
className: "min-h-[120px] text-base resize-none",
|
|
9869
|
+
autoFocus: true
|
|
9870
|
+
}
|
|
9871
|
+
),
|
|
9872
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "\u2318+Enter to save" })
|
|
9873
|
+
] }) }),
|
|
9874
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
9875
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9876
|
+
Button,
|
|
9877
|
+
{
|
|
9878
|
+
variant: "ghost",
|
|
9879
|
+
onClick: () => onOpenChange(false),
|
|
9880
|
+
children: "Cancel"
|
|
9881
|
+
}
|
|
9882
|
+
),
|
|
9883
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9884
|
+
Button,
|
|
9885
|
+
{
|
|
9886
|
+
onClick: handleSubmit,
|
|
9887
|
+
disabled: !commentText.trim(),
|
|
9888
|
+
className: "gap-1.5",
|
|
9889
|
+
children: [
|
|
9890
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "h-4 w-4" }),
|
|
9891
|
+
"Save note"
|
|
9892
|
+
]
|
|
9893
|
+
}
|
|
9894
|
+
)
|
|
9895
|
+
] })
|
|
9896
|
+
] }) });
|
|
9897
|
+
}
|
|
9898
|
+
function CommentsSection({
|
|
9899
|
+
comments,
|
|
9900
|
+
delivery,
|
|
9901
|
+
weekId,
|
|
9902
|
+
onAddComment
|
|
9903
|
+
}) {
|
|
9904
|
+
const [viewCommentsOpen, setViewCommentsOpen] = React27__namespace.useState(true);
|
|
9905
|
+
const [addDialogOpen, setAddDialogOpen] = React27__namespace.useState(false);
|
|
9906
|
+
const formatDate2 = (date) => {
|
|
9907
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
9908
|
+
month: "short",
|
|
9909
|
+
day: "numeric",
|
|
9910
|
+
hour: "numeric",
|
|
9911
|
+
minute: "2-digit"
|
|
9912
|
+
}).format(date);
|
|
9913
|
+
};
|
|
9914
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9915
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
|
|
9916
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9917
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9918
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4 text-muted-foreground" }),
|
|
9919
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Notes before unloading" }),
|
|
9920
|
+
comments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", className: "text-[10px] h-5", children: comments.length })
|
|
9921
|
+
] }),
|
|
9922
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9923
|
+
Button,
|
|
9924
|
+
{
|
|
9925
|
+
variant: "outline",
|
|
9926
|
+
size: "sm",
|
|
9927
|
+
className: "gap-1.5 h-9",
|
|
9928
|
+
onClick: () => setAddDialogOpen(true),
|
|
9929
|
+
children: [
|
|
9930
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4" }),
|
|
9931
|
+
"Add note"
|
|
9932
|
+
]
|
|
9933
|
+
}
|
|
9934
|
+
)
|
|
9935
|
+
] }),
|
|
9936
|
+
comments.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(Collapsible, { open: viewCommentsOpen, onOpenChange: setViewCommentsOpen, children: [
|
|
9937
|
+
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", size: "sm", className: "w-full justify-between h-8 px-2", children: [
|
|
9938
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium", children: viewCommentsOpen ? "Hide comments" : "Show comments" }),
|
|
9939
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn(
|
|
9940
|
+
"h-4 w-4 transition-transform duration-200",
|
|
9941
|
+
viewCommentsOpen && "rotate-180"
|
|
9942
|
+
) })
|
|
9943
|
+
] }) }),
|
|
9944
|
+
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { className: "space-y-2 pt-2", children: comments.map((comment) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-muted/50 p-3 space-y-1", children: [
|
|
9945
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9946
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9947
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium", children: comment.author }),
|
|
9948
|
+
comment.supplierName && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", className: "text-[9px] px-1.5 py-0 h-4", children: comment.prefixName ? `${comment.supplierName} - ${comment.prefixName}` : comment.supplierName })
|
|
9949
|
+
] }),
|
|
9950
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: formatDate2(comment.createdAt) })
|
|
9951
|
+
] }),
|
|
9952
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: comment.text })
|
|
9953
|
+
] }, comment.id)) })
|
|
9954
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-dashed p-4 text-center text-sm text-muted-foreground", children: "No pre-unloading notes yet. Add notes before confirming the load." })
|
|
9955
|
+
] }),
|
|
9956
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9957
|
+
AddCommentDialog,
|
|
9958
|
+
{
|
|
9959
|
+
open: addDialogOpen,
|
|
9960
|
+
onOpenChange: setAddDialogOpen,
|
|
9961
|
+
delivery,
|
|
9962
|
+
weekId,
|
|
9963
|
+
onAddComment
|
|
9964
|
+
}
|
|
9965
|
+
)
|
|
9966
|
+
] });
|
|
9967
|
+
}
|
|
9968
|
+
function getDeliveryHeaderStyles(state, hasRisk) {
|
|
9969
|
+
if (hasRisk) {
|
|
9970
|
+
return {
|
|
9971
|
+
iconBg: "bg-red-100 dark:bg-red-950/50",
|
|
9972
|
+
iconColor: "text-red-600 dark:text-red-400"
|
|
9973
|
+
};
|
|
9974
|
+
}
|
|
9975
|
+
switch (state) {
|
|
9976
|
+
case "sent":
|
|
9977
|
+
return {
|
|
9978
|
+
iconBg: "bg-green-100 dark:bg-green-950/50",
|
|
9979
|
+
iconColor: "text-green-600 dark:text-green-400"
|
|
9980
|
+
};
|
|
9981
|
+
case "ready":
|
|
9982
|
+
return {
|
|
9983
|
+
iconBg: "bg-green-100 dark:bg-green-950/50",
|
|
9984
|
+
iconColor: "text-green-600 dark:text-green-400"
|
|
9985
|
+
};
|
|
9986
|
+
default:
|
|
9987
|
+
return {
|
|
9988
|
+
iconBg: "bg-muted",
|
|
9989
|
+
iconColor: "text-muted-foreground"
|
|
9990
|
+
};
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
function DeliveryDetailPage({
|
|
9994
|
+
delivery,
|
|
9995
|
+
week,
|
|
9996
|
+
suppliers,
|
|
9997
|
+
userRole,
|
|
9998
|
+
currentSupplierId,
|
|
9999
|
+
onBack,
|
|
10000
|
+
onAddComment,
|
|
10001
|
+
onConfirmLoad
|
|
10002
|
+
}) {
|
|
10003
|
+
const visualState = getDeliveryVisualState(delivery);
|
|
10004
|
+
const headerStyles = getDeliveryHeaderStyles(visualState, delivery.hasProductionRisk ?? false);
|
|
10005
|
+
const loadedCount = delivery.loadedCount ?? delivery.elements.filter((e) => e.status === "loaded").length;
|
|
10006
|
+
const totalCount = delivery.totalCount ?? delivery.elements.length;
|
|
10007
|
+
const loadedPercent = totalCount > 0 ? Math.round(loadedCount / totalCount * 100) : 0;
|
|
10008
|
+
const producedCount = delivery.producedCount ?? loadedCount;
|
|
10009
|
+
const producedPercent = totalCount > 0 ? Math.round(producedCount / totalCount * 100) : 0;
|
|
10010
|
+
const elementsByStatus = React27__namespace.useMemo(() => {
|
|
10011
|
+
const loaded = delivery.elements.filter((e) => e.status === "loaded");
|
|
10012
|
+
const missing = delivery.elements.filter((e) => e.status === "missing");
|
|
10013
|
+
const moved = delivery.elements.filter((e) => e.status === "moved");
|
|
10014
|
+
const addons = delivery.elements.filter((e) => e.status === "addon");
|
|
10015
|
+
return { loaded, missing, moved, addons };
|
|
10016
|
+
}, [delivery.elements]);
|
|
10017
|
+
const preUnloadingComments = delivery.comments.filter((c) => c.context === "pre_unloading");
|
|
10018
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
|
|
10019
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 px-4 py-3 border-b bg-background sticky top-0 z-10", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10020
|
+
Button,
|
|
10021
|
+
{
|
|
10022
|
+
variant: "ghost",
|
|
10023
|
+
size: "sm",
|
|
10024
|
+
className: "gap-1 -ml-2",
|
|
10025
|
+
onClick: onBack,
|
|
10026
|
+
children: [
|
|
10027
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
|
|
10028
|
+
"Back"
|
|
10029
|
+
]
|
|
10030
|
+
}
|
|
10031
|
+
) }),
|
|
10032
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 pb-6 space-y-6", children: [
|
|
10033
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pt-4 space-y-4", children: [
|
|
10034
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
10035
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
10036
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(
|
|
10037
|
+
"flex items-center justify-center h-12 w-12 rounded-xl shrink-0",
|
|
10038
|
+
headerStyles.iconBg
|
|
10039
|
+
), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: cn("h-6 w-6", headerStyles.iconColor) }) }),
|
|
10040
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
10041
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
10042
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", children: delivery.label }),
|
|
10043
|
+
visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-5 w-5 text-green-600 dark:text-green-400" }),
|
|
10044
|
+
delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-5 w-5 text-red-500" })
|
|
10045
|
+
] }),
|
|
10046
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
10047
|
+
delivery.supplierName,
|
|
10048
|
+
delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`
|
|
10049
|
+
] })
|
|
10050
|
+
] })
|
|
10051
|
+
] }),
|
|
10052
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-end gap-1.5", children: [
|
|
10053
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10054
|
+
Badge,
|
|
10055
|
+
{
|
|
10056
|
+
variant: getStatusBadgeVariant2(delivery.status),
|
|
10057
|
+
className: cn("shrink-0", getStatusBadgeClasses2(delivery.status)),
|
|
10058
|
+
children: getLoadingDeliveryStatusLabel(delivery.status)
|
|
10059
|
+
}
|
|
10060
|
+
),
|
|
10061
|
+
delivery.isReadyToUnload && /* @__PURE__ */ jsxRuntime.jsx(
|
|
10062
|
+
Badge,
|
|
10063
|
+
{
|
|
10064
|
+
variant: "outline",
|
|
10065
|
+
className: "bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
|
|
10066
|
+
children: "Ready to unload"
|
|
10067
|
+
}
|
|
10068
|
+
)
|
|
10069
|
+
] })
|
|
10070
|
+
] }),
|
|
10071
|
+
delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border-l-2 border-l-red-500 bg-red-50/50 dark:bg-red-950/30 p-3", children: [
|
|
10072
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
10073
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-600 dark:text-red-400 shrink-0" }),
|
|
10074
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-red-700 dark:text-red-400", children: "Production delay risk" })
|
|
10075
|
+
] }),
|
|
10076
|
+
delivery.riskReason && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600 dark:text-red-400 mt-1 ml-6", children: delivery.riskReason })
|
|
10077
|
+
] }),
|
|
10078
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-4 text-sm text-muted-foreground", children: [
|
|
10079
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
10080
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "h-4 w-4" }),
|
|
10081
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: delivery.date.toLocaleDateString("en-US", {
|
|
10082
|
+
weekday: "short",
|
|
10083
|
+
month: "short",
|
|
10084
|
+
day: "numeric"
|
|
10085
|
+
}) })
|
|
10086
|
+
] }),
|
|
10087
|
+
delivery.destination && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
10088
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "h-4 w-4" }),
|
|
10089
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: delivery.destination })
|
|
10090
|
+
] })
|
|
10091
|
+
] }),
|
|
10092
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-muted/50 p-4 space-y-3", children: [
|
|
10093
|
+
(delivery.producedCount !== void 0 || delivery.producedTons !== void 0) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
10094
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
10095
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Production" }),
|
|
10096
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn(
|
|
10097
|
+
"text-sm font-semibold tabular-nums",
|
|
10098
|
+
delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : ""
|
|
10099
|
+
), children: [
|
|
10100
|
+
delivery.producedTons !== void 0 && delivery.totalTons !== void 0 ? `${delivery.producedTons} / ${delivery.totalTons} tons` : `Produced ${producedCount} / ${totalCount}`,
|
|
10101
|
+
delivery.isReadyToUnload && " \u2713"
|
|
10102
|
+
] })
|
|
10103
|
+
] }),
|
|
10104
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10105
|
+
"div",
|
|
10106
|
+
{
|
|
10107
|
+
className: cn(
|
|
10108
|
+
"h-full rounded-full transition-all",
|
|
10109
|
+
delivery.isReadyToUnload ? "bg-green-500" : delivery.hasProductionRisk ? "bg-red-500" : "bg-amber-500"
|
|
10110
|
+
),
|
|
10111
|
+
style: { width: `${producedPercent}%` }
|
|
10112
|
+
}
|
|
10113
|
+
) })
|
|
10114
|
+
] }),
|
|
10115
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, { className: "my-2" }),
|
|
10116
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
10117
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
10118
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Loading Progress" }),
|
|
10119
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-semibold tabular-nums", children: [
|
|
10120
|
+
"Loaded ",
|
|
10121
|
+
loadedCount,
|
|
10122
|
+
" / ",
|
|
10123
|
+
totalCount
|
|
10124
|
+
] })
|
|
10125
|
+
] }),
|
|
10126
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10127
|
+
"div",
|
|
10128
|
+
{
|
|
10129
|
+
className: cn(
|
|
10130
|
+
"h-full rounded-full transition-all",
|
|
10131
|
+
loadedPercent === 100 ? "bg-green-500" : "bg-primary"
|
|
10132
|
+
),
|
|
10133
|
+
style: { width: `${loadedPercent}%` }
|
|
10134
|
+
}
|
|
10135
|
+
) }),
|
|
10136
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-wrap text-xs", children: [
|
|
10137
|
+
elementsByStatus.loaded.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-green-600 dark:text-green-400", children: [
|
|
10138
|
+
elementsByStatus.loaded.length,
|
|
10139
|
+
" Loaded"
|
|
10140
|
+
] }),
|
|
10141
|
+
elementsByStatus.missing.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
|
|
10142
|
+
elementsByStatus.missing.length,
|
|
10143
|
+
" Missing"
|
|
10144
|
+
] }),
|
|
10145
|
+
elementsByStatus.moved.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-blue-600 dark:text-blue-400", children: [
|
|
10146
|
+
elementsByStatus.moved.length,
|
|
10147
|
+
" Moved"
|
|
10148
|
+
] }),
|
|
10149
|
+
elementsByStatus.addons.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-purple-600 dark:text-purple-400", children: [
|
|
10150
|
+
elementsByStatus.addons.length,
|
|
10151
|
+
" Add-on"
|
|
10152
|
+
] })
|
|
10153
|
+
] })
|
|
10154
|
+
] })
|
|
10155
|
+
] })
|
|
10156
|
+
] }),
|
|
10157
|
+
delivery.elements.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
|
|
10158
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
10159
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Package, { className: "h-4 w-4 text-muted-foreground" }),
|
|
10160
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Elements to Unload" }),
|
|
10161
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground ml-auto", children: [
|
|
10162
|
+
delivery.elements.length,
|
|
10163
|
+
" total"
|
|
10164
|
+
] })
|
|
10165
|
+
] }),
|
|
10166
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
10167
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "bg-sidebar hover:bg-sidebar", children: [
|
|
10168
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Prefix" }),
|
|
10169
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Type" }),
|
|
10170
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Weight" }),
|
|
10171
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Size (m\xB2)" }),
|
|
10172
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-center", children: "Status" })
|
|
10173
|
+
] }) }),
|
|
10174
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: delivery.elements.map((element) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10175
|
+
TableRow,
|
|
10176
|
+
{
|
|
10177
|
+
className: getElementRowBg(element.status),
|
|
10178
|
+
children: [
|
|
10179
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "font-medium", children: element.prefix }),
|
|
10180
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: element.type }),
|
|
10181
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: element.weight ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
10182
|
+
element.weight,
|
|
10183
|
+
" ",
|
|
10184
|
+
element.weightUnit || "kg"
|
|
10185
|
+
] }) : "\u2014" }),
|
|
10186
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: element.sizeSqm ?? "\u2014" }),
|
|
10187
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-1", children: [
|
|
10188
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10189
|
+
Badge,
|
|
10190
|
+
{
|
|
10191
|
+
variant: "outline",
|
|
10192
|
+
className: cn(
|
|
10193
|
+
"text-[10px] h-5",
|
|
10194
|
+
getElementStatusBadgeClasses(element.status)
|
|
10195
|
+
),
|
|
10196
|
+
children: getLoadingElementStatusLabel(element.status)
|
|
10197
|
+
}
|
|
10198
|
+
),
|
|
10199
|
+
element.status === "moved" && element.actualDeliveryLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[9px] text-blue-600 dark:text-blue-400", children: [
|
|
10200
|
+
"\u2192 ",
|
|
10201
|
+
element.actualDeliveryLabel
|
|
10202
|
+
] }),
|
|
10203
|
+
element.status === "addon" && element.originalDeliveryLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[9px] text-purple-600 dark:text-purple-400", children: [
|
|
10204
|
+
"from ",
|
|
10205
|
+
element.originalDeliveryLabel
|
|
10206
|
+
] })
|
|
10207
|
+
] }) })
|
|
10208
|
+
]
|
|
10209
|
+
},
|
|
10210
|
+
element.id
|
|
10211
|
+
)) })
|
|
10212
|
+
] }) })
|
|
10213
|
+
] }),
|
|
10214
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10215
|
+
CommentsSection,
|
|
10216
|
+
{
|
|
10217
|
+
comments: preUnloadingComments,
|
|
10218
|
+
delivery,
|
|
10219
|
+
weekId: week.weekKey,
|
|
10220
|
+
onAddComment
|
|
10221
|
+
}
|
|
10222
|
+
),
|
|
10223
|
+
onConfirmLoad && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "pt-4", children: [
|
|
10224
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10225
|
+
Button,
|
|
10226
|
+
{
|
|
10227
|
+
className: "w-full h-12 text-base",
|
|
10228
|
+
onClick: () => onConfirmLoad(delivery.id),
|
|
10229
|
+
children: "Start Loading"
|
|
10230
|
+
}
|
|
10231
|
+
),
|
|
10232
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground text-center mt-2", children: "Comments are saved independently." })
|
|
10233
|
+
] })
|
|
10234
|
+
] }) })
|
|
10235
|
+
] });
|
|
10236
|
+
}
|
|
10237
|
+
function SupplierWeeklyLoading({
|
|
10238
|
+
week,
|
|
10239
|
+
deliveries,
|
|
10240
|
+
suppliers,
|
|
10241
|
+
userRole,
|
|
10242
|
+
currentSupplierId,
|
|
10243
|
+
onDeliveryClick,
|
|
10244
|
+
onBack,
|
|
10245
|
+
onAddComment,
|
|
10246
|
+
onConfirmLoad,
|
|
10247
|
+
onWeekChange,
|
|
10248
|
+
showNavigation = true,
|
|
10249
|
+
bordered = true,
|
|
10250
|
+
className
|
|
10251
|
+
}) {
|
|
10252
|
+
const [selectedDelivery, setSelectedDelivery] = React27__namespace.useState(null);
|
|
10253
|
+
const [sheetOpen, setSheetOpen] = React27__namespace.useState(false);
|
|
10254
|
+
const handleDeliveryClick = (delivery) => {
|
|
10255
|
+
setSelectedDelivery(delivery);
|
|
10256
|
+
setSheetOpen(true);
|
|
10257
|
+
onDeliveryClick?.(delivery);
|
|
10258
|
+
};
|
|
10259
|
+
const handleSheetClose = () => {
|
|
10260
|
+
setSheetOpen(false);
|
|
10261
|
+
setTimeout(() => setSelectedDelivery(null), 200);
|
|
10262
|
+
onBack?.();
|
|
10263
|
+
};
|
|
10264
|
+
const Wrapper = bordered ? Card : "div";
|
|
10265
|
+
const Content14 = bordered ? CardContent : "div";
|
|
10266
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10267
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10268
|
+
Wrapper,
|
|
10269
|
+
{
|
|
10270
|
+
className: cn(
|
|
10271
|
+
"flex flex-col overflow-hidden",
|
|
10272
|
+
// Removed fixed min-height - content-driven sizing
|
|
10273
|
+
!bordered && "border border-border bg-card rounded-lg",
|
|
10274
|
+
className
|
|
10275
|
+
),
|
|
10276
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Content14, { className: cn("flex-1 overflow-hidden p-0", !bordered && ""), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10277
|
+
WeeklyLoadingView,
|
|
10278
|
+
{
|
|
10279
|
+
week,
|
|
10280
|
+
deliveries,
|
|
10281
|
+
onDeliveryClick: handleDeliveryClick,
|
|
10282
|
+
onWeekChange,
|
|
10283
|
+
showNavigation
|
|
10284
|
+
}
|
|
10285
|
+
) })
|
|
10286
|
+
}
|
|
10287
|
+
),
|
|
10288
|
+
/* @__PURE__ */ jsxRuntime.jsx(Sheet, { open: sheetOpen, onOpenChange: (open) => !open && handleSheetClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10289
|
+
SheetContent,
|
|
10290
|
+
{
|
|
10291
|
+
side: "right",
|
|
10292
|
+
className: "w-full sm:max-w-lg p-0 overflow-hidden",
|
|
10293
|
+
children: [
|
|
10294
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetHeader, { className: "sr-only", children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: selectedDelivery?.label ?? "Delivery Details" }) }),
|
|
10295
|
+
selectedDelivery && /* @__PURE__ */ jsxRuntime.jsx(
|
|
10296
|
+
DeliveryDetailPage,
|
|
10297
|
+
{
|
|
10298
|
+
delivery: selectedDelivery,
|
|
10299
|
+
week,
|
|
10300
|
+
suppliers,
|
|
10301
|
+
userRole,
|
|
10302
|
+
currentSupplierId,
|
|
10303
|
+
onBack: handleSheetClose,
|
|
10304
|
+
onAddComment,
|
|
10305
|
+
onConfirmLoad
|
|
10306
|
+
}
|
|
10307
|
+
)
|
|
10308
|
+
]
|
|
10309
|
+
}
|
|
10310
|
+
) })
|
|
10311
|
+
] });
|
|
10312
|
+
}
|
|
10313
|
+
function getStatusBadgeVariant3(status) {
|
|
10314
|
+
switch (status) {
|
|
10315
|
+
case "shipped":
|
|
10316
|
+
case "delivered":
|
|
10317
|
+
return "default";
|
|
10318
|
+
case "loaded":
|
|
10319
|
+
case "in_progress":
|
|
10320
|
+
return "secondary";
|
|
10321
|
+
case "cancelled":
|
|
10322
|
+
return "destructive";
|
|
10323
|
+
case "planned":
|
|
10324
|
+
default:
|
|
10325
|
+
return "outline";
|
|
10326
|
+
}
|
|
10327
|
+
}
|
|
10328
|
+
function getStatusBadgeClasses3(status) {
|
|
10329
|
+
switch (status) {
|
|
10330
|
+
case "shipped":
|
|
10331
|
+
case "delivered":
|
|
10332
|
+
return "border-green-500 text-green-600 bg-green-50 dark:bg-green-950/50";
|
|
10333
|
+
case "loaded":
|
|
10334
|
+
return "border-blue-500 text-blue-600 bg-blue-50 dark:bg-blue-950/50";
|
|
10335
|
+
case "in_progress":
|
|
10336
|
+
return "border-amber-500 text-amber-600 bg-amber-50 dark:bg-amber-950/50";
|
|
10337
|
+
case "cancelled":
|
|
10338
|
+
return "";
|
|
10339
|
+
case "planned":
|
|
10340
|
+
default:
|
|
10341
|
+
return "border-muted-foreground/50 text-muted-foreground";
|
|
10342
|
+
}
|
|
10343
|
+
}
|
|
10344
|
+
function getLeftStrokeStyles2(state, hasRisk, isHovered) {
|
|
10345
|
+
if (hasRisk) {
|
|
10346
|
+
return {
|
|
10347
|
+
stroke: "border-l-2 border-l-red-500",
|
|
10348
|
+
iconColor: "text-muted-foreground"
|
|
10349
|
+
};
|
|
10350
|
+
}
|
|
10351
|
+
switch (state) {
|
|
10352
|
+
case "sent":
|
|
10353
|
+
return {
|
|
10354
|
+
stroke: "border-l-2 border-l-green-500/50",
|
|
10355
|
+
iconColor: "text-muted-foreground/40"
|
|
10356
|
+
};
|
|
10357
|
+
case "ready":
|
|
10358
|
+
return {
|
|
10359
|
+
stroke: "border-l-2 border-l-green-500",
|
|
10360
|
+
iconColor: "text-muted-foreground"
|
|
10361
|
+
};
|
|
10362
|
+
default:
|
|
10363
|
+
return {
|
|
10364
|
+
stroke: isHovered ? "border-l-2 border-l-border" : "border-l-2 border-l-transparent",
|
|
10365
|
+
iconColor: "text-muted-foreground"
|
|
10366
|
+
};
|
|
10367
|
+
}
|
|
10368
|
+
}
|
|
10369
|
+
function DeliveryCard({
|
|
10370
|
+
delivery,
|
|
10371
|
+
onTap,
|
|
10372
|
+
className
|
|
10373
|
+
}) {
|
|
10374
|
+
const [isHovered, setIsHovered] = React27__namespace.useState(false);
|
|
10375
|
+
const hasComments = delivery.comments.length > 0;
|
|
10376
|
+
const visualState = getDeliveryVisualState(delivery);
|
|
10377
|
+
const styles = getLeftStrokeStyles2(visualState, delivery.hasProductionRisk ?? false, isHovered);
|
|
10378
|
+
const productionDisplay = React27__namespace.useMemo(() => {
|
|
10379
|
+
if (delivery.producedTons !== void 0 && delivery.totalTons !== void 0) {
|
|
10380
|
+
return `${delivery.producedTons} / ${delivery.totalTons}t produced`;
|
|
10381
|
+
}
|
|
10382
|
+
if (delivery.producedCount !== void 0 && delivery.totalCount !== void 0) {
|
|
10383
|
+
return `${delivery.producedCount} / ${delivery.totalCount} produced`;
|
|
10384
|
+
}
|
|
10385
|
+
if (delivery.loadedCount !== void 0 && delivery.totalCount !== void 0) {
|
|
10386
|
+
return `Loaded ${delivery.loadedCount} / ${delivery.totalCount}`;
|
|
10387
|
+
}
|
|
10388
|
+
return null;
|
|
10389
|
+
}, [delivery]);
|
|
10390
|
+
const handleClick = () => {
|
|
10391
|
+
onTap?.();
|
|
10392
|
+
};
|
|
10393
|
+
const handleKeyDown = (e) => {
|
|
10394
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
10395
|
+
e.preventDefault();
|
|
10396
|
+
onTap?.();
|
|
10397
|
+
}
|
|
10398
|
+
};
|
|
10399
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10400
|
+
"div",
|
|
10401
|
+
{
|
|
10402
|
+
role: "button",
|
|
10403
|
+
tabIndex: 0,
|
|
10404
|
+
onClick: handleClick,
|
|
10405
|
+
onKeyDown: handleKeyDown,
|
|
10406
|
+
onMouseEnter: () => setIsHovered(true),
|
|
10407
|
+
onMouseLeave: () => setIsHovered(false),
|
|
10408
|
+
className: cn(
|
|
10409
|
+
// Full-width, 90° corners (j3m.radius.none)
|
|
10410
|
+
"w-full rounded-none",
|
|
10411
|
+
// Touch-friendly sizing - 56px min-height for iPad
|
|
10412
|
+
"min-h-[56px] p-4",
|
|
10413
|
+
// Card styling: white background, standard border
|
|
10414
|
+
"bg-background border border-border",
|
|
10415
|
+
// Left stroke for status (j3m.stroke.m = 2px)
|
|
10416
|
+
styles.stroke,
|
|
10417
|
+
// Hover/tap state - lift effect like Calibration
|
|
10418
|
+
"cursor-pointer transition-all duration-200 ease-out",
|
|
10419
|
+
"hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
|
|
10420
|
+
"active:translate-y-0 active:shadow-sm",
|
|
10421
|
+
// Focus state
|
|
10422
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",
|
|
10423
|
+
// Greyed out for sent state
|
|
10424
|
+
visualState === "sent" && "opacity-60",
|
|
10425
|
+
className
|
|
10426
|
+
),
|
|
10427
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
10428
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 min-w-0 flex-1", children: [
|
|
10429
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(
|
|
10430
|
+
"flex items-center justify-center h-10 w-10 rounded-md shrink-0 bg-muted/50"
|
|
10431
|
+
), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Truck, { className: cn("h-5 w-5", styles.iconColor) }) }),
|
|
10432
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [
|
|
10433
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
10434
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold truncate", children: delivery.label }),
|
|
10435
|
+
visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
|
|
10436
|
+
visualState === "ready" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
10437
|
+
Badge,
|
|
10438
|
+
{
|
|
10439
|
+
variant: "outline",
|
|
10440
|
+
className: "text-[9px] px-1.5 py-0 h-4 bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
|
|
10441
|
+
children: "Ready"
|
|
10442
|
+
}
|
|
10443
|
+
),
|
|
10444
|
+
delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
|
|
10445
|
+
hasComments && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative shrink-0", children: [
|
|
10446
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-3.5 w-3.5 text-muted-foreground" }),
|
|
10447
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary" })
|
|
10448
|
+
] })
|
|
10449
|
+
] }),
|
|
10450
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground truncate", children: [
|
|
10451
|
+
delivery.supplierName,
|
|
10452
|
+
delivery.prefixScope && ` \u2022 ${delivery.prefixScope}`
|
|
10453
|
+
] }),
|
|
10454
|
+
productionDisplay && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-xs", children: [
|
|
10455
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Package, { className: "h-3 w-3 text-muted-foreground" }),
|
|
10456
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: cn(
|
|
10457
|
+
delivery.isReadyToUnload ? "text-green-600 dark:text-green-400 font-medium" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
|
|
10458
|
+
), children: [
|
|
10459
|
+
delivery.isReadyToUnload ? "\u2713 " : "",
|
|
10460
|
+
productionDisplay
|
|
10461
|
+
] })
|
|
10462
|
+
] })
|
|
10463
|
+
] })
|
|
10464
|
+
] }),
|
|
10465
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [
|
|
10466
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10467
|
+
Badge,
|
|
10468
|
+
{
|
|
10469
|
+
variant: getStatusBadgeVariant3(delivery.status),
|
|
10470
|
+
className: cn("text-[10px] h-5", getStatusBadgeClasses3(delivery.status)),
|
|
10471
|
+
children: getLoadingDeliveryStatusLabel(delivery.status)
|
|
10472
|
+
}
|
|
10473
|
+
),
|
|
10474
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 text-muted-foreground" })
|
|
10475
|
+
] })
|
|
10476
|
+
] })
|
|
10477
|
+
}
|
|
10478
|
+
);
|
|
10479
|
+
}
|
|
10480
|
+
|
|
9172
10481
|
// src/components/event-calendar/types.ts
|
|
9173
10482
|
var DEFAULT_WORKING_HOURS = {
|
|
9174
10483
|
0: { from: 0, to: 0 },
|
|
@@ -9231,7 +10540,7 @@ var BADGE_VARIANT_LABELS = {
|
|
|
9231
10540
|
colored: "Colored",
|
|
9232
10541
|
mixed: "Mixed"
|
|
9233
10542
|
};
|
|
9234
|
-
var CalendarContext =
|
|
10543
|
+
var CalendarContext = React27__namespace.createContext(null);
|
|
9235
10544
|
function EventCalendarProvider({
|
|
9236
10545
|
children,
|
|
9237
10546
|
events: initialEvents = [],
|
|
@@ -9246,38 +10555,38 @@ function EventCalendarProvider({
|
|
|
9246
10555
|
onEventUpdate,
|
|
9247
10556
|
onEventDelete
|
|
9248
10557
|
}) {
|
|
9249
|
-
const [selectedDate, setSelectedDate] =
|
|
9250
|
-
const [selectedUserId, setSelectedUserId] =
|
|
9251
|
-
const [events, setEventsState] =
|
|
9252
|
-
const [users] =
|
|
9253
|
-
const [badgeVariant, setBadgeVariant] =
|
|
9254
|
-
const [view, setView] =
|
|
9255
|
-
const [workingHours, setWorkingHours] =
|
|
9256
|
-
const [visibleHours, setVisibleHours] =
|
|
9257
|
-
|
|
10558
|
+
const [selectedDate, setSelectedDate] = React27__namespace.useState(defaultDate);
|
|
10559
|
+
const [selectedUserId, setSelectedUserId] = React27__namespace.useState(defaultUserId);
|
|
10560
|
+
const [events, setEventsState] = React27__namespace.useState(initialEvents);
|
|
10561
|
+
const [users] = React27__namespace.useState(initialUsers);
|
|
10562
|
+
const [badgeVariant, setBadgeVariant] = React27__namespace.useState(defaultBadgeVariant);
|
|
10563
|
+
const [view, setView] = React27__namespace.useState(defaultView);
|
|
10564
|
+
const [workingHours, setWorkingHours] = React27__namespace.useState(defaultWorkingHours);
|
|
10565
|
+
const [visibleHours, setVisibleHours] = React27__namespace.useState(defaultVisibleHours);
|
|
10566
|
+
React27__namespace.useEffect(() => {
|
|
9258
10567
|
setEventsState(initialEvents);
|
|
9259
10568
|
}, [initialEvents]);
|
|
9260
|
-
const setEvents =
|
|
10569
|
+
const setEvents = React27__namespace.useCallback((newEvents) => {
|
|
9261
10570
|
setEventsState(newEvents);
|
|
9262
10571
|
}, []);
|
|
9263
|
-
const addEvent =
|
|
10572
|
+
const addEvent = React27__namespace.useCallback((event) => {
|
|
9264
10573
|
setEventsState((prev) => [...prev, event]);
|
|
9265
10574
|
onEventAdd?.(event);
|
|
9266
10575
|
}, [onEventAdd]);
|
|
9267
|
-
const updateEvent =
|
|
10576
|
+
const updateEvent = React27__namespace.useCallback((event) => {
|
|
9268
10577
|
setEventsState(
|
|
9269
10578
|
(prev) => prev.map((e) => e.id === event.id ? event : e)
|
|
9270
10579
|
);
|
|
9271
10580
|
onEventUpdate?.(event);
|
|
9272
10581
|
}, [onEventUpdate]);
|
|
9273
|
-
const deleteEvent =
|
|
10582
|
+
const deleteEvent = React27__namespace.useCallback((eventId) => {
|
|
9274
10583
|
setEventsState((prev) => prev.filter((e) => e.id !== eventId));
|
|
9275
10584
|
onEventDelete?.(eventId);
|
|
9276
10585
|
}, [onEventDelete]);
|
|
9277
|
-
const goToToday =
|
|
10586
|
+
const goToToday = React27__namespace.useCallback(() => {
|
|
9278
10587
|
setSelectedDate(/* @__PURE__ */ new Date());
|
|
9279
10588
|
}, []);
|
|
9280
|
-
const goToPrevious =
|
|
10589
|
+
const goToPrevious = React27__namespace.useCallback(() => {
|
|
9281
10590
|
setSelectedDate((current) => {
|
|
9282
10591
|
switch (view) {
|
|
9283
10592
|
case "day":
|
|
@@ -9295,7 +10604,7 @@ function EventCalendarProvider({
|
|
|
9295
10604
|
}
|
|
9296
10605
|
});
|
|
9297
10606
|
}, [view]);
|
|
9298
|
-
const goToNext =
|
|
10607
|
+
const goToNext = React27__namespace.useCallback(() => {
|
|
9299
10608
|
setSelectedDate((current) => {
|
|
9300
10609
|
switch (view) {
|
|
9301
10610
|
case "day":
|
|
@@ -9313,7 +10622,7 @@ function EventCalendarProvider({
|
|
|
9313
10622
|
}
|
|
9314
10623
|
});
|
|
9315
10624
|
}, [view]);
|
|
9316
|
-
const contextValue =
|
|
10625
|
+
const contextValue = React27__namespace.useMemo(
|
|
9317
10626
|
() => ({
|
|
9318
10627
|
// State
|
|
9319
10628
|
selectedDate,
|
|
@@ -9360,7 +10669,7 @@ function EventCalendarProvider({
|
|
|
9360
10669
|
return /* @__PURE__ */ jsxRuntime.jsx(CalendarContext.Provider, { value: contextValue, children });
|
|
9361
10670
|
}
|
|
9362
10671
|
function useEventCalendar() {
|
|
9363
|
-
const context =
|
|
10672
|
+
const context = React27__namespace.useContext(CalendarContext);
|
|
9364
10673
|
if (!context) {
|
|
9365
10674
|
throw new Error("useEventCalendar must be used within an EventCalendarProvider");
|
|
9366
10675
|
}
|
|
@@ -9368,14 +10677,14 @@ function useEventCalendar() {
|
|
|
9368
10677
|
}
|
|
9369
10678
|
function useFilteredEvents() {
|
|
9370
10679
|
const { events, selectedUserId } = useEventCalendar();
|
|
9371
|
-
return
|
|
10680
|
+
return React27__namespace.useMemo(() => {
|
|
9372
10681
|
if (!selectedUserId) return events;
|
|
9373
10682
|
return events.filter((event) => event.user.id === selectedUserId);
|
|
9374
10683
|
}, [events, selectedUserId]);
|
|
9375
10684
|
}
|
|
9376
10685
|
function useEventsInRange(startDate, endDate) {
|
|
9377
10686
|
const filteredEvents = useFilteredEvents();
|
|
9378
|
-
return
|
|
10687
|
+
return React27__namespace.useMemo(() => {
|
|
9379
10688
|
return filteredEvents.filter((event) => {
|
|
9380
10689
|
const eventStart = new Date(event.startDate);
|
|
9381
10690
|
const eventEnd = new Date(event.endDate);
|
|
@@ -9933,8 +11242,8 @@ function MoreEvents({ count, onClick, className }) {
|
|
|
9933
11242
|
);
|
|
9934
11243
|
}
|
|
9935
11244
|
function TimeIndicator({ className }) {
|
|
9936
|
-
const [now, setNow] =
|
|
9937
|
-
|
|
11245
|
+
const [now, setNow] = React27__namespace.useState(/* @__PURE__ */ new Date());
|
|
11246
|
+
React27__namespace.useEffect(() => {
|
|
9938
11247
|
const interval = setInterval(() => setNow(/* @__PURE__ */ new Date()), 6e4);
|
|
9939
11248
|
return () => clearInterval(interval);
|
|
9940
11249
|
}, []);
|
|
@@ -9971,24 +11280,24 @@ function DateBadge({ date, className }) {
|
|
|
9971
11280
|
}
|
|
9972
11281
|
);
|
|
9973
11282
|
}
|
|
9974
|
-
var DragContext =
|
|
11283
|
+
var DragContext = React27__namespace.createContext(null);
|
|
9975
11284
|
function DragProvider({
|
|
9976
11285
|
children,
|
|
9977
11286
|
snapMinutes = 15,
|
|
9978
11287
|
onDragStart,
|
|
9979
11288
|
onDragEnd
|
|
9980
11289
|
}) {
|
|
9981
|
-
const [draggedEvent, setDraggedEventState] =
|
|
9982
|
-
const [isDragging, setIsDragging] =
|
|
11290
|
+
const [draggedEvent, setDraggedEventState] = React27__namespace.useState(null);
|
|
11291
|
+
const [isDragging, setIsDragging] = React27__namespace.useState(false);
|
|
9983
11292
|
const { updateEvent } = useEventCalendar();
|
|
9984
|
-
const setDraggedEvent =
|
|
11293
|
+
const setDraggedEvent = React27__namespace.useCallback((event) => {
|
|
9985
11294
|
setDraggedEventState(event);
|
|
9986
11295
|
setIsDragging(!!event);
|
|
9987
11296
|
if (event) {
|
|
9988
11297
|
onDragStart?.(event);
|
|
9989
11298
|
}
|
|
9990
11299
|
}, [onDragStart]);
|
|
9991
|
-
const handleDrop =
|
|
11300
|
+
const handleDrop = React27__namespace.useCallback((newStartDate) => {
|
|
9992
11301
|
if (!draggedEvent) return;
|
|
9993
11302
|
const snappedDate = snapToInterval(newStartDate, snapMinutes);
|
|
9994
11303
|
const { startDate, endDate } = calculateDropDates(draggedEvent, snappedDate);
|
|
@@ -10001,7 +11310,7 @@ function DragProvider({
|
|
|
10001
11310
|
onDragEnd?.(updatedEvent, new Date(startDate), new Date(endDate));
|
|
10002
11311
|
setDraggedEvent(null);
|
|
10003
11312
|
}, [draggedEvent, snapMinutes, updateEvent, onDragEnd, setDraggedEvent]);
|
|
10004
|
-
const contextValue =
|
|
11313
|
+
const contextValue = React27__namespace.useMemo(
|
|
10005
11314
|
() => ({
|
|
10006
11315
|
draggedEvent,
|
|
10007
11316
|
setDraggedEvent,
|
|
@@ -10012,7 +11321,7 @@ function DragProvider({
|
|
|
10012
11321
|
return /* @__PURE__ */ jsxRuntime.jsx(DragContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(DragDropHandler, { onDrop: handleDrop, children }) });
|
|
10013
11322
|
}
|
|
10014
11323
|
function useDrag() {
|
|
10015
|
-
const context =
|
|
11324
|
+
const context = React27__namespace.useContext(DragContext);
|
|
10016
11325
|
if (!context) {
|
|
10017
11326
|
throw new Error("useDrag must be used within a DragProvider");
|
|
10018
11327
|
}
|
|
@@ -10057,7 +11366,7 @@ function DroppableZone({
|
|
|
10057
11366
|
}) {
|
|
10058
11367
|
const { draggedEvent, setDraggedEvent } = useDrag();
|
|
10059
11368
|
const { updateEvent } = useEventCalendar();
|
|
10060
|
-
const [isOver, setIsOver] =
|
|
11369
|
+
const [isOver, setIsOver] = React27__namespace.useState(false);
|
|
10061
11370
|
const handleDragOver = (e) => {
|
|
10062
11371
|
e.preventDefault();
|
|
10063
11372
|
e.dataTransfer.dropEffect = "move";
|
|
@@ -10095,23 +11404,23 @@ function DroppableZone({
|
|
|
10095
11404
|
function useDroppable({ date, hour, minute = 0, onDrop }) {
|
|
10096
11405
|
const { draggedEvent, setDraggedEvent } = useDrag();
|
|
10097
11406
|
const { updateEvent } = useEventCalendar();
|
|
10098
|
-
const [isOver, setIsOver] =
|
|
10099
|
-
const dropTargetDate =
|
|
11407
|
+
const [isOver, setIsOver] = React27__namespace.useState(false);
|
|
11408
|
+
const dropTargetDate = React27__namespace.useMemo(() => {
|
|
10100
11409
|
const targetDate = new Date(date);
|
|
10101
11410
|
if (hour !== void 0) {
|
|
10102
11411
|
targetDate.setHours(hour, minute, 0, 0);
|
|
10103
11412
|
}
|
|
10104
11413
|
return targetDate;
|
|
10105
11414
|
}, [date, hour, minute]);
|
|
10106
|
-
const handleDragOver =
|
|
11415
|
+
const handleDragOver = React27__namespace.useCallback((e) => {
|
|
10107
11416
|
e.preventDefault();
|
|
10108
11417
|
e.dataTransfer.dropEffect = "move";
|
|
10109
11418
|
if (!isOver) setIsOver(true);
|
|
10110
11419
|
}, [isOver]);
|
|
10111
|
-
const handleDragLeave =
|
|
11420
|
+
const handleDragLeave = React27__namespace.useCallback(() => {
|
|
10112
11421
|
setIsOver(false);
|
|
10113
11422
|
}, []);
|
|
10114
|
-
const handleDrop =
|
|
11423
|
+
const handleDrop = React27__namespace.useCallback((e) => {
|
|
10115
11424
|
e.preventDefault();
|
|
10116
11425
|
setIsOver(false);
|
|
10117
11426
|
if (!draggedEvent) return;
|
|
@@ -10138,13 +11447,13 @@ function useDroppable({ date, hour, minute = 0, onDrop }) {
|
|
|
10138
11447
|
function useDraggable(event, disabled = false) {
|
|
10139
11448
|
const { setDraggedEvent, draggedEvent } = useDrag();
|
|
10140
11449
|
const isDragged = draggedEvent?.id === event.id;
|
|
10141
|
-
const handleDragStart =
|
|
11450
|
+
const handleDragStart = React27__namespace.useCallback((e) => {
|
|
10142
11451
|
if (disabled) return;
|
|
10143
11452
|
e.dataTransfer.effectAllowed = "move";
|
|
10144
11453
|
e.dataTransfer.setData("text/plain", event.id);
|
|
10145
11454
|
setDraggedEvent(event);
|
|
10146
11455
|
}, [disabled, event, setDraggedEvent]);
|
|
10147
|
-
const handleDragEnd =
|
|
11456
|
+
const handleDragEnd = React27__namespace.useCallback(() => {
|
|
10148
11457
|
setDraggedEvent(null);
|
|
10149
11458
|
}, [setDraggedEvent]);
|
|
10150
11459
|
return {
|
|
@@ -10185,15 +11494,15 @@ function MonthView({
|
|
|
10185
11494
|
}) {
|
|
10186
11495
|
const { selectedDate, badgeVariant, setSelectedDate, setView } = useEventCalendar();
|
|
10187
11496
|
const filteredEvents = useFilteredEvents();
|
|
10188
|
-
const { singleDayEvents, multiDayEvents } =
|
|
11497
|
+
const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
|
|
10189
11498
|
() => splitEventsByDuration(filteredEvents),
|
|
10190
11499
|
[filteredEvents]
|
|
10191
11500
|
);
|
|
10192
|
-
const cells =
|
|
11501
|
+
const cells = React27__namespace.useMemo(
|
|
10193
11502
|
() => getCalendarCells(selectedDate),
|
|
10194
11503
|
[selectedDate]
|
|
10195
11504
|
);
|
|
10196
|
-
const eventPositions =
|
|
11505
|
+
const eventPositions = React27__namespace.useMemo(
|
|
10197
11506
|
() => calculateMonthEventPositions(multiDayEvents, singleDayEvents, selectedDate),
|
|
10198
11507
|
[multiDayEvents, singleDayEvents, selectedDate]
|
|
10199
11508
|
);
|
|
@@ -10375,7 +11684,7 @@ function WeekView({
|
|
|
10375
11684
|
visibleHours
|
|
10376
11685
|
} = useEventCalendar();
|
|
10377
11686
|
const filteredEvents = useFilteredEvents();
|
|
10378
|
-
const { singleDayEvents, multiDayEvents } =
|
|
11687
|
+
const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
|
|
10379
11688
|
() => splitEventsByDuration(filteredEvents),
|
|
10380
11689
|
[filteredEvents]
|
|
10381
11690
|
);
|
|
@@ -10581,8 +11890,8 @@ function CalendarTimeline({
|
|
|
10581
11890
|
firstVisibleHour,
|
|
10582
11891
|
lastVisibleHour
|
|
10583
11892
|
}) {
|
|
10584
|
-
const [currentTime, setCurrentTime] =
|
|
10585
|
-
|
|
11893
|
+
const [currentTime, setCurrentTime] = React27__namespace.useState(/* @__PURE__ */ new Date());
|
|
11894
|
+
React27__namespace.useEffect(() => {
|
|
10586
11895
|
const interval = setInterval(() => {
|
|
10587
11896
|
setCurrentTime(/* @__PURE__ */ new Date());
|
|
10588
11897
|
}, 6e4);
|
|
@@ -10665,7 +11974,7 @@ function DayView({
|
|
|
10665
11974
|
visibleHours
|
|
10666
11975
|
} = useEventCalendar();
|
|
10667
11976
|
const filteredEvents = useFilteredEvents();
|
|
10668
|
-
const { singleDayEvents, multiDayEvents } =
|
|
11977
|
+
const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
|
|
10669
11978
|
() => splitEventsByDuration(filteredEvents),
|
|
10670
11979
|
[filteredEvents]
|
|
10671
11980
|
);
|
|
@@ -10673,7 +11982,7 @@ function DayView({
|
|
|
10673
11982
|
visibleHours,
|
|
10674
11983
|
singleDayEvents
|
|
10675
11984
|
);
|
|
10676
|
-
const currentEvents =
|
|
11985
|
+
const currentEvents = React27__namespace.useMemo(() => {
|
|
10677
11986
|
if (!dateFns.isToday(selectedDate)) return [];
|
|
10678
11987
|
return getCurrentEvents(singleDayEvents);
|
|
10679
11988
|
}, [singleDayEvents, selectedDate]);
|
|
@@ -10897,8 +12206,8 @@ function CalendarTimeline2({
|
|
|
10897
12206
|
firstVisibleHour,
|
|
10898
12207
|
lastVisibleHour
|
|
10899
12208
|
}) {
|
|
10900
|
-
const [currentTime, setCurrentTime] =
|
|
10901
|
-
|
|
12209
|
+
const [currentTime, setCurrentTime] = React27__namespace.useState(/* @__PURE__ */ new Date());
|
|
12210
|
+
React27__namespace.useEffect(() => {
|
|
10902
12211
|
const interval = setInterval(() => {
|
|
10903
12212
|
setCurrentTime(/* @__PURE__ */ new Date());
|
|
10904
12213
|
}, 6e4);
|
|
@@ -10932,7 +12241,7 @@ function YearView({
|
|
|
10932
12241
|
}) {
|
|
10933
12242
|
const { selectedDate, setSelectedDate, setView } = useEventCalendar();
|
|
10934
12243
|
const filteredEvents = useFilteredEvents();
|
|
10935
|
-
const months =
|
|
12244
|
+
const months = React27__namespace.useMemo(() => {
|
|
10936
12245
|
const yearStart = dateFns.startOfYear(selectedDate);
|
|
10937
12246
|
return Array.from({ length: 12 }, (_, i) => dateFns.addMonths(yearStart, i));
|
|
10938
12247
|
}, [selectedDate]);
|
|
@@ -11055,11 +12364,11 @@ function AgendaView({
|
|
|
11055
12364
|
}) {
|
|
11056
12365
|
const { selectedDate, setSelectedDate, setView } = useEventCalendar();
|
|
11057
12366
|
const filteredEvents = useFilteredEvents();
|
|
11058
|
-
const { singleDayEvents, multiDayEvents } =
|
|
12367
|
+
const { singleDayEvents, multiDayEvents } = React27__namespace.useMemo(
|
|
11059
12368
|
() => splitEventsByDuration(filteredEvents),
|
|
11060
12369
|
[filteredEvents]
|
|
11061
12370
|
);
|
|
11062
|
-
const eventsByDay =
|
|
12371
|
+
const eventsByDay = React27__namespace.useMemo(() => {
|
|
11063
12372
|
const allDates = /* @__PURE__ */ new Map();
|
|
11064
12373
|
singleDayEvents.forEach((event) => {
|
|
11065
12374
|
const eventDate = dateFns.parseISO(event.startDate);
|
|
@@ -11524,16 +12833,16 @@ function EventDialog({
|
|
|
11524
12833
|
defaultUserId
|
|
11525
12834
|
}) {
|
|
11526
12835
|
const { addEvent, updateEvent, deleteEvent, users } = useEventCalendar();
|
|
11527
|
-
const [title, setTitle] =
|
|
11528
|
-
const [description, setDescription] =
|
|
11529
|
-
const [startDate, setStartDate] =
|
|
11530
|
-
const [startTime, setStartTime] =
|
|
11531
|
-
const [endDate, setEndDate] =
|
|
11532
|
-
const [endTime, setEndTime] =
|
|
11533
|
-
const [color, setColor] =
|
|
11534
|
-
const [userId, setUserId] =
|
|
11535
|
-
const [isSubmitting, setIsSubmitting] =
|
|
11536
|
-
|
|
12836
|
+
const [title, setTitle] = React27__namespace.useState("");
|
|
12837
|
+
const [description, setDescription] = React27__namespace.useState("");
|
|
12838
|
+
const [startDate, setStartDate] = React27__namespace.useState("");
|
|
12839
|
+
const [startTime, setStartTime] = React27__namespace.useState("");
|
|
12840
|
+
const [endDate, setEndDate] = React27__namespace.useState("");
|
|
12841
|
+
const [endTime, setEndTime] = React27__namespace.useState("");
|
|
12842
|
+
const [color, setColor] = React27__namespace.useState("blue");
|
|
12843
|
+
const [userId, setUserId] = React27__namespace.useState("");
|
|
12844
|
+
const [isSubmitting, setIsSubmitting] = React27__namespace.useState(false);
|
|
12845
|
+
React27__namespace.useEffect(() => {
|
|
11537
12846
|
if (open) {
|
|
11538
12847
|
if (mode === "edit" && event) {
|
|
11539
12848
|
const start = dateFns.parseISO(event.startDate);
|
|
@@ -11756,7 +13065,7 @@ function QuickAddEvent({
|
|
|
11756
13065
|
onOpenDialog,
|
|
11757
13066
|
onClose
|
|
11758
13067
|
}) {
|
|
11759
|
-
const [title, setTitle] =
|
|
13068
|
+
const [title, setTitle] = React27__namespace.useState("");
|
|
11760
13069
|
const { users } = useEventCalendar();
|
|
11761
13070
|
const handleSubmit = (e) => {
|
|
11762
13071
|
e.preventDefault();
|
|
@@ -11823,8 +13132,8 @@ var HOUR_OPTIONS = Array.from({ length: 25 }, (_, i) => {
|
|
|
11823
13132
|
});
|
|
11824
13133
|
function ChangeVisibleHoursInput() {
|
|
11825
13134
|
const { visibleHours, setVisibleHours } = useEventCalendar();
|
|
11826
|
-
const [from, setFrom] =
|
|
11827
|
-
const [to, setTo] =
|
|
13135
|
+
const [from, setFrom] = React27__namespace.useState(visibleHours.from);
|
|
13136
|
+
const [to, setTo] = React27__namespace.useState(visibleHours.to);
|
|
11828
13137
|
const handleApply = () => {
|
|
11829
13138
|
const toHour = to === 0 ? 24 : to;
|
|
11830
13139
|
setVisibleHours({ from, to: toHour });
|
|
@@ -11870,7 +13179,7 @@ var HOUR_OPTIONS2 = Array.from({ length: 25 }, (_, i) => {
|
|
|
11870
13179
|
});
|
|
11871
13180
|
function ChangeWorkingHoursInput() {
|
|
11872
13181
|
const { workingHours, setWorkingHours } = useEventCalendar();
|
|
11873
|
-
const [localWorkingHours, setLocalWorkingHours] =
|
|
13182
|
+
const [localWorkingHours, setLocalWorkingHours] = React27__namespace.useState({
|
|
11874
13183
|
...workingHours
|
|
11875
13184
|
});
|
|
11876
13185
|
const handleToggleDay = (dayId) => {
|
|
@@ -12019,8 +13328,8 @@ function CalendarSettingsButton({
|
|
|
12019
13328
|
);
|
|
12020
13329
|
}
|
|
12021
13330
|
function useMediaQuery(query) {
|
|
12022
|
-
const [matches, setMatches] =
|
|
12023
|
-
|
|
13331
|
+
const [matches, setMatches] = React27__namespace.useState(false);
|
|
13332
|
+
React27__namespace.useEffect(() => {
|
|
12024
13333
|
const media = window.matchMedia(query);
|
|
12025
13334
|
setMatches(media.matches);
|
|
12026
13335
|
const listener = (event) => {
|
|
@@ -12072,11 +13381,11 @@ function BigCalendarInner({
|
|
|
12072
13381
|
maxEventsPerDay
|
|
12073
13382
|
}) {
|
|
12074
13383
|
const { view, setView } = useEventCalendar();
|
|
12075
|
-
const [dialogOpen, setDialogOpen] =
|
|
12076
|
-
const [settingsDialogOpen, setSettingsDialogOpen] =
|
|
12077
|
-
const [selectedEvent, setSelectedEvent] =
|
|
12078
|
-
const [dialogMode, setDialogMode] =
|
|
12079
|
-
const [defaultDate, setDefaultDate] =
|
|
13384
|
+
const [dialogOpen, setDialogOpen] = React27__namespace.useState(false);
|
|
13385
|
+
const [settingsDialogOpen, setSettingsDialogOpen] = React27__namespace.useState(false);
|
|
13386
|
+
const [selectedEvent, setSelectedEvent] = React27__namespace.useState(null);
|
|
13387
|
+
const [dialogMode, setDialogMode] = React27__namespace.useState("add");
|
|
13388
|
+
const [defaultDate, setDefaultDate] = React27__namespace.useState(/* @__PURE__ */ new Date());
|
|
12080
13389
|
const isMobile = useMediaQuery("(max-width: 768px)");
|
|
12081
13390
|
const isCompact = compact === "auto" ? isMobile : compact;
|
|
12082
13391
|
const handleAddClick = () => {
|
|
@@ -12394,6 +13703,9 @@ exports.DataTablePagination = DataTablePagination;
|
|
|
12394
13703
|
exports.DataTableViewOptions = DataTableViewOptions;
|
|
12395
13704
|
exports.DateBadge = DateBadge;
|
|
12396
13705
|
exports.DayView = DayView;
|
|
13706
|
+
exports.DeliveryBadge = DeliveryBadge;
|
|
13707
|
+
exports.DeliveryCard = DeliveryCard;
|
|
13708
|
+
exports.DeliveryDetailPage = DeliveryDetailPage;
|
|
12397
13709
|
exports.DeliveryIndicator = DeliveryIndicator;
|
|
12398
13710
|
exports.DeliveryIndicators = DeliveryIndicators;
|
|
12399
13711
|
exports.Dialog = Dialog;
|
|
@@ -12610,6 +13922,7 @@ exports.Slider = Slider;
|
|
|
12610
13922
|
exports.Spinner = Spinner;
|
|
12611
13923
|
exports.SubmitCalibrationBar = SubmitCalibrationBar;
|
|
12612
13924
|
exports.SupplierCell = SupplierCell;
|
|
13925
|
+
exports.SupplierWeeklyLoading = SupplierWeeklyLoading;
|
|
12613
13926
|
exports.Switch = Switch;
|
|
12614
13927
|
exports.Table = Table;
|
|
12615
13928
|
exports.TableBody = TableBody;
|
|
@@ -12644,6 +13957,7 @@ exports.WeekCell = WeekCell;
|
|
|
12644
13957
|
exports.WeekDetailDialog = WeekDetailDialog;
|
|
12645
13958
|
exports.WeekHeader = WeekHeader;
|
|
12646
13959
|
exports.WeekView = WeekView;
|
|
13960
|
+
exports.WeeklyLoadingView = WeeklyLoadingView;
|
|
12647
13961
|
exports.YearView = YearView;
|
|
12648
13962
|
exports.badgeVariants = badgeVariants;
|
|
12649
13963
|
exports.buttonGroupVariants = buttonGroupVariants;
|
|
@@ -12655,12 +13969,14 @@ exports.canSubmitCalibration = canSubmitCalibration;
|
|
|
12655
13969
|
exports.cardVariants = cardVariants;
|
|
12656
13970
|
exports.createDefaultEvent = createDefaultEvent;
|
|
12657
13971
|
exports.deliveryIndicatorVariants = deliveryIndicatorVariants;
|
|
13972
|
+
exports.extractPrefixes = extractPrefixes;
|
|
12658
13973
|
exports.formatCalibrationUnit = formatCalibrationUnit;
|
|
12659
13974
|
exports.formatDateRange = formatDateRange2;
|
|
12660
13975
|
exports.formatProductionUnit = formatProductionUnit;
|
|
12661
13976
|
exports.formatTime = formatTime;
|
|
12662
13977
|
exports.generateColumns = generateColumns;
|
|
12663
13978
|
exports.generateEventId = generateEventId;
|
|
13979
|
+
exports.generateLoadingWeek = generateLoadingWeek;
|
|
12664
13980
|
exports.generateLocationOptions = generateLocationOptions;
|
|
12665
13981
|
exports.generateWeekColumns = generateWeekColumns;
|
|
12666
13982
|
exports.generateWeeks = generateWeeks;
|
|
@@ -12668,6 +13984,8 @@ exports.getCalendarCells = getCalendarCells;
|
|
|
12668
13984
|
exports.getCommentLocationLabel = getCommentLocationLabel;
|
|
12669
13985
|
exports.getCurrentEvents = getCurrentEvents;
|
|
12670
13986
|
exports.getDayHours = getDayHours;
|
|
13987
|
+
exports.getDayLabel = getDayLabel;
|
|
13988
|
+
exports.getDeliveryVisualState = getDeliveryVisualState;
|
|
12671
13989
|
exports.getElementShipmentStatus = getElementShipmentStatus;
|
|
12672
13990
|
exports.getEventBlockStyle = getEventBlockStyle;
|
|
12673
13991
|
exports.getEventDuration = getEventDuration;
|
|
@@ -12677,9 +13995,14 @@ exports.getEventsForDate = getEventsForDate;
|
|
|
12677
13995
|
exports.getEventsInRange = getEventsInRange;
|
|
12678
13996
|
exports.getHeaderLabel = getHeaderLabel;
|
|
12679
13997
|
exports.getISOWeek = getISOWeek;
|
|
13998
|
+
exports.getLoadingDeliveryStatusLabel = getLoadingDeliveryStatusLabel;
|
|
13999
|
+
exports.getLoadingElementStatusLabel = getLoadingElementStatusLabel;
|
|
14000
|
+
exports.getLoadingISOWeek = getLoadingISOWeek;
|
|
14001
|
+
exports.getLoadingWeekKey = getLoadingWeekKey;
|
|
12680
14002
|
exports.getMonthCellEvents = getMonthCellEvents;
|
|
12681
14003
|
exports.getMonthDays = getMonthDays;
|
|
12682
14004
|
exports.getShipmentStatusLabel = getShipmentStatusLabel;
|
|
14005
|
+
exports.getShortDayLabel = getShortDayLabel;
|
|
12683
14006
|
exports.getSupplierColumn = getSupplierColumn;
|
|
12684
14007
|
exports.getTimeHeight = getTimeHeight;
|
|
12685
14008
|
exports.getTimePosition = getTimePosition;
|
|
@@ -12689,6 +14012,8 @@ exports.getWeekDayNames = getWeekDayNames;
|
|
|
12689
14012
|
exports.getWeekDays = getWeekDays;
|
|
12690
14013
|
exports.getWeekKey = getWeekKey;
|
|
12691
14014
|
exports.getYearMonths = getYearMonths;
|
|
14015
|
+
exports.groupDeliveriesByDay = groupDeliveriesByDay;
|
|
14016
|
+
exports.groupDeliveriesByPrefixAndDay = groupDeliveriesByPrefixAndDay;
|
|
12692
14017
|
exports.groupEvents = groupEvents;
|
|
12693
14018
|
exports.isMultiDayEvent = isMultiDayEvent;
|
|
12694
14019
|
exports.isWorkingHour = isWorkingHour;
|