@jingx/lottery-components-react-jsx 1.0.31 → 1.0.33

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.esm.js CHANGED
@@ -59001,9 +59001,9 @@ var axios_1 = axios;
59001
59001
 
59002
59002
  var axios$1 = /*@__PURE__*/getDefaultExportFromCjs(axios_1);
59003
59003
 
59004
- const ProtestApi = "api/v1.0.0/order/protest";
59004
+ const ProtestApi = (isSystem) => isSystem ? "api/v1.0.0/protest-ticket" : "api/v1.0.0/order/protest";
59005
59005
  const RemoveReasonApi = "api/v1.0.0/order/remove-reason";
59006
- const DeleteApi = "api/v1.0.0/order/remove";
59006
+ const DeleteApi = (isSystem) => isSystem ? "api/v1.0.0/cancel-ticket" : "api/v1.0.0/order/remove";
59007
59007
  const RemarkApi = "api/v1.0.0/order/remark";
59008
59008
  const PaidApi = "api/v1.0.0/order/paid";
59009
59009
  const PayoutApi = "api/v1.0.0/order/payout";
@@ -59048,7 +59048,8 @@ function DeleteModal(_a) {
59048
59048
  Env = {},
59049
59049
  isSubmitting: externalSubmitting = false,
59050
59050
  accessToken,
59051
- isRemoveReason
59051
+ isRemoveReason,
59052
+ isSystem = false
59052
59053
  } = _b; __objRest$2(_b, [
59053
59054
  "ticket",
59054
59055
  "isOpen",
@@ -59059,7 +59060,8 @@ function DeleteModal(_a) {
59059
59060
  "Env",
59060
59061
  "isSubmitting",
59061
59062
  "accessToken",
59062
- "isRemoveReason"
59063
+ "isRemoveReason",
59064
+ "isSystem"
59063
59065
  ]);
59064
59066
  const [options, setOptions] = useState([]);
59065
59067
  const [selectedReason, setSelectedReason] = useState(null);
@@ -59072,7 +59074,7 @@ function DeleteModal(_a) {
59072
59074
  "X-DeviceType": "WEB"
59073
59075
  }, token ? { Authorization: `Bearer ${token}` } : {});
