@lodashventure/medusa-membership 0.5.13 → 0.5.14

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.
@@ -365,20 +365,20 @@ const config$2 = adminSdk.defineRouteConfig({
365
365
  label: "Membership",
366
366
  icon: icons.Users
367
367
  });
368
- const useCreateMembershipConsent = () => {
368
+ const useCreateMembershipTier = () => {
369
369
  const [isPending, setIsPending] = react.useState(false);
370
370
  const [error, setError] = react.useState(null);
371
371
  const mutate = async (data, { onSuccess } = {}) => {
372
372
  try {
373
373
  setIsPending(true);
374
374
  setError(null);
375
- const response = await axios__default.default.post("/admin/membership-consents", data);
375
+ const response = await axios__default.default.post("/admin/member-tiers", data);
376
376
  if (onSuccess) {
377
377
  onSuccess();
378
378
  }
379
379
  return response.data;
380
380
  } catch (err) {
381
- const error2 = err instanceof Error ? err : new Error("Failed to create consent");
381
+ const error2 = err instanceof Error ? err : new Error("Failed to create tier");
382
382
  setError(error2);
383
383
  throw error2;
384
384
  } finally {
@@ -391,19 +391,19 @@ const useCreateMembershipConsent = () => {
391
391
  error
392
392
  };
393
393
  };
394
- const useDeleteMembershipConsent = () => {
394
+ const useDeleteMembershipTier = () => {
395
395
  const [isPending, setIsPending] = react.useState(false);
396
396
  const [error, setError] = react.useState(null);
397
397
  const mutate = async (id, { onSuccess } = {}) => {
398
398
  try {
399
399
  setIsPending(true);
400
400
  setError(null);
401
- await axios__default.default.delete(`/admin/membership-consents/${id}`);
401
+ await axios__default.default.delete(`/admin/member-tiers/${id}`);
402
402
  if (onSuccess) {
403
403
  onSuccess();
404
404
  }
405
405
  } catch (err) {
406
- const error2 = err instanceof Error ? err : new Error("Failed to delete consent");
406
+ const error2 = err instanceof Error ? err : new Error("Failed to delete tier");
407
407
  setError(error2);
408
408
  throw error2;
409
409
  } finally {
@@ -416,56 +416,62 @@ const useDeleteMembershipConsent = () => {
416
416
  error
417
417
  };
418
418
  };
419
- const useMembershipConsents = () => {
419
+ const useMembershipTiers = (params = {
420
+ limit: 15,
421
+ offset: 0,
422
+ order: {
423
+ min_points: "ASC"
424
+ }
425
+ }) => {
426
+ var _a;
420
427
  const [data, setData] = react.useState(void 0);
421
428
  const [isLoading, setIsLoading] = react.useState(true);
422
429
  const [error, setError] = react.useState(null);
423
- const fetchConsents = async () => {
430
+ const fetchTiers = async () => {
424
431
  try {
425
432
  setIsLoading(true);
426
433
  setError(null);
427
- const response = await axios__default.default.get("/admin/membership-consents");
434
+ const response = await axios__default.default.get("/admin/member-tiers", {
435
+ params
436
+ });
428
437
  setData(
429
438
  response.data
430
439
  );
431
440
  } catch (err) {
432
- setError(
433
- err instanceof Error ? err : new Error("Failed to fetch consents")
434
- );
441
+ setError(err instanceof Error ? err : new Error("Failed to fetch tiers"));
435
442
  } finally {
436
443
  setIsLoading(false);
437
444
  }
438
445
  };
439
446
  react.useEffect(() => {
440
- fetchConsents();
441
- }, []);
447
+ fetchTiers();
448
+ }, [params.limit, params.offset, (_a = params.order) == null ? void 0 : _a.min_points]);
442
449
  return {
443
450
  data,
444
451
  isLoading,
445
452
  error,
446
- refetch: fetchConsents
453
+ refetch: fetchTiers
447
454
  };
448
455
  };
449
- const useUpdateMembershipConsent = () => {
456
+ const useUpdateMembershipTier = () => {
450
457
  const [isPending, setIsPending] = react.useState(false);
451
458
  const [error, setError] = react.useState(null);
452
- const mutate = async (consentKey, { onSuccess } = {}) => {
459
+ const mutate = async (tier, { onSuccess } = {}) => {
453
460
  try {
454
461
  setIsPending(true);
455
462
  setError(null);
456
- const response = await axios__default.default.patch(
457
- `/admin/membership-consents/${consentKey.id}`,
458
- {
459
- name: consentKey.name,
460
- description: consentKey.description
461
- }
462
- );
463
+ const response = await axios__default.default.patch(`/admin/member-tiers/${tier.id}`, {
464
+ name: tier.name,
465
+ description: tier.description,
466
+ privilege_description: tier.privilege_description,
467
+ min_points: tier.min_points
468
+ });
463
469
  if (onSuccess) {
464
470
  onSuccess();
465
471
  }
466
472
  return response.data;
467
473
  } catch (err) {
468
- const error2 = err instanceof Error ? err : new Error("Failed to update consent");
474
+ const error2 = err instanceof Error ? err : new Error("Failed to update tier");
469
475
  setError(error2);
470
476
  throw error2;
471
477
  } finally {
@@ -480,34 +486,46 @@ const useUpdateMembershipConsent = () => {
480
486
  };
481
487
  const columnHelper$1 = ui.createDataTableColumnHelper();
482
488
  const columns$1 = [
489
+ columnHelper$1.accessor("min_points", {
490
+ header: "Min Points"
491
+ }),
483
492
  columnHelper$1.accessor("name", {
484
493
  header: "Name"
485
494
  }),
486
495
  columnHelper$1.accessor("description", {
487
496
  header: "Description",
488
497
  maxSize: 250
498
+ }),
499
+ columnHelper$1.accessor("privilege_description", {
500
+ header: "Privilege Description",
501
+ maxSize: 250
489
502
  })
490
503
  ];
491
- const MembershipConsentsRenderer = () => {
504
+ const MembershipTierRenderer = () => {
492
505
  const dialog = ui.usePrompt();
493
506
  const [pagination, setPagination] = react.useState({
494
507
  pageSize: 1e3,
495
508
  pageIndex: 0
496
509
  });
497
510
  const [isDrawerOpen, setIsDrawerOpen] = react.useState(false);
498
- const [editingConsent, setEditingConsent] = react.useState(null);
511
+ const [editingTier, setEditingTier] = react.useState(null);
499
512
  const [formData, setFormData] = react.useState({
500
513
  name: "",
501
- description: ""
514
+ description: "",
515
+ privilege_description: "",
516
+ min_points: 0
502
517
  });
503
- const { data, isLoading, refetch } = useMembershipConsents();
504
- const createConsent = useCreateMembershipConsent();
505
- const updateConsent = useUpdateMembershipConsent();
506
- const deleteConsent = useDeleteMembershipConsent();
518
+ const { data, isLoading, refetch } = useMembershipTiers({
519
+ limit: pagination.pageSize,
520
+ offset: pagination.pageIndex * pagination.pageSize
521
+ });
522
+ const createTier = useCreateMembershipTier();
523
+ const updateTier = useUpdateMembershipTier();
524
+ const deleteTier = useDeleteMembershipTier();
507
525
  const table = ui.useDataTable({
508
526
  columns: columns$1,
509
- data: (data == null ? void 0 : data.consent_keys) || [],
510
- getRowId: (consent) => consent.id,
527
+ data: (data == null ? void 0 : data.tiers) || [],
528
+ getRowId: (tier) => tier.id,
511
529
  rowCount: (data == null ? void 0 : data.count) || 0,
512
530
  isLoading,
513
531
  pagination: {
@@ -535,25 +553,29 @@ const MembershipConsentsRenderer = () => {
535
553
  const handleReset = () => {
536
554
  setFormData({
537
555
  name: "",
538
- description: ""
556
+ description: "",
557
+ privilege_description: "",
558
+ min_points: 0
539
559
  });
540
560
  };
541
- const openDrawer = (consentKey) => {
542
- if (consentKey) {
543
- setEditingConsent(consentKey);
561
+ const openDrawer = (tier) => {
562
+ if (tier) {
563
+ setEditingTier(tier);
544
564
  setFormData({
545
- name: consentKey.name,
546
- description: consentKey.description
565
+ name: tier.name,
566
+ description: tier.description,
567
+ privilege_description: tier.privilege_description,
568
+ min_points: tier.min_points
547
569
  });
548
570
  } else {
549
- setEditingConsent(null);
571
+ setEditingTier(null);
550
572
  handleReset();
551
573
  }
552
574
  setIsDrawerOpen(true);
553
575
  };
554
576
  const closeDrawer = () => {
555
577
  setIsDrawerOpen(false);
556
- setEditingConsent(null);
578
+ setEditingTier(null);
557
579
  handleReset();
558
580
  refetch();
559
581
  };
@@ -564,15 +586,15 @@ const MembershipConsentsRenderer = () => {
564
586
  ui.toast.error("Name is required", { dismissable: true, duration: 2500 });
565
587
  return;
566
588
  }
567
- if (editingConsent) {
568
- await updateConsent.mutateAsync({ id: editingConsent.id, ...formData });
569
- ui.toast.success("Consent updated successfully", {
589
+ if (editingTier) {
590
+ await updateTier.mutateAsync({ id: editingTier.id, ...formData });
591
+ ui.toast.success("Tier updated successfully", {
570
592
  dismissable: true,
571
593
  duration: 2500
572
594
  });
573
595
  } else {
574
- await createConsent.mutateAsync(formData);
575
- ui.toast.success("Consent created successfully", {
596
+ await createTier.mutateAsync(formData);
597
+ ui.toast.success("Tier created successfully", {
576
598
  dismissable: true,
577
599
  duration: 2500
578
600
  });
@@ -580,13 +602,13 @@ const MembershipConsentsRenderer = () => {
580
602
  closeDrawer();
581
603
  } catch (error) {
582
604
  if (axios__default.default.isAxiosError(error)) {
583
- ui.toast.error("Error saving consent", {
605
+ ui.toast.error("Error saving tier", {
584
606
  description: (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message,
585
607
  dismissable: true,
586
608
  duration: 2500
587
609
  });
588
610
  } else {
589
- ui.toast.error("Error saving consent", {
611
+ ui.toast.error("Error saving tier", {
590
612
  dismissable: true,
591
613
  duration: 2500
592
614
  });
@@ -597,27 +619,27 @@ const MembershipConsentsRenderer = () => {
597
619
  var _a, _b;
598
620
  try {
599
621
  const confirmed = await dialog({
600
- title: "Delete Membership Consent",
601
- description: `Are you sure you want to delete the \`${editingConsent == null ? void 0 : editingConsent.name}\` consent?`
622
+ title: "Delete Membership Tier",
623
+ description: `Are you sure you want to delete the \`${editingTier == null ? void 0 : editingTier.name}\` tier?`
602
624
  });
603
625
  if (!confirmed) {
604
626
  return;
605
627
  }
606
- await deleteConsent.mutateAsync(id);
607
- ui.toast.success("Consent deleted successfully", {
628
+ await deleteTier.mutateAsync(id);
629
+ ui.toast.success("Tier deleted successfully", {
608
630
  dismissable: true,
609
631
  duration: 2500
610
632
  });
611
633
  closeDrawer();
612
634
  } catch (error) {
613
635
  if (axios__default.default.isAxiosError(error)) {
614
- ui.toast.error("Error deleting consent", {
636
+ ui.toast.error("Error deleting tier", {
615
637
  description: (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message,
616
638
  dismissable: true,
617
639
  duration: 2500
618
640
  });
619
641
  } else {
620
- ui.toast.error("Error deleting consent", {
642
+ ui.toast.error("Error deleting tier", {
621
643
  dismissable: true,
622
644
  duration: 2500
623
645
  });
@@ -627,53 +649,66 @@ const MembershipConsentsRenderer = () => {
627
649
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
628
650
  /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "flex flex-col p-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.DataTable, { instance: table, children: [
629
651
  /* @__PURE__ */ jsxRuntime.jsxs(ui.DataTable.Toolbar, { className: "flex flex-col items-start justify-between gap-2 md:flex-row md:items-center", children: [
630
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Membership Consents" }),
631
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => openDrawer(), children: "Add Consent" })
652
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Membership Tiers" }),
653
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => openDrawer(), children: "Add Tier" })
632
654
  ] }),
633
655
  /* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Table, {})
634
656
  ] }) }),
635
657
  /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer, { open: isDrawerOpen, onOpenChange: setIsDrawerOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Content, { children: [
636
- /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Title, { children: editingConsent ? "Edit Consent" : "Add Consent" }) }),
637
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Body, { "aria-description": "Membership Consent Form", children: [
638
- /* @__PURE__ */ jsxRuntime.jsxs(
639
- "div",
640
- {
641
- className: "space-y-4",
642
- "aria-description": "Membership Consent Form",
643
- children: [
644
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Name" }),
645
- /* @__PURE__ */ jsxRuntime.jsx(
646
- ui.Input,
647
- {
648
- name: "name",
649
- value: formData.name,
650
- onChange: handleInputChange
651
- }
652
- ),
653
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Description" }),
654
- /* @__PURE__ */ jsxRuntime.jsx(
655
- ui.Textarea,
656
- {
657
- className: "truncate",
658
- name: "description",
659
- value: formData.description,
660
- onChange: handleTextAreaChange
661
- }
662
- )
663
- ]
664
- }
665
- ),
658
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Title, { children: editingTier ? "Edit Tier" : "Add Tier" }) }),
659
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Body, { "aria-description": "Membership Tier Form", children: [
660
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", "aria-description": "Membership Tier Form", children: [
661
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Name" }),
662
+ /* @__PURE__ */ jsxRuntime.jsx(
663
+ ui.Input,
664
+ {
665
+ name: "name",
666
+ value: formData.name,
667
+ onChange: handleInputChange
668
+ }
669
+ ),
670
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Description" }),
671
+ /* @__PURE__ */ jsxRuntime.jsx(
672
+ ui.Textarea,
673
+ {
674
+ className: "truncate",
675
+ name: "description",
676
+ value: formData.description,
677
+ onChange: handleTextAreaChange
678
+ }
679
+ ),
680
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Privilege Description" }),
681
+ /* @__PURE__ */ jsxRuntime.jsx(
682
+ ui.Textarea,
683
+ {
684
+ className: "truncate",
685
+ name: "privilege_description",
686
+ value: formData.privilege_description,
687
+ onChange: handleTextAreaChange
688
+ }
689
+ ),
690
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Points" }),
691
+ /* @__PURE__ */ jsxRuntime.jsx(
692
+ ui.Input,
693
+ {
694
+ name: "min_points",
695
+ type: "number",
696
+ value: formData.min_points,
697
+ onChange: handleInputChange
698
+ }
699
+ )
700
+ ] }),
666
701
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2 mt-6", children: [
667
702
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: closeDrawer, children: "Cancel" }),
668
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: handleSubmit, children: editingConsent ? "Update" : "Create" })
703
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: handleSubmit, children: editingTier ? "Update" : "Create" })
669
704
  ] })
670
705
  ] }),
671
- /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Footer, { className: "flex justify-start", children: editingConsent && /* @__PURE__ */ jsxRuntime.jsx(
706
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Footer, { className: "flex justify-start", children: editingTier && /* @__PURE__ */ jsxRuntime.jsx(
672
707
  ui.Button,
673
708
  {
674
709
  variant: "danger",
675
710
  onClick: () => {
676
- handleDelete(editingConsent.id);
711
+ handleDelete(editingTier.id);
677
712
  },
678
713
  children: "Delete"
679
714
  }
@@ -681,26 +716,26 @@ const MembershipConsentsRenderer = () => {
681
716
  ] }) })
682
717
  ] });
683
718
  };
684
- const MembershipConsentPage = () => {
685
- return /* @__PURE__ */ jsxRuntime.jsx(MembershipConsentsRenderer, {});
719
+ const MembershipTierPage = () => {
720
+ return /* @__PURE__ */ jsxRuntime.jsx(MembershipTierRenderer, {});
686
721
  };
687
722
  const config$1 = adminSdk.defineRouteConfig({
688
- label: "Membership Consents"
723
+ label: "Membership Tiers"
689
724
  });
690
- const useCreateMembershipTier = () => {
725
+ const useCreateMembershipConsent = () => {
691
726
  const [isPending, setIsPending] = react.useState(false);
692
727
  const [error, setError] = react.useState(null);
693
728
  const mutate = async (data, { onSuccess } = {}) => {
694
729
  try {
695
730
  setIsPending(true);
696
731
  setError(null);
697
- const response = await axios__default.default.post("/admin/member-tiers", data);
732
+ const response = await axios__default.default.post("/admin/membership-consents", data);
698
733
  if (onSuccess) {
699
734
  onSuccess();
700
735
  }
701
736
  return response.data;
702
737
  } catch (err) {
703
- const error2 = err instanceof Error ? err : new Error("Failed to create tier");
738
+ const error2 = err instanceof Error ? err : new Error("Failed to create consent");
704
739
  setError(error2);
705
740
  throw error2;
706
741
  } finally {
@@ -713,19 +748,19 @@ const useCreateMembershipTier = () => {
713
748
  error
714
749
  };
715
750
  };
716
- const useDeleteMembershipTier = () => {
751
+ const useDeleteMembershipConsent = () => {
717
752
  const [isPending, setIsPending] = react.useState(false);
718
753
  const [error, setError] = react.useState(null);
719
754
  const mutate = async (id, { onSuccess } = {}) => {
720
755
  try {
721
756
  setIsPending(true);
722
757
  setError(null);
723
- await axios__default.default.delete(`/admin/member-tiers/${id}`);
758
+ await axios__default.default.delete(`/admin/membership-consents/${id}`);
724
759
  if (onSuccess) {
725
760
  onSuccess();
726
761
  }
727
762
  } catch (err) {
728
- const error2 = err instanceof Error ? err : new Error("Failed to delete tier");
763
+ const error2 = err instanceof Error ? err : new Error("Failed to delete consent");
729
764
  setError(error2);
730
765
  throw error2;
731
766
  } finally {
@@ -738,62 +773,56 @@ const useDeleteMembershipTier = () => {
738
773
  error
739
774
  };
740
775
  };
741
- const useMembershipTiers = (params = {
742
- limit: 15,
743
- offset: 0,
744
- order: {
745
- min_points: "ASC"
746
- }
747
- }) => {
748
- var _a;
776
+ const useMembershipConsents = () => {
749
777
  const [data, setData] = react.useState(void 0);
750
778
  const [isLoading, setIsLoading] = react.useState(true);
751
779
  const [error, setError] = react.useState(null);
752
- const fetchTiers = async () => {
780
+ const fetchConsents = async () => {
753
781
  try {
754
782
  setIsLoading(true);
755
783
  setError(null);
756
- const response = await axios__default.default.get("/admin/member-tiers", {
757
- params
758
- });
784
+ const response = await axios__default.default.get("/admin/membership-consents");
759
785
  setData(
760
786
  response.data
761
787
  );
762
788
  } catch (err) {
763
- setError(err instanceof Error ? err : new Error("Failed to fetch tiers"));
789
+ setError(
790
+ err instanceof Error ? err : new Error("Failed to fetch consents")
791
+ );
764
792
  } finally {
765
793
  setIsLoading(false);
766
794
  }
767
795
  };
768
796
  react.useEffect(() => {
769
- fetchTiers();
770
- }, [params.limit, params.offset, (_a = params.order) == null ? void 0 : _a.min_points]);
797
+ fetchConsents();
798
+ }, []);
771
799
  return {
772
800
  data,
773
801
  isLoading,
774
802
  error,
775
- refetch: fetchTiers
803
+ refetch: fetchConsents
776
804
  };
777
805
  };
778
- const useUpdateMembershipTier = () => {
806
+ const useUpdateMembershipConsent = () => {
779
807
  const [isPending, setIsPending] = react.useState(false);
780
808
  const [error, setError] = react.useState(null);
781
- const mutate = async (tier, { onSuccess } = {}) => {
809
+ const mutate = async (consentKey, { onSuccess } = {}) => {
782
810
  try {
783
811
  setIsPending(true);
784
812
  setError(null);
785
- const response = await axios__default.default.patch(`/admin/member-tiers/${tier.id}`, {
786
- name: tier.name,
787
- description: tier.description,
788
- privilege_description: tier.privilege_description,
789
- min_points: tier.min_points
790
- });
813
+ const response = await axios__default.default.patch(
814
+ `/admin/membership-consents/${consentKey.id}`,
815
+ {
816
+ name: consentKey.name,
817
+ description: consentKey.description
818
+ }
819
+ );
791
820
  if (onSuccess) {
792
821
  onSuccess();
793
822
  }
794
823
  return response.data;
795
824
  } catch (err) {
796
- const error2 = err instanceof Error ? err : new Error("Failed to update tier");
825
+ const error2 = err instanceof Error ? err : new Error("Failed to update consent");
797
826
  setError(error2);
798
827
  throw error2;
799
828
  } finally {
@@ -808,46 +837,34 @@ const useUpdateMembershipTier = () => {
808
837
  };
809
838
  const columnHelper = ui.createDataTableColumnHelper();
810
839
  const columns = [
811
- columnHelper.accessor("min_points", {
812
- header: "Min Points"
813
- }),
814
840
  columnHelper.accessor("name", {
815
841
  header: "Name"
816
842
  }),
817
843
  columnHelper.accessor("description", {
818
844
  header: "Description",
819
845
  maxSize: 250
820
- }),
821
- columnHelper.accessor("privilege_description", {
822
- header: "Privilege Description",
823
- maxSize: 250
824
846
  })
825
847
  ];
826
- const MembershipTierRenderer = () => {
848
+ const MembershipConsentsRenderer = () => {
827
849
  const dialog = ui.usePrompt();
828
850
  const [pagination, setPagination] = react.useState({
829
851
  pageSize: 1e3,
830
852
  pageIndex: 0
831
853
  });
832
854
  const [isDrawerOpen, setIsDrawerOpen] = react.useState(false);
833
- const [editingTier, setEditingTier] = react.useState(null);
855
+ const [editingConsent, setEditingConsent] = react.useState(null);
834
856
  const [formData, setFormData] = react.useState({
835
857
  name: "",
836
- description: "",
837
- privilege_description: "",
838
- min_points: 0
839
- });
840
- const { data, isLoading, refetch } = useMembershipTiers({
841
- limit: pagination.pageSize,
842
- offset: pagination.pageIndex * pagination.pageSize
858
+ description: ""
843
859
  });
844
- const createTier = useCreateMembershipTier();
845
- const updateTier = useUpdateMembershipTier();
846
- const deleteTier = useDeleteMembershipTier();
860
+ const { data, isLoading, refetch } = useMembershipConsents();
861
+ const createConsent = useCreateMembershipConsent();
862
+ const updateConsent = useUpdateMembershipConsent();
863
+ const deleteConsent = useDeleteMembershipConsent();
847
864
  const table = ui.useDataTable({
848
865
  columns,
849
- data: (data == null ? void 0 : data.tiers) || [],
850
- getRowId: (tier) => tier.id,
866
+ data: (data == null ? void 0 : data.consent_keys) || [],
867
+ getRowId: (consent) => consent.id,
851
868
  rowCount: (data == null ? void 0 : data.count) || 0,
852
869
  isLoading,
853
870
  pagination: {
@@ -875,29 +892,25 @@ const MembershipTierRenderer = () => {
875
892
  const handleReset = () => {
876
893
  setFormData({
877
894
  name: "",
878
- description: "",
879
- privilege_description: "",
880
- min_points: 0
895
+ description: ""
881
896
  });
882
897
  };
883
- const openDrawer = (tier) => {
884
- if (tier) {
885
- setEditingTier(tier);
898
+ const openDrawer = (consentKey) => {
899
+ if (consentKey) {
900
+ setEditingConsent(consentKey);
886
901
  setFormData({
887
- name: tier.name,
888
- description: tier.description,
889
- privilege_description: tier.privilege_description,
890
- min_points: tier.min_points
902
+ name: consentKey.name,
903
+ description: consentKey.description
891
904
  });
892
905
  } else {
893
- setEditingTier(null);
906
+ setEditingConsent(null);
894
907
  handleReset();
895
908
  }
896
909
  setIsDrawerOpen(true);
897
910
  };
898
911
  const closeDrawer = () => {
899
912
  setIsDrawerOpen(false);
900
- setEditingTier(null);
913
+ setEditingConsent(null);
901
914
  handleReset();
902
915
  refetch();
903
916
  };
@@ -908,15 +921,15 @@ const MembershipTierRenderer = () => {
908
921
  ui.toast.error("Name is required", { dismissable: true, duration: 2500 });
909
922
  return;
910
923
  }
911
- if (editingTier) {
912
- await updateTier.mutateAsync({ id: editingTier.id, ...formData });
913
- ui.toast.success("Tier updated successfully", {
924
+ if (editingConsent) {
925
+ await updateConsent.mutateAsync({ id: editingConsent.id, ...formData });
926
+ ui.toast.success("Consent updated successfully", {
914
927
  dismissable: true,
915
928
  duration: 2500
916
929
  });
917
930
  } else {
918
- await createTier.mutateAsync(formData);
919
- ui.toast.success("Tier created successfully", {
931
+ await createConsent.mutateAsync(formData);
932
+ ui.toast.success("Consent created successfully", {
920
933
  dismissable: true,
921
934
  duration: 2500
922
935
  });
@@ -924,13 +937,13 @@ const MembershipTierRenderer = () => {
924
937
  closeDrawer();
925
938
  } catch (error) {
926
939
  if (axios__default.default.isAxiosError(error)) {
927
- ui.toast.error("Error saving tier", {
940
+ ui.toast.error("Error saving consent", {
928
941
  description: (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message,
929
942
  dismissable: true,
930
943
  duration: 2500
931
944
  });
932
945
  } else {
933
- ui.toast.error("Error saving tier", {
946
+ ui.toast.error("Error saving consent", {
934
947
  dismissable: true,
935
948
  duration: 2500
936
949
  });
@@ -941,27 +954,27 @@ const MembershipTierRenderer = () => {
941
954
  var _a, _b;
942
955
  try {
943
956
  const confirmed = await dialog({
944
- title: "Delete Membership Tier",
945
- description: `Are you sure you want to delete the \`${editingTier == null ? void 0 : editingTier.name}\` tier?`
957
+ title: "Delete Membership Consent",
958
+ description: `Are you sure you want to delete the \`${editingConsent == null ? void 0 : editingConsent.name}\` consent?`
946
959
  });
947
960
  if (!confirmed) {
948
961
  return;
949
962
  }
950
- await deleteTier.mutateAsync(id);
951
- ui.toast.success("Tier deleted successfully", {
963
+ await deleteConsent.mutateAsync(id);
964
+ ui.toast.success("Consent deleted successfully", {
952
965
  dismissable: true,
953
966
  duration: 2500
954
967
  });
955
968
  closeDrawer();
956
969
  } catch (error) {
957
970
  if (axios__default.default.isAxiosError(error)) {
958
- ui.toast.error("Error deleting tier", {
971
+ ui.toast.error("Error deleting consent", {
959
972
  description: (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message,
960
973
  dismissable: true,
961
974
  duration: 2500
962
975
  });
963
976
  } else {
964
- ui.toast.error("Error deleting tier", {
977
+ ui.toast.error("Error deleting consent", {
965
978
  dismissable: true,
966
979
  duration: 2500
967
980
  });
@@ -971,66 +984,53 @@ const MembershipTierRenderer = () => {
971
984
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
972
985
  /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "flex flex-col p-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.DataTable, { instance: table, children: [
973
986
  /* @__PURE__ */ jsxRuntime.jsxs(ui.DataTable.Toolbar, { className: "flex flex-col items-start justify-between gap-2 md:flex-row md:items-center", children: [
974
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Membership Tiers" }),
975
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => openDrawer(), children: "Add Tier" })
987
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Membership Consents" }),
988
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => openDrawer(), children: "Add Consent" })
976
989
  ] }),
977
990
  /* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Table, {})
978
991
  ] }) }),
979
992
  /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer, { open: isDrawerOpen, onOpenChange: setIsDrawerOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Content, { children: [
980
- /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Title, { children: editingTier ? "Edit Tier" : "Add Tier" }) }),
981
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Body, { "aria-description": "Membership Tier Form", children: [
982
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", "aria-description": "Membership Tier Form", children: [
983
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Name" }),
984
- /* @__PURE__ */ jsxRuntime.jsx(
985
- ui.Input,
986
- {
987
- name: "name",
988
- value: formData.name,
989
- onChange: handleInputChange
990
- }
991
- ),
992
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Description" }),
993
- /* @__PURE__ */ jsxRuntime.jsx(
994
- ui.Textarea,
995
- {
996
- className: "truncate",
997
- name: "description",
998
- value: formData.description,
999
- onChange: handleTextAreaChange
1000
- }
1001
- ),
1002
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Privilege Description" }),
1003
- /* @__PURE__ */ jsxRuntime.jsx(
1004
- ui.Textarea,
1005
- {
1006
- className: "truncate",
1007
- name: "privilege_description",
1008
- value: formData.privilege_description,
1009
- onChange: handleTextAreaChange
1010
- }
1011
- ),
1012
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Points" }),
1013
- /* @__PURE__ */ jsxRuntime.jsx(
1014
- ui.Input,
1015
- {
1016
- name: "min_points",
1017
- type: "number",
1018
- value: formData.min_points,
1019
- onChange: handleInputChange
1020
- }
1021
- )
1022
- ] }),
993
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Title, { children: editingConsent ? "Edit Consent" : "Add Consent" }) }),
994
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Body, { "aria-description": "Membership Consent Form", children: [
995
+ /* @__PURE__ */ jsxRuntime.jsxs(
996
+ "div",
997
+ {
998
+ className: "space-y-4",
999
+ "aria-description": "Membership Consent Form",
1000
+ children: [
1001
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Name" }),
1002
+ /* @__PURE__ */ jsxRuntime.jsx(
1003
+ ui.Input,
1004
+ {
1005
+ name: "name",
1006
+ value: formData.name,
1007
+ onChange: handleInputChange
1008
+ }
1009
+ ),
1010
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Description" }),
1011
+ /* @__PURE__ */ jsxRuntime.jsx(
1012
+ ui.Textarea,
1013
+ {
1014
+ className: "truncate",
1015
+ name: "description",
1016
+ value: formData.description,
1017
+ onChange: handleTextAreaChange
1018
+ }
1019
+ )
1020
+ ]
1021
+ }
1022
+ ),
1023
1023
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2 mt-6", children: [
1024
1024
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: closeDrawer, children: "Cancel" }),
1025
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: handleSubmit, children: editingTier ? "Update" : "Create" })
1025
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: handleSubmit, children: editingConsent ? "Update" : "Create" })
1026
1026
  ] })
1027
1027
  ] }),
1028
- /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Footer, { className: "flex justify-start", children: editingTier && /* @__PURE__ */ jsxRuntime.jsx(
1028
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Footer, { className: "flex justify-start", children: editingConsent && /* @__PURE__ */ jsxRuntime.jsx(
1029
1029
  ui.Button,
1030
1030
  {
1031
1031
  variant: "danger",
1032
1032
  onClick: () => {
1033
- handleDelete(editingTier.id);
1033
+ handleDelete(editingConsent.id);
1034
1034
  },
1035
1035
  children: "Delete"
1036
1036
  }
@@ -1038,11 +1038,11 @@ const MembershipTierRenderer = () => {
1038
1038
  ] }) })
1039
1039
  ] });
1040
1040
  };
1041
- const MembershipTierPage = () => {
1042
- return /* @__PURE__ */ jsxRuntime.jsx(MembershipTierRenderer, {});
1041
+ const MembershipConsentPage = () => {
1042
+ return /* @__PURE__ */ jsxRuntime.jsx(MembershipConsentsRenderer, {});
1043
1043
  };
1044
1044
  const config = adminSdk.defineRouteConfig({
1045
- label: "Membership Tiers"
1045
+ label: "Membership Consents"
1046
1046
  });
1047
1047
  const widgetModule = { widgets: [
1048
1048
  {
@@ -1056,13 +1056,13 @@ const routeModule = {
1056
1056
  Component: BannerUpload,
1057
1057
  path: "/membership"
1058
1058
  },
1059
- {
1060
- Component: MembershipConsentPage,
1061
- path: "/membership/member-consents"
1062
- },
1063
1059
  {
1064
1060
  Component: MembershipTierPage,
1065
1061
  path: "/membership/membertier"
1062
+ },
1063
+ {
1064
+ Component: MembershipConsentPage,
1065
+ path: "/membership/member-consents"
1066
1066
  }
1067
1067
  ]
1068
1068
  };
@@ -1075,13 +1075,13 @@ const menuItemModule = {
1075
1075
  nested: void 0
1076
1076
  },
1077
1077
  {
1078
- label: config$1.label,
1078
+ label: config.label,
1079
1079
  icon: void 0,
1080
1080
  path: "/membership/member-consents",
1081
1081
  nested: void 0
1082
1082
  },
1083
1083
  {
1084
- label: config.label,
1084
+ label: config$1.label,
1085
1085
  icon: void 0,
1086
1086
  path: "/membership/membertier",
1087
1087
  nested: void 0