@mohasinac/appkit 2.7.20 → 2.7.22
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.
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { useRouter } from "next/navigation";
|
|
5
|
-
import { Button, Stack, Text, useToast } from "../../../ui";
|
|
5
|
+
import { Button, Stack, Text, useToast, LoginRequiredModal } from "../../../ui";
|
|
6
6
|
import { ROUTES } from "../../../next";
|
|
7
7
|
import { formatCurrency } from "../../../utils/number.formatter";
|
|
8
8
|
import { useGuestCart } from "../../cart/hooks/useGuestCart";
|
|
9
9
|
import { pushCartOp } from "../../cart/utils/pending-ops";
|
|
10
10
|
import { NonRefundableConsentModal } from "./NonRefundableConsentModal";
|
|
11
|
+
import { useAuthGate } from "../../../react/hooks/useAuthGate";
|
|
12
|
+
import { ACTION_ID } from "../constants/action-defs";
|
|
11
13
|
/**
|
|
12
14
|
* Client buy panel for a prize-draw detail page (SB4-G).
|
|
13
15
|
*
|
|
@@ -19,13 +21,14 @@ export function PrizeDrawEntryActions({ productId, productSlug, title, thumb, pr
|
|
|
19
21
|
const router = useRouter();
|
|
20
22
|
const cart = useGuestCart();
|
|
21
23
|
const { showToast } = useToast();
|
|
24
|
+
const { requireAuth, modalOpen, modalMessage, closeModal } = useAuthGate();
|
|
22
25
|
const [consentOpen, setConsentOpen] = useState(false);
|
|
23
26
|
const closed = revealStatus === "closed" || remainingEntries === 0;
|
|
24
27
|
const handleEnter = useCallback(() => {
|
|
25
28
|
if (closed)
|
|
26
29
|
return;
|
|
27
|
-
setConsentOpen(true);
|
|
28
|
-
}, [closed]);
|
|
30
|
+
requireAuth(ACTION_ID.ENTER_PRIZE_DRAW, () => setConsentOpen(true));
|
|
31
|
+
}, [closed, requireAuth]);
|
|
29
32
|
const handleConfirm = useCallback(() => {
|
|
30
33
|
cart.add(productId, 1, {
|
|
31
34
|
productTitle: title,
|
|
@@ -44,5 +47,5 @@ export function PrizeDrawEntryActions({ productId, productSlug, title, thumb, pr
|
|
|
44
47
|
showToast("Entry added to cart", "success");
|
|
45
48
|
router.push(String(ROUTES.USER.CART));
|
|
46
49
|
}, [cart, productId, title, thumb, pricePerEntry, router, showToast]);
|
|
47
|
-
return (_jsxs(Stack, { gap: "md", children: [_jsxs(Text, { className: "text-2xl font-bold text-zinc-900 dark:text-zinc-50", children: [formatCurrency(pricePerEntry, currency), _jsx(Text, { as: "span", className: "ml-1 text-xs font-normal text-[var(--appkit-color-text-muted)]", children: "per entry" })] }), _jsx(Button, { variant: "primary", size: "md", className: "w-full", disabled: closed, onClick: handleEnter, children: closed ? "Draw closed" : "Enter draw" }), prizeGithubFileUrl ? (_jsx("a", { href: prizeGithubFileUrl, target: "_blank", rel: "noopener noreferrer", className: "text-center text-xs font-medium text-primary-600 underline-offset-4 hover:underline dark:text-primary-400", children: "View RNG source code on GitHub \u2192" })) : null, _jsx(Text, { className: "text-center text-xs text-[var(--appkit-color-text-muted)]", children: "Winners chosen by Node.js crypto.randomInt \u2014 fully auditable. Entries are locked once paid; refunds only if the prize pool is exhausted." }), _jsx(NonRefundableConsentModal, { open: consentOpen, listingType: "prize-draw", itemTitle: title, priceLabel: formatCurrency(pricePerEntry, currency), onCancel: () => setConsentOpen(false), onConfirm: handleConfirm })] }));
|
|
50
|
+
return (_jsxs(Stack, { gap: "md", children: [_jsxs(Text, { className: "text-2xl font-bold text-zinc-900 dark:text-zinc-50", children: [formatCurrency(pricePerEntry, currency), _jsx(Text, { as: "span", className: "ml-1 text-xs font-normal text-[var(--appkit-color-text-muted)]", children: "per entry" })] }), _jsx(Button, { variant: "primary", size: "md", className: "w-full", disabled: closed, onClick: handleEnter, children: closed ? "Draw closed" : "Enter draw" }), prizeGithubFileUrl ? (_jsx("a", { href: prizeGithubFileUrl, target: "_blank", rel: "noopener noreferrer", className: "text-center text-xs font-medium text-primary-600 underline-offset-4 hover:underline dark:text-primary-400", children: "View RNG source code on GitHub \u2192" })) : null, _jsx(Text, { className: "text-center text-xs text-[var(--appkit-color-text-muted)]", children: "Winners chosen by Node.js crypto.randomInt \u2014 fully auditable. Entries are locked once paid; refunds only if the prize pool is exhausted." }), _jsx(NonRefundableConsentModal, { open: consentOpen, listingType: "prize-draw", itemTitle: title, priceLabel: formatCurrency(pricePerEntry, currency), onCancel: () => setConsentOpen(false), onConfirm: handleConfirm }), _jsx(LoginRequiredModal, { isOpen: modalOpen, onClose: closeModal, message: modalMessage })] }));
|
|
48
51
|
}
|
|
@@ -12,6 +12,7 @@ import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
|
12
12
|
import { TABLE_KEYS, VIEW_MODE } from "../../../constants/table-keys";
|
|
13
13
|
import { sortBy } from "../../../constants/sort";
|
|
14
14
|
import { STORE_FIELDS } from "../../../constants/field-names";
|
|
15
|
+
import { ACTION_ID } from "../../products/constants/action-defs";
|
|
15
16
|
const DEFAULT_SORT = sortBy(STORE_FIELDS.CREATED_AT);
|
|
16
17
|
const STORE_SORT_OPTIONS = [
|
|
17
18
|
{ value: sortBy(STORE_FIELDS.CREATED_AT), label: "Newest First" },
|
|
@@ -115,7 +116,7 @@ export function StoresIndexListing({ initialData }) {
|
|
|
115
116
|
const selection = useBulkSelection({ items: stores, keyExtractor: (s) => s.id ?? s.storeSlug });
|
|
116
117
|
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search stores...", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT, sortOptions: STORE_SORT_OPTIONS, onSortChange: (v) => { table.set(TABLE_KEYS.SORT, v); }, view: view, onViewChange: handleViewToggle, onResetAll: resetAll, hasActiveState: hasActiveState, bulkMode: selection.isSelecting, bulkSelectedCount: selection.selectedCount, bulkTotalCount: stores.length, onBulkSelectAll: selection.toggleAll, onBulkClear: selection.clearSelection }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
|
|
117
118
|
{
|
|
118
|
-
id:
|
|
119
|
+
id: ACTION_ID.COMPARE,
|
|
119
120
|
label: "Compare",
|
|
120
121
|
variant: "secondary",
|
|
121
122
|
onClick: () => { selection.clearSelection(); },
|