kaafil-react-uikit 0.11.6 → 0.11.8

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.
@@ -1,9 +1,9 @@
1
1
  import { useManagerMe, useConflicts, useNotifications } from '../chunk-U6IE2UYL.js';
2
- import { FORM_FIELD_KIND_SINGLE_BOOLEAN, useChecklists, useManagers, useCloseout, useFiles, useFloat, useForms, useParties, useItinerary, useVendors, useExpenses, useCollections, useManagerToday, usePickups, useRooming, useTravellerProfile, useSeating } from '../chunk-63JQKLMH.js';
2
+ import { FORM_FIELD_KIND_SINGLE_BOOLEAN, useChecklists, useManagers, useCloseout, useFiles, useFloat, useForms, useParties, useItinerary, useVendors, useExpenses, useCollections, useManagerToday, usePickups, useRooming, useTravellerProfile, useSeating } from '../chunk-XGPX7TYV.js';
3
3
  import { useOfflineEngine } from '../chunk-RCWSMWQD.js';
4
4
  import { OfflineFallbackScreen } from '../chunk-LOLQNRIK.js';
5
5
  export { BootErrorScreen, LockedTripScreen, NotFoundScreen, OfflineFallbackScreen, SessionExpiredScreen } from '../chunk-LOLQNRIK.js';
6
- import { createRegistry, useKaafilChrome, useSession, tokenStyle, useOutboxStatus, useKaafilBrand } from '../chunk-YJJ4DI42.js';
6
+ import { createRegistry, useKaafilChrome, useSession, tokenStyle, useOutboxStatus, useOfflineEvent, useKaafilBrand } from '../chunk-YJJ4DI42.js';
7
7
  import { useState, useRef, useEffect, useMemo, useId } from 'react';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
 
@@ -6042,7 +6042,37 @@ function ReadyManagerMoneySection({
6042
6042
  issuedMinor: floatRow.issuedMinor,
6043
6043
  currency: floatRow.currency
6044
6044
  } : void 0,
6045
- spend: expensesReady !== void 0 ? { amountMinor: sumSpendMinor(active), currency } : void 0,
6045
+ spend: (
6046
+ /*
6047
+ * THE SERVER'S OWN ROLLUP FIRST, the local sum only as a fallback.
6048
+ *
6049
+ * This summed `active` — the snapshot-backed rows — and nothing
6050
+ * else. `useExpenses` deliberately enqueues its writes WITHOUT an
6051
+ * optimistic row (its own DECISION comment: a fabricated
6052
+ * `ExpenseResponse` would have to guess `floatMovementId`,
6053
+ * `receiptRequired` and the negative-float guard, none of which a
6054
+ * client can compute). That decision is right, and its consequence
6055
+ * is that a freshly logged expense is absent from `expenses[]` until
6056
+ * a pull brings it down — so this tile read ₹0 with the money
6057
+ * already spent, on the one screen a manager checks it on.
6058
+ *
6059
+ * `totals.spendTotalMinor` is the server's own spend rollup and the
6060
+ * hook already re-reads it on every `sync.drained`, so it reflects
6061
+ * the write as soon as the queue reaches the server. Using it here
6062
+ * is also simply more correct than summing whichever rows this
6063
+ * device happens to hold.
6064
+ *
6065
+ * The local sum stays as the fallback rather than the primary. Its
6066
+ * own doc says `spendTotalMinor` is `undefined` until a read lands
6067
+ * and must never be drawn as zero — offline, where that read cannot
6068
+ * happen, a sum of the rows actually held is the honest answer, and
6069
+ * it is what offline-first means here.
6070
+ */
6071
+ expensesReady !== void 0 ? {
6072
+ amountMinor: expensesReady.totals.spendTotalMinor ?? sumSpendMinor(active),
6073
+ currency
6074
+ } : void 0
6075
+ ),
6046
6076
  collect: collectionsReady !== void 0 ? {
6047
6077
  amountMinor: balancesDueRows.reduce((sum, row) => sum + row.outstandingMinor, 0),
6048
6078
  travellerCount: balancesDueRows.length,
@@ -8003,7 +8033,6 @@ function ReadyManagerPickupsSection({
8003
8033
  style
8004
8034
  }) {
8005
8035
  const pickups = usePickups(tripRef);
8006
- const outbox = useOutboxStatus();
8007
8036
  const StopListUI = components?.StopList ?? StopList;
8008
8037
  const BoardingViewUI = components?.BoardingView ?? BoardingView;
8009
8038
  const [kind, setKind] = useState("PICKUP");
@@ -8027,27 +8056,13 @@ function ReadyManagerPickupsSection({
8027
8056
  cancelled = true;
8028
8057
  };
8029
8058
  }, [ready, selectedStopId, kind]);
8030
- const drainedFrom = useRef(outbox.pending);
8031
- useEffect(() => {
8032
- const hadWork = drainedFrom.current > 0;
8033
- drainedFrom.current = outbox.pending;
8034
- if (!hadWork || outbox.pending > 0) {
8035
- return;
8036
- }
8059
+ useOfflineEvent("sync.drained", () => {
8037
8060
  if (pickups.status !== "ready" || selectedStopId === void 0) {
8038
8061
  return;
8039
8062
  }
8040
- let cancelled = false;
8041
- void pickups.manifestByPickup({ kind }).then((result) => {
8042
- if (!cancelled) {
8043
- setManifest(result);
8044
- }
8045
- });
8063
+ void pickups.manifestByPickup({ kind }).then(setManifest);
8046
8064
  void pickups.refreshLive();
8047
- return () => {
8048
- cancelled = true;
8049
- };
8050
- }, [outbox.pending, selectedStopId, kind]);
8065
+ });
8051
8066
  if (pickups.status === "loading") {
8052
8067
  return /* @__PURE__ */ jsxs("div", { className: "kf-manager-pickups__skeleton", style: tokenStyle(style), children: [
8053
8068
  /* @__PURE__ */ jsx("div", { className: "kf-manager-pickups__skeleton-line" }),