medusa-idosell 1.0.0 → 1.1.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.
@@ -531,10 +531,300 @@ var IdosellOrdersRoute = () => {
531
531
  })
532
532
  });
533
533
  };
534
- var config = (0, _medusajs_admin_sdk.defineRouteConfig)({
534
+ var config$1 = (0, _medusajs_admin_sdk.defineRouteConfig)({
535
535
  label: "IdoSell Orders",
536
536
  icon: _medusajs_icons.ShoppingBag
537
537
  });
538
+ // src/admin/routes/settings/idosell/page.tsx
539
+ function SourceBadge({ source }) {
540
+ if (source === "db") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Badge, {
541
+ color: "green",
542
+ size: "2xsmall",
543
+ children: "Panel (DB)"
544
+ });
545
+ if (source === "env") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Badge, {
546
+ color: "blue",
547
+ size: "2xsmall",
548
+ children: "ENV"
549
+ });
550
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Badge, {
551
+ color: "grey",
552
+ size: "2xsmall",
553
+ children: "Brak"
554
+ });
555
+ }
556
+ function parseOptionalPositiveInt(raw) {
557
+ const trimmed = raw.trim();
558
+ if (!trimmed) return null;
559
+ const num = Number(trimmed);
560
+ if (!Number.isInteger(num) || num <= 0) throw new Error(`Wartość "${trimmed}" musi być dodatnią liczbą całkowitą.`);
561
+ return num;
562
+ }
563
+ var IdosellSettingsPage = () => {
564
+ const [loading, setLoading] = (0, react.useState)(true);
565
+ const [saving, setSaving] = (0, react.useState)(false);
566
+ const [testing, setTesting] = (0, react.useState)(false);
567
+ const [summary, setSummary] = (0, react.useState)(null);
568
+ const [domain, setDomain] = (0, react.useState)("");
569
+ const [apiKey, setApiKey] = (0, react.useState)("");
570
+ const [shopId, setShopId] = (0, react.useState)("");
571
+ const [stockId, setStockId] = (0, react.useState)("");
572
+ const [courierId, setCourierId] = (0, react.useState)("");
573
+ const [paymentFormId, setPaymentFormId] = (0, react.useState)("");
574
+ const [webhookSecret, setWebhookSecret] = (0, react.useState)("");
575
+ const [testResult, setTestResult] = (0, react.useState)(null);
576
+ const applySummary = (data) => {
577
+ setSummary(data);
578
+ setDomain(data.domain ?? "");
579
+ setShopId(data.shop_id ?? "");
580
+ setStockId(data.stock_id !== null ? String(data.stock_id) : "");
581
+ setCourierId(data.courier_id !== null ? String(data.courier_id) : "");
582
+ setPaymentFormId(data.payment_form_id !== null ? String(data.payment_form_id) : "");
583
+ setApiKey("");
584
+ setWebhookSecret("");
585
+ };
586
+ (0, react.useEffect)(() => {
587
+ let active = true;
588
+ sdk.client.fetch("/admin/idosell/settings").then((res) => {
589
+ if (active) applySummary(res.settings);
590
+ }).catch((err) => {
591
+ if (active) _medusajs_ui.toast.error("Nie udało się pobrać ustawień IdoSell", { description: err instanceof Error ? err.message : String(err) });
592
+ }).finally(() => {
593
+ if (active) setLoading(false);
594
+ });
595
+ return () => {
596
+ active = false;
597
+ };
598
+ }, []);
599
+ const handleSave = async (e) => {
600
+ e.preventDefault();
601
+ setSaving(true);
602
+ setTestResult(null);
603
+ try {
604
+ const payload = {
605
+ domain: domain.trim() || null,
606
+ shop_id: shopId.trim() || null,
607
+ stock_id: parseOptionalPositiveInt(stockId),
608
+ courier_id: parseOptionalPositiveInt(courierId),
609
+ payment_form_id: parseOptionalPositiveInt(paymentFormId)
610
+ };
611
+ if (apiKey.trim()) payload.api_key = apiKey.trim();
612
+ if (webhookSecret.trim()) payload.webhook_secret = webhookSecret.trim();
613
+ const res = await sdk.client.fetch("/admin/idosell/settings", {
614
+ method: "PUT",
615
+ body: payload
616
+ });
617
+ applySummary(res.settings);
618
+ _medusajs_ui.toast.success("Zapisano ustawienia IdoSell");
619
+ } catch (err) {
620
+ _medusajs_ui.toast.error("Błąd zapisu ustawień IdoSell", { description: err instanceof Error ? err.message : String(err) });
621
+ } finally {
622
+ setSaving(false);
623
+ }
624
+ };
625
+ const handleTest = async () => {
626
+ setTesting(true);
627
+ setTestResult(null);
628
+ try {
629
+ const body = {};
630
+ if (domain.trim()) body.domain = domain.trim();
631
+ if (apiKey.trim()) body.api_key = apiKey.trim();
632
+ const res = await sdk.client.fetch("/admin/idosell/settings/test", {
633
+ method: "POST",
634
+ body
635
+ });
636
+ if (res.ok) {
637
+ const message = `Połączenie działa (dostawcy w IdoSell: ${res.suppliers_count ?? 0}).`;
638
+ setTestResult({
639
+ ok: true,
640
+ message
641
+ });
642
+ _medusajs_ui.toast.success(message);
643
+ } else {
644
+ const message = res.error || "Test połączenia nie powiódł się.";
645
+ setTestResult({
646
+ ok: false,
647
+ message
648
+ });
649
+ _medusajs_ui.toast.error(message);
650
+ }
651
+ } catch (err) {
652
+ const message = err instanceof Error ? err.message : String(err);
653
+ setTestResult({
654
+ ok: false,
655
+ message
656
+ });
657
+ _medusajs_ui.toast.error(message);
658
+ } finally {
659
+ setTesting(false);
660
+ }
661
+ };
662
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_medusajs_ui.Container, {
663
+ className: "divide-y p-0",
664
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
665
+ className: "flex items-center justify-between px-6 py-4",
666
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Heading, {
667
+ level: "h1",
668
+ children: "IdoSell — Konfiguracja"
669
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
670
+ size: "small",
671
+ className: "text-ui-fg-subtle",
672
+ children: "Ustawienia zapisane w panelu mają pierwszeństwo przed zmiennymi środowiskowymi (.env)."
673
+ })] })
674
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
675
+ onSubmit: handleSave,
676
+ className: "flex flex-col gap-6 px-6 py-6",
677
+ children: loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
678
+ size: "small",
679
+ className: "text-ui-fg-subtle",
680
+ children: "Ładowanie ustawień..."
681
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
682
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
683
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2",
684
+ children: [
685
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
686
+ className: "flex flex-col gap-2",
687
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
688
+ className: "flex items-center justify-between",
689
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
690
+ htmlFor: "idosell-domain",
691
+ children: "Domena IdoSell"
692
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.domain })]
693
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
694
+ id: "idosell-domain",
695
+ placeholder: "np. client1234.idosell.com",
696
+ value: domain,
697
+ onChange: (e) => setDomain(e.target.value)
698
+ })]
699
+ }),
700
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
701
+ className: "flex flex-col gap-2",
702
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
703
+ className: "flex items-center justify-between",
704
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
705
+ htmlFor: "idosell-api-key",
706
+ children: "Klucz API (X-API-KEY)"
707
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.api_key })]
708
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
709
+ id: "idosell-api-key",
710
+ type: "password",
711
+ autoComplete: "new-password",
712
+ placeholder: summary?.api_key_configured ? "Skonfigurowano (zostaw puste, aby nie zmieniać)" : "Wklej klucz API z panelu IdoSell",
713
+ value: apiKey,
714
+ onChange: (e) => setApiKey(e.target.value)
715
+ })]
716
+ }),
717
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
718
+ className: "flex flex-col gap-2",
719
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
720
+ className: "flex items-center justify-between",
721
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
722
+ htmlFor: "idosell-shop-id",
723
+ children: "ID Sklepu (Shop ID)"
724
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.shop_id })]
725
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
726
+ id: "idosell-shop-id",
727
+ placeholder: "np. 1",
728
+ value: shopId,
729
+ onChange: (e) => setShopId(e.target.value)
730
+ })]
731
+ }),
732
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
733
+ className: "flex flex-col gap-2",
734
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
735
+ className: "flex items-center justify-between",
736
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
737
+ htmlFor: "idosell-stock-id",
738
+ children: "ID Magazynu (Stock ID)"
739
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.stock_id })]
740
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
741
+ id: "idosell-stock-id",
742
+ type: "number",
743
+ min: 1,
744
+ placeholder: "np. 1",
745
+ value: stockId,
746
+ onChange: (e) => setStockId(e.target.value)
747
+ })]
748
+ }),
749
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
750
+ className: "flex flex-col gap-2",
751
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
752
+ className: "flex items-center justify-between",
753
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
754
+ htmlFor: "idosell-courier-id",
755
+ children: "ID Kuriera (Courier ID)"
756
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.courier_id })]
757
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
758
+ id: "idosell-courier-id",
759
+ type: "number",
760
+ min: 1,
761
+ placeholder: "np. 100",
762
+ value: courierId,
763
+ onChange: (e) => setCourierId(e.target.value)
764
+ })]
765
+ }),
766
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
767
+ className: "flex flex-col gap-2",
768
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
769
+ className: "flex items-center justify-between",
770
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
771
+ htmlFor: "idosell-payment-form-id",
772
+ children: "ID Formy Płatności (Payment Form ID)"
773
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.payment_form_id })]
774
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
775
+ id: "idosell-payment-form-id",
776
+ type: "number",
777
+ min: 1,
778
+ placeholder: "np. 1",
779
+ value: paymentFormId,
780
+ onChange: (e) => setPaymentFormId(e.target.value)
781
+ })]
782
+ }),
783
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
784
+ className: "flex flex-col gap-2 md:col-span-2",
785
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
786
+ className: "flex items-center justify-between",
787
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Label, {
788
+ htmlFor: "idosell-webhook-secret",
789
+ children: "Sekret Webhooka (Bearer)"
790
+ }), summary && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SourceBadge, { source: summary.sources.webhook_secret })]
791
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Input, {
792
+ id: "idosell-webhook-secret",
793
+ type: "password",
794
+ autoComplete: "new-password",
795
+ placeholder: summary?.webhook_secret_configured ? "Skonfigurowano (zostaw puste, aby nie zmieniać)" : "Opcjonalny sekret weryfikujący webhooki z IdoSell",
796
+ value: webhookSecret,
797
+ onChange: (e) => setWebhookSecret(e.target.value)
798
+ })]
799
+ })
800
+ ]
801
+ }),
802
+ testResult && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Text, {
803
+ size: "small",
804
+ className: testResult.ok ? "text-ui-fg-interactive" : "text-ui-fg-error",
805
+ children: testResult.message
806
+ }),
807
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
808
+ className: "flex items-center gap-3",
809
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
810
+ type: "submit",
811
+ isLoading: saving,
812
+ disabled: saving || testing,
813
+ children: "Zapisz ustawienia"
814
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
815
+ type: "button",
816
+ variant: "secondary",
817
+ onClick: handleTest,
818
+ isLoading: testing,
819
+ disabled: saving || testing,
820
+ children: "Testuj połączenie"
821
+ })]
822
+ })
823
+ ] })
824
+ })]
825
+ });
826
+ };
827
+ var config = (0, _medusajs_admin_sdk.defineRouteConfig)({ label: "IdoSell" });
538
828
  var plugin = {
539
829
  widgetModule: { widgets: [{
540
830
  Component: IdosellOrderDetailsWidget,
@@ -544,18 +834,32 @@ var plugin = {
544
834
  routeModule: { routes: [{
545
835
  Component: IdosellOrdersRoute,
546
836
  path: "/idosell-orders",
837
+ handle: {
838
+ label: config$1.label,
839
+ translationNs: config$1.translationNs
840
+ }
841
+ }, {
842
+ Component: IdosellSettingsPage,
843
+ path: "/settings/idosell",
547
844
  handle: {
548
845
  label: config.label,
549
846
  translationNs: config.translationNs
550
847
  }
551
848
  }] },
552
849
  menuItemModule: { menuItems: [{
553
- label: config.label,
554
- icon: config.icon,
850
+ label: config$1.label,
851
+ icon: config$1.icon,
555
852
  path: "/idosell-orders",
556
853
  nested: void 0,
557
854
  rank: void 0,
558
855
  translationNs: void 0
856
+ }, {
857
+ label: config.label,
858
+ icon: void 0,
859
+ path: "/settings/idosell",
860
+ nested: void 0,
861
+ rank: void 0,
862
+ translationNs: void 0
559
863
  }] },
560
864
  formModule: { customFields: {} },
561
865
  displayModule: { displays: {} },
@@ -1,10 +1,10 @@
1
1
  import { defineRouteConfig, defineWidgetConfig } from "@medusajs/admin-sdk";
2
2
  import { ShoppingBag, Spinner } from "@medusajs/icons";
3
- import { Badge, Button, Container, DataTable, Heading, Label, Switch, Text, createDataTableColumnHelper, createDataTableFilterHelper, toast, useDataTable } from "@medusajs/ui";
3
+ import { Badge, Button, Container, DataTable, Heading, Input, Label, Switch, Text, createDataTableColumnHelper, createDataTableFilterHelper, toast, useDataTable } from "@medusajs/ui";
4
4
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
5
5
  import Medusa from "@medusajs/js-sdk";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- import { useMemo, useState } from "react";
7
+ import { useEffect, useMemo, useState } from "react";
8
8
  import { Link } from "react-router-dom";
9
9
  import "@medusajs/admin-shared";
10
10
  // src/admin/lib/sdk.ts
@@ -509,10 +509,300 @@ var IdosellOrdersRoute = () => {
509
509
  })
510
510
  });
511
511
  };
512
- var config = defineRouteConfig({
512
+ var config$1 = defineRouteConfig({
513
513
  label: "IdoSell Orders",
514
514
  icon: ShoppingBag
515
515
  });
516
+ // src/admin/routes/settings/idosell/page.tsx
517
+ function SourceBadge({ source }) {
518
+ if (source === "db") return /* @__PURE__ */ jsx(Badge, {
519
+ color: "green",
520
+ size: "2xsmall",
521
+ children: "Panel (DB)"
522
+ });
523
+ if (source === "env") return /* @__PURE__ */ jsx(Badge, {
524
+ color: "blue",
525
+ size: "2xsmall",
526
+ children: "ENV"
527
+ });
528
+ return /* @__PURE__ */ jsx(Badge, {
529
+ color: "grey",
530
+ size: "2xsmall",
531
+ children: "Brak"
532
+ });
533
+ }
534
+ function parseOptionalPositiveInt(raw) {
535
+ const trimmed = raw.trim();
536
+ if (!trimmed) return null;
537
+ const num = Number(trimmed);
538
+ if (!Number.isInteger(num) || num <= 0) throw new Error(`Wartość "${trimmed}" musi być dodatnią liczbą całkowitą.`);
539
+ return num;
540
+ }
541
+ var IdosellSettingsPage = () => {
542
+ const [loading, setLoading] = useState(true);
543
+ const [saving, setSaving] = useState(false);
544
+ const [testing, setTesting] = useState(false);
545
+ const [summary, setSummary] = useState(null);
546
+ const [domain, setDomain] = useState("");
547
+ const [apiKey, setApiKey] = useState("");
548
+ const [shopId, setShopId] = useState("");
549
+ const [stockId, setStockId] = useState("");
550
+ const [courierId, setCourierId] = useState("");
551
+ const [paymentFormId, setPaymentFormId] = useState("");
552
+ const [webhookSecret, setWebhookSecret] = useState("");
553
+ const [testResult, setTestResult] = useState(null);
554
+ const applySummary = (data) => {
555
+ setSummary(data);
556
+ setDomain(data.domain ?? "");
557
+ setShopId(data.shop_id ?? "");
558
+ setStockId(data.stock_id !== null ? String(data.stock_id) : "");
559
+ setCourierId(data.courier_id !== null ? String(data.courier_id) : "");
560
+ setPaymentFormId(data.payment_form_id !== null ? String(data.payment_form_id) : "");
561
+ setApiKey("");
562
+ setWebhookSecret("");
563
+ };
564
+ useEffect(() => {
565
+ let active = true;
566
+ sdk.client.fetch("/admin/idosell/settings").then((res) => {
567
+ if (active) applySummary(res.settings);
568
+ }).catch((err) => {
569
+ if (active) toast.error("Nie udało się pobrać ustawień IdoSell", { description: err instanceof Error ? err.message : String(err) });
570
+ }).finally(() => {
571
+ if (active) setLoading(false);
572
+ });
573
+ return () => {
574
+ active = false;
575
+ };
576
+ }, []);
577
+ const handleSave = async (e) => {
578
+ e.preventDefault();
579
+ setSaving(true);
580
+ setTestResult(null);
581
+ try {
582
+ const payload = {
583
+ domain: domain.trim() || null,
584
+ shop_id: shopId.trim() || null,
585
+ stock_id: parseOptionalPositiveInt(stockId),
586
+ courier_id: parseOptionalPositiveInt(courierId),
587
+ payment_form_id: parseOptionalPositiveInt(paymentFormId)
588
+ };
589
+ if (apiKey.trim()) payload.api_key = apiKey.trim();
590
+ if (webhookSecret.trim()) payload.webhook_secret = webhookSecret.trim();
591
+ const res = await sdk.client.fetch("/admin/idosell/settings", {
592
+ method: "PUT",
593
+ body: payload
594
+ });
595
+ applySummary(res.settings);
596
+ toast.success("Zapisano ustawienia IdoSell");
597
+ } catch (err) {
598
+ toast.error("Błąd zapisu ustawień IdoSell", { description: err instanceof Error ? err.message : String(err) });
599
+ } finally {
600
+ setSaving(false);
601
+ }
602
+ };
603
+ const handleTest = async () => {
604
+ setTesting(true);
605
+ setTestResult(null);
606
+ try {
607
+ const body = {};
608
+ if (domain.trim()) body.domain = domain.trim();
609
+ if (apiKey.trim()) body.api_key = apiKey.trim();
610
+ const res = await sdk.client.fetch("/admin/idosell/settings/test", {
611
+ method: "POST",
612
+ body
613
+ });
614
+ if (res.ok) {
615
+ const message = `Połączenie działa (dostawcy w IdoSell: ${res.suppliers_count ?? 0}).`;
616
+ setTestResult({
617
+ ok: true,
618
+ message
619
+ });
620
+ toast.success(message);
621
+ } else {
622
+ const message = res.error || "Test połączenia nie powiódł się.";
623
+ setTestResult({
624
+ ok: false,
625
+ message
626
+ });
627
+ toast.error(message);
628
+ }
629
+ } catch (err) {
630
+ const message = err instanceof Error ? err.message : String(err);
631
+ setTestResult({
632
+ ok: false,
633
+ message
634
+ });
635
+ toast.error(message);
636
+ } finally {
637
+ setTesting(false);
638
+ }
639
+ };
640
+ return /* @__PURE__ */ jsxs(Container, {
641
+ className: "divide-y p-0",
642
+ children: [/* @__PURE__ */ jsx("div", {
643
+ className: "flex items-center justify-between px-6 py-4",
644
+ children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Heading, {
645
+ level: "h1",
646
+ children: "IdoSell — Konfiguracja"
647
+ }), /* @__PURE__ */ jsx(Text, {
648
+ size: "small",
649
+ className: "text-ui-fg-subtle",
650
+ children: "Ustawienia zapisane w panelu mają pierwszeństwo przed zmiennymi środowiskowymi (.env)."
651
+ })] })
652
+ }), /* @__PURE__ */ jsx("form", {
653
+ onSubmit: handleSave,
654
+ className: "flex flex-col gap-6 px-6 py-6",
655
+ children: loading ? /* @__PURE__ */ jsx(Text, {
656
+ size: "small",
657
+ className: "text-ui-fg-subtle",
658
+ children: "Ładowanie ustawień..."
659
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
660
+ /* @__PURE__ */ jsxs("div", {
661
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2",
662
+ children: [
663
+ /* @__PURE__ */ jsxs("div", {
664
+ className: "flex flex-col gap-2",
665
+ children: [/* @__PURE__ */ jsxs("div", {
666
+ className: "flex items-center justify-between",
667
+ children: [/* @__PURE__ */ jsx(Label, {
668
+ htmlFor: "idosell-domain",
669
+ children: "Domena IdoSell"
670
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.domain })]
671
+ }), /* @__PURE__ */ jsx(Input, {
672
+ id: "idosell-domain",
673
+ placeholder: "np. client1234.idosell.com",
674
+ value: domain,
675
+ onChange: (e) => setDomain(e.target.value)
676
+ })]
677
+ }),
678
+ /* @__PURE__ */ jsxs("div", {
679
+ className: "flex flex-col gap-2",
680
+ children: [/* @__PURE__ */ jsxs("div", {
681
+ className: "flex items-center justify-between",
682
+ children: [/* @__PURE__ */ jsx(Label, {
683
+ htmlFor: "idosell-api-key",
684
+ children: "Klucz API (X-API-KEY)"
685
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.api_key })]
686
+ }), /* @__PURE__ */ jsx(Input, {
687
+ id: "idosell-api-key",
688
+ type: "password",
689
+ autoComplete: "new-password",
690
+ placeholder: summary?.api_key_configured ? "Skonfigurowano (zostaw puste, aby nie zmieniać)" : "Wklej klucz API z panelu IdoSell",
691
+ value: apiKey,
692
+ onChange: (e) => setApiKey(e.target.value)
693
+ })]
694
+ }),
695
+ /* @__PURE__ */ jsxs("div", {
696
+ className: "flex flex-col gap-2",
697
+ children: [/* @__PURE__ */ jsxs("div", {
698
+ className: "flex items-center justify-between",
699
+ children: [/* @__PURE__ */ jsx(Label, {
700
+ htmlFor: "idosell-shop-id",
701
+ children: "ID Sklepu (Shop ID)"
702
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.shop_id })]
703
+ }), /* @__PURE__ */ jsx(Input, {
704
+ id: "idosell-shop-id",
705
+ placeholder: "np. 1",
706
+ value: shopId,
707
+ onChange: (e) => setShopId(e.target.value)
708
+ })]
709
+ }),
710
+ /* @__PURE__ */ jsxs("div", {
711
+ className: "flex flex-col gap-2",
712
+ children: [/* @__PURE__ */ jsxs("div", {
713
+ className: "flex items-center justify-between",
714
+ children: [/* @__PURE__ */ jsx(Label, {
715
+ htmlFor: "idosell-stock-id",
716
+ children: "ID Magazynu (Stock ID)"
717
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.stock_id })]
718
+ }), /* @__PURE__ */ jsx(Input, {
719
+ id: "idosell-stock-id",
720
+ type: "number",
721
+ min: 1,
722
+ placeholder: "np. 1",
723
+ value: stockId,
724
+ onChange: (e) => setStockId(e.target.value)
725
+ })]
726
+ }),
727
+ /* @__PURE__ */ jsxs("div", {
728
+ className: "flex flex-col gap-2",
729
+ children: [/* @__PURE__ */ jsxs("div", {
730
+ className: "flex items-center justify-between",
731
+ children: [/* @__PURE__ */ jsx(Label, {
732
+ htmlFor: "idosell-courier-id",
733
+ children: "ID Kuriera (Courier ID)"
734
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.courier_id })]
735
+ }), /* @__PURE__ */ jsx(Input, {
736
+ id: "idosell-courier-id",
737
+ type: "number",
738
+ min: 1,
739
+ placeholder: "np. 100",
740
+ value: courierId,
741
+ onChange: (e) => setCourierId(e.target.value)
742
+ })]
743
+ }),
744
+ /* @__PURE__ */ jsxs("div", {
745
+ className: "flex flex-col gap-2",
746
+ children: [/* @__PURE__ */ jsxs("div", {
747
+ className: "flex items-center justify-between",
748
+ children: [/* @__PURE__ */ jsx(Label, {
749
+ htmlFor: "idosell-payment-form-id",
750
+ children: "ID Formy Płatności (Payment Form ID)"
751
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.payment_form_id })]
752
+ }), /* @__PURE__ */ jsx(Input, {
753
+ id: "idosell-payment-form-id",
754
+ type: "number",
755
+ min: 1,
756
+ placeholder: "np. 1",
757
+ value: paymentFormId,
758
+ onChange: (e) => setPaymentFormId(e.target.value)
759
+ })]
760
+ }),
761
+ /* @__PURE__ */ jsxs("div", {
762
+ className: "flex flex-col gap-2 md:col-span-2",
763
+ children: [/* @__PURE__ */ jsxs("div", {
764
+ className: "flex items-center justify-between",
765
+ children: [/* @__PURE__ */ jsx(Label, {
766
+ htmlFor: "idosell-webhook-secret",
767
+ children: "Sekret Webhooka (Bearer)"
768
+ }), summary && /* @__PURE__ */ jsx(SourceBadge, { source: summary.sources.webhook_secret })]
769
+ }), /* @__PURE__ */ jsx(Input, {
770
+ id: "idosell-webhook-secret",
771
+ type: "password",
772
+ autoComplete: "new-password",
773
+ placeholder: summary?.webhook_secret_configured ? "Skonfigurowano (zostaw puste, aby nie zmieniać)" : "Opcjonalny sekret weryfikujący webhooki z IdoSell",
774
+ value: webhookSecret,
775
+ onChange: (e) => setWebhookSecret(e.target.value)
776
+ })]
777
+ })
778
+ ]
779
+ }),
780
+ testResult && /* @__PURE__ */ jsx(Text, {
781
+ size: "small",
782
+ className: testResult.ok ? "text-ui-fg-interactive" : "text-ui-fg-error",
783
+ children: testResult.message
784
+ }),
785
+ /* @__PURE__ */ jsxs("div", {
786
+ className: "flex items-center gap-3",
787
+ children: [/* @__PURE__ */ jsx(Button, {
788
+ type: "submit",
789
+ isLoading: saving,
790
+ disabled: saving || testing,
791
+ children: "Zapisz ustawienia"
792
+ }), /* @__PURE__ */ jsx(Button, {
793
+ type: "button",
794
+ variant: "secondary",
795
+ onClick: handleTest,
796
+ isLoading: testing,
797
+ disabled: saving || testing,
798
+ children: "Testuj połączenie"
799
+ })]
800
+ })
801
+ ] })
802
+ })]
803
+ });
804
+ };
805
+ var config = defineRouteConfig({ label: "IdoSell" });
516
806
  var plugin = {
517
807
  widgetModule: { widgets: [{
518
808
  Component: IdosellOrderDetailsWidget,
@@ -522,18 +812,32 @@ var plugin = {
522
812
  routeModule: { routes: [{
523
813
  Component: IdosellOrdersRoute,
524
814
  path: "/idosell-orders",
815
+ handle: {
816
+ label: config$1.label,
817
+ translationNs: config$1.translationNs
818
+ }
819
+ }, {
820
+ Component: IdosellSettingsPage,
821
+ path: "/settings/idosell",
525
822
  handle: {
526
823
  label: config.label,
527
824
  translationNs: config.translationNs
528
825
  }
529
826
  }] },
530
827
  menuItemModule: { menuItems: [{
531
- label: config.label,
532
- icon: config.icon,
828
+ label: config$1.label,
829
+ icon: config$1.icon,
533
830
  path: "/idosell-orders",
534
831
  nested: void 0,
535
832
  rank: void 0,
536
833
  translationNs: void 0
834
+ }, {
835
+ label: config.label,
836
+ icon: void 0,
837
+ path: "/settings/idosell",
838
+ nested: void 0,
839
+ rank: void 0,
840
+ translationNs: void 0
537
841
  }] },
538
842
  formModule: { customFields: {} },
539
843
  displayModule: { displays: {} },