@orderly.network/trading-points 1.0.1-alpha.0

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/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # Trading Points Module
2
+
3
+ This module provides a complete points system implementation for trading campaigns, including points tracking, leaderboards, referral links, and stage management.
4
+
5
+ ## Features
6
+
7
+ - 📊 **Points Dashboard**: Display user's trading points, PnL points, and referral points
8
+ - 🏆 **Leaderboard**: Show rankings with support for different time ranges (this week, last week, all time)
9
+ - 🎯 **Campaign Stages**: Support multiple campaign stages with different statuses (active, pending, completed)
10
+ - 🔗 **Referral System**: Generate and share referral links and codes
11
+ - ⏱️ **Countdown Timer**: Display countdown for pending campaigns
12
+
13
+ ## Basic Usage
14
+
15
+ ### Simple Integration
16
+
17
+ ```tsx
18
+ import { PointSystemPage } from "@orderly.network/trading-points";
19
+
20
+ function MyApp() {
21
+ const handleRouteChange = (option) => {
22
+ // Handle navigation
23
+ console.log("Navigate to:", option.href);
24
+ };
25
+
26
+ return <PointSystemPage onRouteChange={handleRouteChange} />;
27
+ }
28
+ ```
29
+
30
+ ## Advanced Usage
31
+
32
+ ### Using the Points Hook
33
+
34
+ The `usePoints` hook provides access to all points-related data and methods:
35
+
36
+ ```tsx
37
+ import { usePoints } from "@orderly.network/trading-points";
38
+
39
+ function CustomPointsComponent() {
40
+ const {
41
+ stages, // All campaign stages
42
+ userStatistics, // User's points statistics
43
+ currentStage, // Currently selected stage
44
+ setCurrentStage, // Function to change stage
45
+ isLoading, // Loading state
46
+ isNoCampaign, // Whether there's no active campaign
47
+ refLink, // Referral link
48
+ refCode, // Referral code
49
+ selectedTimeRange, // Current time range filter
50
+ setSelectedTimeRange, // Function to change time range
51
+ pointsDisplay, // Formatted points display data
52
+ allTimePointsDisplay, // All-time points display data
53
+ isCurrentStagePending, // Whether current stage is pending
54
+ isCurrentStageCompleted, // Whether current stage is completed
55
+ getRankingUrl, // Function to get ranking API URL
56
+ } = usePoints();
57
+
58
+ return (
59
+ <div>
60
+ <h2>Total Points: {pointsDisplay.currentPointsDisplay}</h2>
61
+ <p>Trading Points: {pointsDisplay.tradingPointsDisplay}</p>
62
+ <p>PnL Points: {pointsDisplay.pnlPointsDisplay}</p>
63
+ <p>Referral Points: {pointsDisplay.referralPointsDisplay}</p>
64
+ <p>Rank: {pointsDisplay.rankingDisplay}</p>
65
+ </div>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ## Components Overview
71
+
72
+ ### Main Components
73
+
74
+ - **PointSystemPage**: The main entry point component
75
+ - **Countdown**: Displays countdown timer for pending campaigns
76
+ - **Intro**: Shows campaign introduction and stage selection
77
+ - **User**: Displays user's points, stats, and referral information
78
+ - **GeneralLeaderboardWidget**: Shows the leaderboard/rankings
79
+
80
+ ### Internal Structure
81
+
82
+ ```
83
+ pages/points/
84
+ ├── page.tsx # Main page component
85
+ ├── main.tsx # Layout and composition
86
+ ├── countdown.tsx # Countdown timer
87
+ ├── intro.tsx # Campaign intro
88
+ ├── user.tsx # User stats
89
+ └── faq.tsx # FAQ section
90
+
91
+ components/
92
+ ├── leaderboard/ # Leaderboard components
93
+ └── ranking/ # Ranking components
94
+
95
+ hooks/
96
+ └── usePointsData/ # Points data management
97
+ ```
@@ -0,0 +1,14 @@
1
+ import { FC } from 'react';
2
+
3
+ type RouteOption = {
4
+ href: string;
5
+ name: string;
6
+ scope?: string;
7
+ target?: string;
8
+ };
9
+ type PointSystemPageProps = {
10
+ onRouteChange: (option: RouteOption) => void;
11
+ };
12
+ declare const PointSystemPage: FC<PointSystemPageProps>;
13
+
14
+ export { PointSystemPage, type PointSystemPageProps, type RouteOption };
@@ -0,0 +1,14 @@
1
+ import { FC } from 'react';
2
+
3
+ type RouteOption = {
4
+ href: string;
5
+ name: string;
6
+ scope?: string;
7
+ target?: string;
8
+ };
9
+ type PointSystemPageProps = {
10
+ onRouteChange: (option: RouteOption) => void;
11
+ };
12
+ declare const PointSystemPage: FC<PointSystemPageProps>;
13
+
14
+ export { PointSystemPage, type PointSystemPageProps, type RouteOption };