@dubsdotapp/expo 0.5.17 → 0.5.18
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.d.mts +2081 -0
- package/dist/index.d.ts +2081 -0
- package/dist/index.js +1916 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1868 -102
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/src/chat/hooks.ts +320 -0
- package/src/chat/index.ts +40 -0
- package/src/chat/provider.tsx +213 -0
- package/src/chat/socket.ts +175 -0
- package/src/chat/types.ts +146 -0
- package/src/client.ts +182 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useEnterJackpot.ts +80 -0
- package/src/hooks/useJackpot.ts +37 -0
- package/src/hooks/useJackpotHistory.ts +34 -0
- package/src/index.ts +55 -0
- package/src/types.ts +60 -0
- package/src/ui/game/JoinGameSheet.tsx +1 -1
- package/src/ui/index.ts +4 -0
- package/src/ui/jackpot/JackpotCard.tsx +417 -0
- package/src/ui/jackpot/JackpotSheet.tsx +683 -0
- package/src/ui/jackpot/JackpotWidget.tsx +74 -0
- package/src/ui/jackpot/index.ts +6 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { JackpotCard } from './JackpotCard';
|
|
3
|
+
import { JackpotSheet } from './JackpotSheet';
|
|
4
|
+
import { useJackpot } from '../../hooks/useJackpot';
|
|
5
|
+
import { useDubs } from '../../provider';
|
|
6
|
+
import type { EnterJackpotMutationResult } from '../../hooks/useEnterJackpot';
|
|
7
|
+
import type { JackpotEntry } from '../../types';
|
|
8
|
+
import type { ViewStyle } from 'react-native';
|
|
9
|
+
|
|
10
|
+
export interface JackpotWidgetProps {
|
|
11
|
+
/** Style applied to the card */
|
|
12
|
+
style?: ViewStyle;
|
|
13
|
+
/** Minimum entry in SOL (default: 0.01) */
|
|
14
|
+
minEntry?: number;
|
|
15
|
+
/** Maximum entry in SOL (default: 10) */
|
|
16
|
+
maxEntry?: number;
|
|
17
|
+
/** Callback when a jackpot entry succeeds */
|
|
18
|
+
onEntry?: (result: EnterJackpotMutationResult) => void;
|
|
19
|
+
/** Callback on entry error */
|
|
20
|
+
onError?: (error: Error) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Self-contained Jackpot widget — the first "crypto ad".
|
|
25
|
+
*
|
|
26
|
+
* Drop `<JackpotWidget />` anywhere in your app. Shows a live jackpot card
|
|
27
|
+
* matching the web lobby design with pot amount, player carousel, and
|
|
28
|
+
* Place Bet button. Tapping opens a scrollable sheet with full entry flow.
|
|
29
|
+
*/
|
|
30
|
+
export function JackpotWidget({
|
|
31
|
+
style,
|
|
32
|
+
minEntry,
|
|
33
|
+
maxEntry,
|
|
34
|
+
onEntry,
|
|
35
|
+
onError,
|
|
36
|
+
}: JackpotWidgetProps) {
|
|
37
|
+
const [sheetVisible, setSheetVisible] = useState(false);
|
|
38
|
+
const { round, lastWinner } = useJackpot();
|
|
39
|
+
const { client } = useDubs();
|
|
40
|
+
const [entries, setEntries] = useState<JackpotEntry[]>([]);
|
|
41
|
+
|
|
42
|
+
// Fetch entries for the card carousel
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
client.getJackpotEntries()
|
|
45
|
+
.then(res => setEntries(res.entries))
|
|
46
|
+
.catch(() => {});
|
|
47
|
+
}, [client, round?.entryCount]);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
<JackpotCard
|
|
52
|
+
round={round}
|
|
53
|
+
lastWinner={lastWinner}
|
|
54
|
+
entries={entries}
|
|
55
|
+
onPress={() => setSheetVisible(true)}
|
|
56
|
+
style={style}
|
|
57
|
+
/>
|
|
58
|
+
<JackpotSheet
|
|
59
|
+
visible={sheetVisible}
|
|
60
|
+
onDismiss={() => setSheetVisible(false)}
|
|
61
|
+
onSuccess={(result) => {
|
|
62
|
+
onEntry?.(result);
|
|
63
|
+
// Refresh entries after entry
|
|
64
|
+
client.getJackpotEntries()
|
|
65
|
+
.then(res => setEntries(res.entries))
|
|
66
|
+
.catch(() => {});
|
|
67
|
+
}}
|
|
68
|
+
onError={onError}
|
|
69
|
+
minEntry={minEntry}
|
|
70
|
+
maxEntry={maxEntry}
|
|
71
|
+
/>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { JackpotCard } from './JackpotCard';
|
|
2
|
+
export type { JackpotCardProps } from './JackpotCard';
|
|
3
|
+
export { JackpotSheet } from './JackpotSheet';
|
|
4
|
+
export type { JackpotSheetProps } from './JackpotSheet';
|
|
5
|
+
export { JackpotWidget } from './JackpotWidget';
|
|
6
|
+
export type { JackpotWidgetProps } from './JackpotWidget';
|