59074
59076
  useEffect(() => {
59075
- if (!ticket) return void 0;
59077
+ if (!ticket || isSystem) return void 0;
59076
59078
  setSelectedReason(null);
59077
59079
  const fetchReasons = async () => {
59078
59080
  var _a2, _b2, _c;
@@ -59101,7 +59103,7 @@ function DeleteModal(_a) {
59101
59103
  }
59102
59104
  };
59103
59105
  fetchReasons();
59104
- }, [Env.REACT_APP_API_BASE_URL, Env.REACT_APP_BASIC_TOKEN, ticket]);
59106
+ }, [Env.REACT_APP_API_BASE_URL, Env.REACT_APP_BASIC_TOKEN, isSystem, ticket]);
59105
59107
  const handleReasonChange = (option) => {
59106
59108
  setSelectedReason(option);
59107
59109
  if (typeof onChange === "function") {
@@ -59124,13 +59126,16 @@ function DeleteModal(_a) {
59124
59126
  ticketNumber: ticket == null ? void 0 : ticket.ticketNumber,
59125
59127
  message: (_a2 = selectedReason == null ? void 0 : selectedReason.value) != null ? _a2 : ""
59126
59128
  };
59127
- const res = await axios$1.delete(
59128
- `${Env.REACT_APP_API_BASE_URL || DEFAULT_API_BASE_URL$3}${DeleteApi}`,
59129
- {
59130
- headers,
59131
- data: payload
59132
- }
59133
- );
59129
+ const payloadSystem = {
59130
+ lotteryType: ticket == null ? void 0 : ticket.lotteryType,
59131
+ id: ticket == null ? void 0 : ticket.ticketNumber,
59132
+ drawCode: ticket == null ? void 0 : ticket.drawCode
59133
+ };
59134
+ const url = `${Env.REACT_APP_API_BASE_URL || DEFAULT_API_BASE_URL$3}${DeleteApi(isSystem)}`;
59135
+ const res = isSystem ? await axios$1.post(url, payloadSystem, { headers }) : await axios$1.delete(url, {
59136
+ headers,
59137
+ data: payload
59138
+ });
59134
59139
  if (typeof onSuccess === "function") {
59135
59140
  onSuccess(res.data, payload);
59136
59141
  }
@@ -59153,7 +59158,6 @@ function DeleteModal(_a) {
59153
59158
  }
59154
59159
  };
59155
59160
  if (!ticket) return null;
59156
- console.log(ticket, "ticket");
59157
59161
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ScopeHost, { children: (container) => {
59158
59162
  var _a2, _b2;
59159
59163
  return container && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -59345,11 +59349,13 @@ const ProtestModal = ({
59345
59349
  Env = {},
59346
59350
  accessToken,
59347
59351
  onChange,
59352
+ isSystem,
59348
59353
  isSubmitting: externalSubmitting = false
59349
59354
  }) => {
59350
59355
  const [selectedTransferIds, setSelectedTransferIds] = useState([]);
59351
59356
  const [options, setOptions] = useState([]);
59352
59357
  const [selectedReason, setSelectedReason] = useState(null);
59358
+ const [systemReason, setSystemReason] = useState("");
59353
59359
  const [isLoading, setIsLoading] = useState(false);
59354
59360
  const [isSubmitting, setIsSubmitting] = useState(false);
59355
59361
  const activeLotteryType = lotteryType || (ticket == null ? void 0 : ticket.lotteryType);
@@ -59360,9 +59366,10 @@ const ProtestModal = ({
59360
59366
  "X-DeviceType": "WEB"
59361
59367
  }, token ? { Authorization: `Bearer ${token}` } : {});
59362
59368
  useEffect(() => {
59363
- if (!ticket) return void 0;
59364
59369
  setSelectedTransferIds([]);
59365
59370
  setSelectedReason(null);
59371
+ setSystemReason("");
59372
+ if (!ticket || isSystem) return void 0;
59366
59373
  const fetchReasons = async () => {
59367
59374
  var _a, _b, _c;
59368
59375
  try {
@@ -59391,7 +59398,7 @@ const ProtestModal = ({
59391
59398
  }
59392
59399
  };
59393
59400
  fetchReasons();
59394
- }, [Env.REACT_APP_API_BASE_URL, ticket]);
59401
+ }, [Env.REACT_APP_API_BASE_URL, isSystem, ticket]);
59395
59402
  const handleSelectedIdsChange = useCallback((ids) => {
59396
59403
  setSelectedTransferIds(ids);
59397
59404
  }, []);
@@ -59401,9 +59408,24 @@ const ProtestModal = ({
59401
59408
  onChange(option);
59402
59409
  }
59403
59410
  };
59411
+ const handleSystemReasonChange = (event) => {
59412
+ const value = event.target.value;
59413
+ setSystemReason(value);
59414
+ if (typeof onChange === "function") {
59415
+ onChange(value);
59416
+ }
59417
+ };
59404
59418
  const handleSubmit = useCallback(async () => {
59405
- var _a, _b, _c;
59406
- if (!selectedReason) {
59419
+ var _a, _b, _c, _d;
59420
+ if (isSystem && !systemReason.trim()) {
59421
+ const message = "\u179F\u17BC\u1798\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17BC\u179B\u17A0\u17C1\u178F\u17BB\u178F\u179C\u17C9\u17B6";
59422
+ PNotify_1.alert({
59423
+ text: message,
59424
+ type: "error"
59425
+ });
59426
+ return;
59427
+ }
59428
+ if (!isSystem && !selectedReason) {
59407
59429
  const message = "\u179F\u17BC\u1798\u1787\u17D2\u179A\u17BE\u179F\u179A\u17BE\u179F\u1798\u17BC\u179B\u17A0\u17C1\u178F\u17BB\u178F\u179C\u17C9\u17B6";
59408
59430
  PNotify_1.alert({
59409
59431
  text: message,
@@ -59425,23 +59447,29 @@ const ProtestModal = ({
59425
59447
  lotteryType: activeLotteryType,
59426
59448
  ticketNumber: ticket == null ? void 0 : ticket.ticketNumber,
59427
59449
  orderItemsIds: selectedTransferIds,
59428
- message: selectedReason.value
59450
+ message: (_a = selectedReason == null ? void 0 : selectedReason.value) != null ? _a : ""
59429
59451
  };
59452
+ const payloadSystem = {
59453
+ lotteryType: activeLotteryType,
59454
+ orderItemsIds: selectedTransferIds,
59455
+ reason: systemReason.trim()
59456
+ };
59457
+ const requestPayload = isSystem ? payloadSystem : payload;
59430
59458
  const res = await axios$1.post(
59431
- `${Env.REACT_APP_API_BASE_URL || DEFAULT_API_BASE_URL$2}${ProtestApi}`,
59432
- payload,
59459
+ `${Env.REACT_APP_API_BASE_URL || DEFAULT_API_BASE_URL$2}${ProtestApi(isSystem)}`,
59460
+ requestPayload,
59433
59461
  { headers }
59434
59462
  );
59435
59463
  if (typeof onSuccessProtest === "function") {
59436
- onSuccessProtest(res.data, payload);
59464
+ onSuccessProtest(res.data, requestPayload);
59437
59465
  }
59438
59466
  PNotify_1.alert({
59439
- text: ((_a = res.data) == null ? void 0 : _a.message) || "\u1780\u17B6\u179A\u178F\u179C\u17C9\u17B6\u1787\u17C4\u1782\u1787\u17D0\u1799 !",
59467
+ text: ((_b = res.data) == null ? void 0 : _b.message) || "\u1780\u17B6\u179A\u178F\u179C\u17C9\u17B6\u1787\u17C4\u1782\u1787\u17D0\u1799 !",
59440
59468
  type: "success"
59441
59469
  });
59442
59470
  onClose == null ? void 0 : onClose();
59443
59471
  } catch (err) {
59444
- const message = ((_c = (_b = err.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message) || err.message || "\u1780\u17B6\u179A\u178F\u179C\u17C9\u17B6\u1794\u179A\u17B6\u1787\u17D0\u1799 !";
59472
+ const message = ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.message) || err.message || "\u1780\u17B6\u179A\u178F\u179C\u17C9\u17B6\u1794\u179A\u17B6\u1787\u17D0\u1799 !";
59445
59473
  PNotify_1.alert({
59446
59474
  text: message,
59447
59475
  type: "error"
@@ -59452,7 +59480,7 @@ const ProtestModal = ({
59452
59480
  } finally {
59453
59481
  setIsSubmitting(false);
59454
59482
  }
59455
- }, [Env.REACT_APP_API_BASE_URL, activeLotteryType, ticket, headers, onClose, onError, onSuccessProtest, selectedReason, selectedTransferIds]);
59483
+ }, [Env.REACT_APP_API_BASE_URL, activeLotteryType, headers, isSystem, onClose, onError, onSuccessProtest, selectedReason, selectedTransferIds, systemReason, ticket]);
59456
59484
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ScopeHost, { children: (container) => container && /* @__PURE__ */ jsxRuntimeExports.jsxs(
59457
59485
  Modal,
59458
59486
  {
@@ -59467,7 +59495,17 @@ const ProtestModal = ({
59467
59495
  /* @__PURE__ */ jsxRuntimeExports.jsxs(ModalBody, { children: [
59468
59496
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-3", children: [
59469
59497
  /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "f-bold custom-label", children: "Protest Reason" }),
59470
- /* @__PURE__ */ jsxRuntimeExports.jsx(
59498
+ isSystem ? /* @__PURE__ */ jsxRuntimeExports.jsx(
59499
+ "textarea",
59500
+ {
59501
+ className: "form-control",
59502
+ rows: "2",
59503
+ value: systemReason,
59504
+ disabled: isSubmitting || externalSubmitting,
59505
+ onChange: handleSystemReasonChange,
59506
+ placeholder: "\u1798\u17BC\u179B\u17A0\u17C1\u178F\u17BB \u178F\u179C\u17C9\u17B6..."
59507
+ }
59508
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
59471
59509
  StateManagedSelect$1,
59472
59510
  {
59473
59511
  options,
@@ -59665,7 +59703,7 @@ function RemarkModal(_a) {
59665
59703
  ticketNumber: object == null ? void 0 : object.ticketNumber,
59666
59704
  message: remark
59667
59705
  };
59668
- const res = await axios$1.delete(
59706
+ const res = await axios$1.post(
59669
59707
  `${Env.REACT_APP_API_BASE_URL || DEFAULT_API_BASE_URL$1}${RemarkApi}`,
59670
59708
  {
59671
59709
  headers,
@@ -59798,7 +59836,8 @@ function MoreMenu(_a) {
59798
59836
  accessToken,
59799
59837
  openCallback,
59800
59838
  closeCallback,
59801
- DropdownButton
59839
+ DropdownButton,
59840
+ isSystem
59802
59841
  } = _b, props = __objRest(_b, [
59803
59842
  "id",
59804
59843
  "object",
@@ -59815,7 +59854,8 @@ function MoreMenu(_a) {
59815
59854
  "accessToken",
59816
59855
  "openCallback",
59817
59856
  "closeCallback",
59818
- "DropdownButton"
59857
+ "DropdownButton",
59858
+ "isSystem"
59819
59859
  ]);
59820
59860
  var _a2, _b2;
59821
59861
  const [activeModal, setActiveModal] = useState(null);
@@ -59823,7 +59863,7 @@ function MoreMenu(_a) {
59823
59863
  const [isPayout, setIsPayout] = useState(Boolean(ticket == null ? void 0 : ticket.isPayout));
59824
59864
  const [isLoadingPaid, setLoadingPaid] = useState(false);
59825
59865
  const [isLoadingPayout, setLoadingPayout] = useState(false);
59826
- const isShowPayout = ((_a2 = ticket == null ? void 0 : ticket.totalKhr) == null ? void 0 : _a2.winAmount) > 0 || ((_b2 = ticket == null ? void 0 : ticket.totalUsd) == null ? void 0 : _b2.winAmount) > 0;
59866
+ const isShowPayout = !isSystem && (((_a2 = ticket == null ? void 0 : ticket.totalKhr) == null ? void 0 : _a2.winAmount) > 0 || ((_b2 = ticket == null ? void 0 : ticket.totalUsd) == null ? void 0 : _b2.winAmount) > 0);
59827
59867
  useEffect(() => {
59828
59868
  setIsPaid(Boolean(ticket == null ? void 0 : ticket.isPaid));
59829
59869
  setIsPayout(Boolean(ticket == null ? void 0 : ticket.isPayout));
@@ -59970,7 +60010,7 @@ function MoreMenu(_a) {
59970
60010
  ]
59971
60011
  }
59972
60012
  ),
59973
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
60013
+ !isSystem && /* @__PURE__ */ jsxRuntimeExports.jsxs(
59974
60014
  DropdownItem,
59975
60015
  {
59976
60016
  type: "button",
@@ -59982,7 +60022,7 @@ function MoreMenu(_a) {
59982
60022
  ]
59983
60023
  }
59984
60024
  ),
59985
- /* @__PURE__ */ jsxRuntimeExports.jsx(
60025
+ !isSystem && /* @__PURE__ */ jsxRuntimeExports.jsx(
59986
60026
  DropdownItem,
59987
60027
  {
59988
60028
  tag: "div",
@@ -60034,7 +60074,8 @@ function MoreMenu(_a) {
60034
60074
  onChange,
60035
60075
  onSuccessProtest: onSuccessProtest != null ? onSuccessProtest : onSuccess,
60036
60076
  onError,
60037
- isSubmitting: externalSubmitting
60077
+ isSubmitting: externalSubmitting,
60078
+ isSystem
60038
60079
  }
60039
60080
  ),
60040
60081
  object && activeModal === "remark" && /* @__PURE__ */ jsxRuntimeExports.jsx(