@getjack/jack 0.1.32 → 0.1.34
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/package.json +1 -1
- package/src/commands/deploys.ts +95 -0
- package/src/commands/link.ts +8 -0
- package/src/commands/mcp.ts +179 -4
- package/src/commands/rollback.ts +53 -0
- package/src/commands/secrets.ts +3 -1
- package/src/commands/services.ts +11 -1
- package/src/commands/ship.ts +3 -1
- package/src/commands/tokens.ts +16 -1
- package/src/commands/whoami.ts +43 -8
- package/src/index.ts +16 -0
- package/src/lib/agent-files.ts +54 -4
- package/src/lib/agent-integration.ts +4 -166
- package/src/lib/claude-hooks-installer.ts +55 -0
- package/src/lib/control-plane.ts +78 -40
- package/src/lib/crypto.ts +84 -0
- package/src/lib/debug.ts +2 -1
- package/src/lib/deploy-upload.ts +13 -3
- package/src/lib/hooks.ts +4 -3
- package/src/lib/managed-deploy.ts +12 -9
- package/src/lib/project-link.ts +6 -0
- package/src/lib/project-operations.ts +92 -30
- package/src/lib/prompts.ts +2 -2
- package/src/lib/telemetry.ts +2 -0
- package/src/mcp/README.md +1 -1
- package/src/mcp/resources/index.ts +1 -16
- package/src/mcp/server.ts +23 -0
- package/src/mcp/tools/index.ts +133 -17
- package/src/mcp/types.ts +1 -0
- package/src/mcp/utils.ts +2 -1
- package/src/templates/index.ts +25 -73
- package/templates/CLAUDE.md +62 -0
- package/templates/ai-chat/.jack.json +10 -5
- package/templates/ai-chat/bun.lock +50 -1
- package/templates/ai-chat/package.json +5 -0
- package/templates/ai-chat/public/app.js +73 -0
- package/templates/ai-chat/public/index.html +14 -197
- package/templates/ai-chat/schema.sql +14 -0
- package/templates/ai-chat/src/index.ts +86 -102
- package/templates/ai-chat/wrangler.jsonc +8 -1
- package/templates/cron/.jack.json +66 -0
- package/templates/cron/bun.lock +23 -0
- package/templates/cron/package.json +16 -0
- package/templates/cron/schema.sql +24 -0
- package/templates/cron/src/index.ts +117 -0
- package/templates/cron/src/jobs.ts +139 -0
- package/templates/cron/src/webhooks.ts +95 -0
- package/templates/cron/tsconfig.json +17 -0
- package/templates/cron/wrangler.jsonc +11 -0
- package/templates/miniapp/.jack.json +1 -1
- package/templates/nextjs/.jack.json +1 -1
- package/templates/nextjs-auth/.jack.json +44 -0
- package/templates/nextjs-auth/app/api/auth/[...all]/route.ts +11 -0
- package/templates/nextjs-auth/app/dashboard/loading.tsx +53 -0
- package/templates/nextjs-auth/app/dashboard/page.tsx +73 -0
- package/templates/nextjs-auth/app/error.tsx +44 -0
- package/templates/nextjs-auth/app/globals.css +1 -0
- package/templates/nextjs-auth/app/health/route.ts +3 -0
- package/templates/nextjs-auth/app/layout.tsx +24 -0
- package/templates/nextjs-auth/app/login/page.tsx +10 -0
- package/templates/nextjs-auth/app/page.tsx +86 -0
- package/templates/nextjs-auth/app/signup/page.tsx +10 -0
- package/templates/nextjs-auth/bun.lock +1065 -0
- package/templates/nextjs-auth/cloudflare-env.d.ts +8 -0
- package/templates/nextjs-auth/components/auth-form.tsx +191 -0
- package/templates/nextjs-auth/components/header.tsx +50 -0
- package/templates/nextjs-auth/components/user-menu.tsx +23 -0
- package/templates/nextjs-auth/lib/auth-client.ts +3 -0
- package/templates/nextjs-auth/lib/auth.ts +43 -0
- package/templates/nextjs-auth/lib/utils.ts +6 -0
- package/templates/nextjs-auth/middleware.ts +33 -0
- package/templates/nextjs-auth/next.config.ts +8 -0
- package/templates/nextjs-auth/open-next.config.ts +6 -0
- package/templates/nextjs-auth/package.json +33 -0
- package/templates/nextjs-auth/postcss.config.mjs +8 -0
- package/templates/nextjs-auth/schema.sql +49 -0
- package/templates/nextjs-auth/tsconfig.json +28 -0
- package/templates/nextjs-auth/wrangler.jsonc +23 -0
- package/templates/nextjs-clerk/.jack.json +54 -0
- package/templates/nextjs-clerk/app/dashboard/page.tsx +69 -0
- package/templates/nextjs-clerk/app/globals.css +1 -0
- package/templates/nextjs-clerk/app/health/route.ts +3 -0
- package/templates/nextjs-clerk/app/layout.tsx +28 -0
- package/templates/nextjs-clerk/app/page.tsx +86 -0
- package/templates/nextjs-clerk/app/sign-in/[[...sign-in]]/page.tsx +9 -0
- package/templates/nextjs-clerk/app/sign-up/[[...sign-up]]/page.tsx +9 -0
- package/templates/nextjs-clerk/bun.lock +1055 -0
- package/templates/nextjs-clerk/cloudflare-env.d.ts +3 -0
- package/templates/nextjs-clerk/components/header.tsx +40 -0
- package/templates/nextjs-clerk/lib/utils.ts +6 -0
- package/templates/nextjs-clerk/middleware.ts +18 -0
- package/templates/nextjs-clerk/next.config.ts +8 -0
- package/templates/nextjs-clerk/open-next.config.ts +6 -0
- package/templates/nextjs-clerk/package.json +31 -0
- package/templates/nextjs-clerk/postcss.config.mjs +8 -0
- package/templates/nextjs-clerk/tsconfig.json +28 -0
- package/templates/nextjs-clerk/wrangler.jsonc +17 -0
- package/templates/nextjs-shadcn/.jack.json +34 -0
- package/templates/nextjs-shadcn/app/dashboard/data.json +614 -0
- package/templates/nextjs-shadcn/app/dashboard/page.tsx +55 -0
- package/templates/nextjs-shadcn/app/globals.css +126 -0
- package/templates/nextjs-shadcn/app/health/route.ts +3 -0
- package/templates/nextjs-shadcn/app/layout.tsx +24 -0
- package/templates/nextjs-shadcn/app/login/page.tsx +19 -0
- package/templates/nextjs-shadcn/app/page.tsx +180 -0
- package/templates/nextjs-shadcn/app/showcase.tsx +1262 -0
- package/templates/nextjs-shadcn/bun.lock +1789 -0
- package/templates/nextjs-shadcn/cloudflare-env.d.ts +4 -0
- package/templates/nextjs-shadcn/components/app-sidebar.tsx +175 -0
- package/templates/nextjs-shadcn/components/chart-area-interactive.tsx +291 -0
- package/templates/nextjs-shadcn/components/data-table.tsx +807 -0
- package/templates/nextjs-shadcn/components/login-form.tsx +95 -0
- package/templates/nextjs-shadcn/components/nav-documents.tsx +92 -0
- package/templates/nextjs-shadcn/components/nav-main.tsx +73 -0
- package/templates/nextjs-shadcn/components/nav-projects.tsx +89 -0
- package/templates/nextjs-shadcn/components/nav-secondary.tsx +42 -0
- package/templates/nextjs-shadcn/components/nav-user.tsx +114 -0
- package/templates/nextjs-shadcn/components/section-cards.tsx +102 -0
- package/templates/nextjs-shadcn/components/site-header.tsx +30 -0
- package/templates/nextjs-shadcn/components/team-switcher.tsx +91 -0
- package/templates/nextjs-shadcn/components/ui/accordion.tsx +66 -0
- package/templates/nextjs-shadcn/components/ui/alert-dialog.tsx +196 -0
- package/templates/nextjs-shadcn/components/ui/alert.tsx +66 -0
- package/templates/nextjs-shadcn/components/ui/aspect-ratio.tsx +11 -0
- package/templates/nextjs-shadcn/components/ui/avatar.tsx +109 -0
- package/templates/nextjs-shadcn/components/ui/badge.tsx +48 -0
- package/templates/nextjs-shadcn/components/ui/breadcrumb.tsx +109 -0
- package/templates/nextjs-shadcn/components/ui/button-group.tsx +83 -0
- package/templates/nextjs-shadcn/components/ui/button.tsx +64 -0
- package/templates/nextjs-shadcn/components/ui/calendar.tsx +220 -0
- package/templates/nextjs-shadcn/components/ui/card.tsx +92 -0
- package/templates/nextjs-shadcn/components/ui/carousel.tsx +241 -0
- package/templates/nextjs-shadcn/components/ui/chart.tsx +357 -0
- package/templates/nextjs-shadcn/components/ui/checkbox.tsx +32 -0
- package/templates/nextjs-shadcn/components/ui/collapsible.tsx +33 -0
- package/templates/nextjs-shadcn/components/ui/combobox.tsx +310 -0
- package/templates/nextjs-shadcn/components/ui/command.tsx +184 -0
- package/templates/nextjs-shadcn/components/ui/context-menu.tsx +252 -0
- package/templates/nextjs-shadcn/components/ui/dialog.tsx +158 -0
- package/templates/nextjs-shadcn/components/ui/direction.tsx +22 -0
- package/templates/nextjs-shadcn/components/ui/drawer.tsx +135 -0
- package/templates/nextjs-shadcn/components/ui/dropdown-menu.tsx +257 -0
- package/templates/nextjs-shadcn/components/ui/empty.tsx +104 -0
- package/templates/nextjs-shadcn/components/ui/field.tsx +248 -0
- package/templates/nextjs-shadcn/components/ui/form.tsx +167 -0
- package/templates/nextjs-shadcn/components/ui/hover-card.tsx +44 -0
- package/templates/nextjs-shadcn/components/ui/input-group.tsx +170 -0
- package/templates/nextjs-shadcn/components/ui/input-otp.tsx +77 -0
- package/templates/nextjs-shadcn/components/ui/input.tsx +21 -0
- package/templates/nextjs-shadcn/components/ui/item.tsx +193 -0
- package/templates/nextjs-shadcn/components/ui/kbd.tsx +28 -0
- package/templates/nextjs-shadcn/components/ui/label.tsx +24 -0
- package/templates/nextjs-shadcn/components/ui/menubar.tsx +276 -0
- package/templates/nextjs-shadcn/components/ui/native-select.tsx +53 -0
- package/templates/nextjs-shadcn/components/ui/navigation-menu.tsx +168 -0
- package/templates/nextjs-shadcn/components/ui/pagination.tsx +127 -0
- package/templates/nextjs-shadcn/components/ui/popover.tsx +89 -0
- package/templates/nextjs-shadcn/components/ui/progress.tsx +31 -0
- package/templates/nextjs-shadcn/components/ui/radio-group.tsx +45 -0
- package/templates/nextjs-shadcn/components/ui/resizable.tsx +53 -0
- package/templates/nextjs-shadcn/components/ui/scroll-area.tsx +58 -0
- package/templates/nextjs-shadcn/components/ui/select.tsx +190 -0
- package/templates/nextjs-shadcn/components/ui/separator.tsx +28 -0
- package/templates/nextjs-shadcn/components/ui/sheet.tsx +143 -0
- package/templates/nextjs-shadcn/components/ui/sidebar.tsx +726 -0
- package/templates/nextjs-shadcn/components/ui/skeleton.tsx +13 -0
- package/templates/nextjs-shadcn/components/ui/slider.tsx +63 -0
- package/templates/nextjs-shadcn/components/ui/sonner.tsx +40 -0
- package/templates/nextjs-shadcn/components/ui/spinner.tsx +16 -0
- package/templates/nextjs-shadcn/components/ui/switch.tsx +35 -0
- package/templates/nextjs-shadcn/components/ui/table.tsx +116 -0
- package/templates/nextjs-shadcn/components/ui/tabs.tsx +91 -0
- package/templates/nextjs-shadcn/components/ui/textarea.tsx +18 -0
- package/templates/nextjs-shadcn/components/ui/toggle-group.tsx +83 -0
- package/templates/nextjs-shadcn/components/ui/toggle.tsx +47 -0
- package/templates/nextjs-shadcn/components/ui/tooltip.tsx +57 -0
- package/templates/nextjs-shadcn/components.json +23 -0
- package/templates/nextjs-shadcn/hooks/use-mobile.ts +19 -0
- package/templates/nextjs-shadcn/lib/utils.ts +6 -0
- package/templates/nextjs-shadcn/next-env.d.ts +6 -0
- package/templates/nextjs-shadcn/next.config.ts +8 -0
- package/templates/nextjs-shadcn/open-next.config.ts +6 -0
- package/templates/nextjs-shadcn/package.json +55 -0
- package/templates/nextjs-shadcn/postcss.config.mjs +8 -0
- package/templates/nextjs-shadcn/tsconfig.json +28 -0
- package/templates/nextjs-shadcn/wrangler.jsonc +23 -0
- package/templates/resend/.jack.json +64 -0
- package/templates/resend/bun.lock +23 -0
- package/templates/resend/package.json +16 -0
- package/templates/resend/schema.sql +13 -0
- package/templates/resend/src/email.ts +165 -0
- package/templates/resend/src/index.ts +108 -0
- package/templates/resend/tsconfig.json +17 -0
- package/templates/resend/wrangler.jsonc +11 -0
- package/templates/saas/.jack.json +1 -1
- package/templates/ai-chat/public/chat.js +0 -149
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import {
|
|
5
|
+
AudioWaveform,
|
|
6
|
+
BookOpen,
|
|
7
|
+
Bot,
|
|
8
|
+
Command,
|
|
9
|
+
Frame,
|
|
10
|
+
GalleryVerticalEnd,
|
|
11
|
+
Map,
|
|
12
|
+
PieChart,
|
|
13
|
+
Settings2,
|
|
14
|
+
SquareTerminal,
|
|
15
|
+
} from "lucide-react"
|
|
16
|
+
|
|
17
|
+
import { NavMain } from "@/components/nav-main"
|
|
18
|
+
import { NavProjects } from "@/components/nav-projects"
|
|
19
|
+
import { NavUser } from "@/components/nav-user"
|
|
20
|
+
import { TeamSwitcher } from "@/components/team-switcher"
|
|
21
|
+
import {
|
|
22
|
+
Sidebar,
|
|
23
|
+
SidebarContent,
|
|
24
|
+
SidebarFooter,
|
|
25
|
+
SidebarHeader,
|
|
26
|
+
SidebarRail,
|
|
27
|
+
} from "@/components/ui/sidebar"
|
|
28
|
+
|
|
29
|
+
// This is sample data.
|
|
30
|
+
const data = {
|
|
31
|
+
user: {
|
|
32
|
+
name: "shadcn",
|
|
33
|
+
email: "m@example.com",
|
|
34
|
+
avatar: "/avatars/shadcn.jpg",
|
|
35
|
+
},
|
|
36
|
+
teams: [
|
|
37
|
+
{
|
|
38
|
+
name: "Acme Inc",
|
|
39
|
+
logo: GalleryVerticalEnd,
|
|
40
|
+
plan: "Enterprise",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "Acme Corp.",
|
|
44
|
+
logo: AudioWaveform,
|
|
45
|
+
plan: "Startup",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "Evil Corp.",
|
|
49
|
+
logo: Command,
|
|
50
|
+
plan: "Free",
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
navMain: [
|
|
54
|
+
{
|
|
55
|
+
title: "Playground",
|
|
56
|
+
url: "#",
|
|
57
|
+
icon: SquareTerminal,
|
|
58
|
+
isActive: true,
|
|
59
|
+
items: [
|
|
60
|
+
{
|
|
61
|
+
title: "History",
|
|
62
|
+
url: "#",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: "Starred",
|
|
66
|
+
url: "#",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: "Settings",
|
|
70
|
+
url: "#",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: "Models",
|
|
76
|
+
url: "#",
|
|
77
|
+
icon: Bot,
|
|
78
|
+
items: [
|
|
79
|
+
{
|
|
80
|
+
title: "Genesis",
|
|
81
|
+
url: "#",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: "Explorer",
|
|
85
|
+
url: "#",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: "Quantum",
|
|
89
|
+
url: "#",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: "Documentation",
|
|
95
|
+
url: "#",
|
|
96
|
+
icon: BookOpen,
|
|
97
|
+
items: [
|
|
98
|
+
{
|
|
99
|
+
title: "Introduction",
|
|
100
|
+
url: "#",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
title: "Get Started",
|
|
104
|
+
url: "#",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
title: "Tutorials",
|
|
108
|
+
url: "#",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
title: "Changelog",
|
|
112
|
+
url: "#",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
title: "Settings",
|
|
118
|
+
url: "#",
|
|
119
|
+
icon: Settings2,
|
|
120
|
+
items: [
|
|
121
|
+
{
|
|
122
|
+
title: "General",
|
|
123
|
+
url: "#",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
title: "Team",
|
|
127
|
+
url: "#",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
title: "Billing",
|
|
131
|
+
url: "#",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
title: "Limits",
|
|
135
|
+
url: "#",
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
projects: [
|
|
141
|
+
{
|
|
142
|
+
name: "Design Engineering",
|
|
143
|
+
url: "#",
|
|
144
|
+
icon: Frame,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "Sales & Marketing",
|
|
148
|
+
url: "#",
|
|
149
|
+
icon: PieChart,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "Travel",
|
|
153
|
+
url: "#",
|
|
154
|
+
icon: Map,
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
|
160
|
+
return (
|
|
161
|
+
<Sidebar collapsible="icon" {...props}>
|
|
162
|
+
<SidebarHeader>
|
|
163
|
+
<TeamSwitcher teams={data.teams} />
|
|
164
|
+
</SidebarHeader>
|
|
165
|
+
<SidebarContent>
|
|
166
|
+
<NavMain items={data.navMain} />
|
|
167
|
+
<NavProjects projects={data.projects} />
|
|
168
|
+
</SidebarContent>
|
|
169
|
+
<SidebarFooter>
|
|
170
|
+
<NavUser user={data.user} />
|
|
171
|
+
</SidebarFooter>
|
|
172
|
+
<SidebarRail />
|
|
173
|
+
</Sidebar>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Area, AreaChart, CartesianGrid, XAxis } from "recharts"
|
|
5
|
+
|
|
6
|
+
import { useIsMobile } from "@/hooks/use-mobile"
|
|
7
|
+
import {
|
|
8
|
+
Card,
|
|
9
|
+
CardAction,
|
|
10
|
+
CardContent,
|
|
11
|
+
CardDescription,
|
|
12
|
+
CardHeader,
|
|
13
|
+
CardTitle,
|
|
14
|
+
} from "@/components/ui/card"
|
|
15
|
+
import {
|
|
16
|
+
ChartContainer,
|
|
17
|
+
ChartTooltip,
|
|
18
|
+
ChartTooltipContent,
|
|
19
|
+
type ChartConfig,
|
|
20
|
+
} from "@/components/ui/chart"
|
|
21
|
+
import {
|
|
22
|
+
Select,
|
|
23
|
+
SelectContent,
|
|
24
|
+
SelectItem,
|
|
25
|
+
SelectTrigger,
|
|
26
|
+
SelectValue,
|
|
27
|
+
} from "@/components/ui/select"
|
|
28
|
+
import {
|
|
29
|
+
ToggleGroup,
|
|
30
|
+
ToggleGroupItem,
|
|
31
|
+
} from "@/components/ui/toggle-group"
|
|
32
|
+
|
|
33
|
+
export const description = "An interactive area chart"
|
|
34
|
+
|
|
35
|
+
const chartData = [
|
|
36
|
+
{ date: "2024-04-01", desktop: 222, mobile: 150 },
|
|
37
|
+
{ date: "2024-04-02", desktop: 97, mobile: 180 },
|
|
38
|
+
{ date: "2024-04-03", desktop: 167, mobile: 120 },
|
|
39
|
+
{ date: "2024-04-04", desktop: 242, mobile: 260 },
|
|
40
|
+
{ date: "2024-04-05", desktop: 373, mobile: 290 },
|
|
41
|
+
{ date: "2024-04-06", desktop: 301, mobile: 340 },
|
|
42
|
+
{ date: "2024-04-07", desktop: 245, mobile: 180 },
|
|
43
|
+
{ date: "2024-04-08", desktop: 409, mobile: 320 },
|
|
44
|
+
{ date: "2024-04-09", desktop: 59, mobile: 110 },
|
|
45
|
+
{ date: "2024-04-10", desktop: 261, mobile: 190 },
|
|
46
|
+
{ date: "2024-04-11", desktop: 327, mobile: 350 },
|
|
47
|
+
{ date: "2024-04-12", desktop: 292, mobile: 210 },
|
|
48
|
+
{ date: "2024-04-13", desktop: 342, mobile: 380 },
|
|
49
|
+
{ date: "2024-04-14", desktop: 137, mobile: 220 },
|
|
50
|
+
{ date: "2024-04-15", desktop: 120, mobile: 170 },
|
|
51
|
+
{ date: "2024-04-16", desktop: 138, mobile: 190 },
|
|
52
|
+
{ date: "2024-04-17", desktop: 446, mobile: 360 },
|
|
53
|
+
{ date: "2024-04-18", desktop: 364, mobile: 410 },
|
|
54
|
+
{ date: "2024-04-19", desktop: 243, mobile: 180 },
|
|
55
|
+
{ date: "2024-04-20", desktop: 89, mobile: 150 },
|
|
56
|
+
{ date: "2024-04-21", desktop: 137, mobile: 200 },
|
|
57
|
+
{ date: "2024-04-22", desktop: 224, mobile: 170 },
|
|
58
|
+
{ date: "2024-04-23", desktop: 138, mobile: 230 },
|
|
59
|
+
{ date: "2024-04-24", desktop: 387, mobile: 290 },
|
|
60
|
+
{ date: "2024-04-25", desktop: 215, mobile: 250 },
|
|
61
|
+
{ date: "2024-04-26", desktop: 75, mobile: 130 },
|
|
62
|
+
{ date: "2024-04-27", desktop: 383, mobile: 420 },
|
|
63
|
+
{ date: "2024-04-28", desktop: 122, mobile: 180 },
|
|
64
|
+
{ date: "2024-04-29", desktop: 315, mobile: 240 },
|
|
65
|
+
{ date: "2024-04-30", desktop: 454, mobile: 380 },
|
|
66
|
+
{ date: "2024-05-01", desktop: 165, mobile: 220 },
|
|
67
|
+
{ date: "2024-05-02", desktop: 293, mobile: 310 },
|
|
68
|
+
{ date: "2024-05-03", desktop: 247, mobile: 190 },
|
|
69
|
+
{ date: "2024-05-04", desktop: 385, mobile: 420 },
|
|
70
|
+
{ date: "2024-05-05", desktop: 481, mobile: 390 },
|
|
71
|
+
{ date: "2024-05-06", desktop: 498, mobile: 520 },
|
|
72
|
+
{ date: "2024-05-07", desktop: 388, mobile: 300 },
|
|
73
|
+
{ date: "2024-05-08", desktop: 149, mobile: 210 },
|
|
74
|
+
{ date: "2024-05-09", desktop: 227, mobile: 180 },
|
|
75
|
+
{ date: "2024-05-10", desktop: 293, mobile: 330 },
|
|
76
|
+
{ date: "2024-05-11", desktop: 335, mobile: 270 },
|
|
77
|
+
{ date: "2024-05-12", desktop: 197, mobile: 240 },
|
|
78
|
+
{ date: "2024-05-13", desktop: 197, mobile: 160 },
|
|
79
|
+
{ date: "2024-05-14", desktop: 448, mobile: 490 },
|
|
80
|
+
{ date: "2024-05-15", desktop: 473, mobile: 380 },
|
|
81
|
+
{ date: "2024-05-16", desktop: 338, mobile: 400 },
|
|
82
|
+
{ date: "2024-05-17", desktop: 499, mobile: 420 },
|
|
83
|
+
{ date: "2024-05-18", desktop: 315, mobile: 350 },
|
|
84
|
+
{ date: "2024-05-19", desktop: 235, mobile: 180 },
|
|
85
|
+
{ date: "2024-05-20", desktop: 177, mobile: 230 },
|
|
86
|
+
{ date: "2024-05-21", desktop: 82, mobile: 140 },
|
|
87
|
+
{ date: "2024-05-22", desktop: 81, mobile: 120 },
|
|
88
|
+
{ date: "2024-05-23", desktop: 252, mobile: 290 },
|
|
89
|
+
{ date: "2024-05-24", desktop: 294, mobile: 220 },
|
|
90
|
+
{ date: "2024-05-25", desktop: 201, mobile: 250 },
|
|
91
|
+
{ date: "2024-05-26", desktop: 213, mobile: 170 },
|
|
92
|
+
{ date: "2024-05-27", desktop: 420, mobile: 460 },
|
|
93
|
+
{ date: "2024-05-28", desktop: 233, mobile: 190 },
|
|
94
|
+
{ date: "2024-05-29", desktop: 78, mobile: 130 },
|
|
95
|
+
{ date: "2024-05-30", desktop: 340, mobile: 280 },
|
|
96
|
+
{ date: "2024-05-31", desktop: 178, mobile: 230 },
|
|
97
|
+
{ date: "2024-06-01", desktop: 178, mobile: 200 },
|
|
98
|
+
{ date: "2024-06-02", desktop: 470, mobile: 410 },
|
|
99
|
+
{ date: "2024-06-03", desktop: 103, mobile: 160 },
|
|
100
|
+
{ date: "2024-06-04", desktop: 439, mobile: 380 },
|
|
101
|
+
{ date: "2024-06-05", desktop: 88, mobile: 140 },
|
|
102
|
+
{ date: "2024-06-06", desktop: 294, mobile: 250 },
|
|
103
|
+
{ date: "2024-06-07", desktop: 323, mobile: 370 },
|
|
104
|
+
{ date: "2024-06-08", desktop: 385, mobile: 320 },
|
|
105
|
+
{ date: "2024-06-09", desktop: 438, mobile: 480 },
|
|
106
|
+
{ date: "2024-06-10", desktop: 155, mobile: 200 },
|
|
107
|
+
{ date: "2024-06-11", desktop: 92, mobile: 150 },
|
|
108
|
+
{ date: "2024-06-12", desktop: 492, mobile: 420 },
|
|
109
|
+
{ date: "2024-06-13", desktop: 81, mobile: 130 },
|
|
110
|
+
{ date: "2024-06-14", desktop: 426, mobile: 380 },
|
|
111
|
+
{ date: "2024-06-15", desktop: 307, mobile: 350 },
|
|
112
|
+
{ date: "2024-06-16", desktop: 371, mobile: 310 },
|
|
113
|
+
{ date: "2024-06-17", desktop: 475, mobile: 520 },
|
|
114
|
+
{ date: "2024-06-18", desktop: 107, mobile: 170 },
|
|
115
|
+
{ date: "2024-06-19", desktop: 341, mobile: 290 },
|
|
116
|
+
{ date: "2024-06-20", desktop: 408, mobile: 450 },
|
|
117
|
+
{ date: "2024-06-21", desktop: 169, mobile: 210 },
|
|
118
|
+
{ date: "2024-06-22", desktop: 317, mobile: 270 },
|
|
119
|
+
{ date: "2024-06-23", desktop: 480, mobile: 530 },
|
|
120
|
+
{ date: "2024-06-24", desktop: 132, mobile: 180 },
|
|
121
|
+
{ date: "2024-06-25", desktop: 141, mobile: 190 },
|
|
122
|
+
{ date: "2024-06-26", desktop: 434, mobile: 380 },
|
|
123
|
+
{ date: "2024-06-27", desktop: 448, mobile: 490 },
|
|
124
|
+
{ date: "2024-06-28", desktop: 149, mobile: 200 },
|
|
125
|
+
{ date: "2024-06-29", desktop: 103, mobile: 160 },
|
|
126
|
+
{ date: "2024-06-30", desktop: 446, mobile: 400 },
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
const chartConfig = {
|
|
130
|
+
visitors: {
|
|
131
|
+
label: "Visitors",
|
|
132
|
+
},
|
|
133
|
+
desktop: {
|
|
134
|
+
label: "Desktop",
|
|
135
|
+
color: "var(--primary)",
|
|
136
|
+
},
|
|
137
|
+
mobile: {
|
|
138
|
+
label: "Mobile",
|
|
139
|
+
color: "var(--primary)",
|
|
140
|
+
},
|
|
141
|
+
} satisfies ChartConfig
|
|
142
|
+
|
|
143
|
+
export function ChartAreaInteractive() {
|
|
144
|
+
const isMobile = useIsMobile()
|
|
145
|
+
const [timeRange, setTimeRange] = React.useState("90d")
|
|
146
|
+
|
|
147
|
+
React.useEffect(() => {
|
|
148
|
+
if (isMobile) {
|
|
149
|
+
setTimeRange("7d")
|
|
150
|
+
}
|
|
151
|
+
}, [isMobile])
|
|
152
|
+
|
|
153
|
+
const filteredData = chartData.filter((item) => {
|
|
154
|
+
const date = new Date(item.date)
|
|
155
|
+
const referenceDate = new Date("2024-06-30")
|
|
156
|
+
let daysToSubtract = 90
|
|
157
|
+
if (timeRange === "30d") {
|
|
158
|
+
daysToSubtract = 30
|
|
159
|
+
} else if (timeRange === "7d") {
|
|
160
|
+
daysToSubtract = 7
|
|
161
|
+
}
|
|
162
|
+
const startDate = new Date(referenceDate)
|
|
163
|
+
startDate.setDate(startDate.getDate() - daysToSubtract)
|
|
164
|
+
return date >= startDate
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<Card className="@container/card">
|
|
169
|
+
<CardHeader>
|
|
170
|
+
<CardTitle>Total Visitors</CardTitle>
|
|
171
|
+
<CardDescription>
|
|
172
|
+
<span className="hidden @[540px]/card:block">
|
|
173
|
+
Total for the last 3 months
|
|
174
|
+
</span>
|
|
175
|
+
<span className="@[540px]/card:hidden">Last 3 months</span>
|
|
176
|
+
</CardDescription>
|
|
177
|
+
<CardAction>
|
|
178
|
+
<ToggleGroup
|
|
179
|
+
type="single"
|
|
180
|
+
value={timeRange}
|
|
181
|
+
onValueChange={setTimeRange}
|
|
182
|
+
variant="outline"
|
|
183
|
+
className="hidden *:data-[slot=toggle-group-item]:!px-4 @[767px]/card:flex"
|
|
184
|
+
>
|
|
185
|
+
<ToggleGroupItem value="90d">Last 3 months</ToggleGroupItem>
|
|
186
|
+
<ToggleGroupItem value="30d">Last 30 days</ToggleGroupItem>
|
|
187
|
+
<ToggleGroupItem value="7d">Last 7 days</ToggleGroupItem>
|
|
188
|
+
</ToggleGroup>
|
|
189
|
+
<Select value={timeRange} onValueChange={setTimeRange}>
|
|
190
|
+
<SelectTrigger
|
|
191
|
+
className="flex w-40 **:data-[slot=select-value]:block **:data-[slot=select-value]:truncate @[767px]/card:hidden"
|
|
192
|
+
size="sm"
|
|
193
|
+
aria-label="Select a value"
|
|
194
|
+
>
|
|
195
|
+
<SelectValue placeholder="Last 3 months" />
|
|
196
|
+
</SelectTrigger>
|
|
197
|
+
<SelectContent className="rounded-xl">
|
|
198
|
+
<SelectItem value="90d" className="rounded-lg">
|
|
199
|
+
Last 3 months
|
|
200
|
+
</SelectItem>
|
|
201
|
+
<SelectItem value="30d" className="rounded-lg">
|
|
202
|
+
Last 30 days
|
|
203
|
+
</SelectItem>
|
|
204
|
+
<SelectItem value="7d" className="rounded-lg">
|
|
205
|
+
Last 7 days
|
|
206
|
+
</SelectItem>
|
|
207
|
+
</SelectContent>
|
|
208
|
+
</Select>
|
|
209
|
+
</CardAction>
|
|
210
|
+
</CardHeader>
|
|
211
|
+
<CardContent className="px-2 pt-4 sm:px-6 sm:pt-6">
|
|
212
|
+
<ChartContainer
|
|
213
|
+
config={chartConfig}
|
|
214
|
+
className="aspect-auto h-[250px] w-full"
|
|
215
|
+
>
|
|
216
|
+
<AreaChart data={filteredData}>
|
|
217
|
+
<defs>
|
|
218
|
+
<linearGradient id="fillDesktop" x1="0" y1="0" x2="0" y2="1">
|
|
219
|
+
<stop
|
|
220
|
+
offset="5%"
|
|
221
|
+
stopColor="var(--color-desktop)"
|
|
222
|
+
stopOpacity={1.0}
|
|
223
|
+
/>
|
|
224
|
+
<stop
|
|
225
|
+
offset="95%"
|
|
226
|
+
stopColor="var(--color-desktop)"
|
|
227
|
+
stopOpacity={0.1}
|
|
228
|
+
/>
|
|
229
|
+
</linearGradient>
|
|
230
|
+
<linearGradient id="fillMobile" x1="0" y1="0" x2="0" y2="1">
|
|
231
|
+
<stop
|
|
232
|
+
offset="5%"
|
|
233
|
+
stopColor="var(--color-mobile)"
|
|
234
|
+
stopOpacity={0.8}
|
|
235
|
+
/>
|
|
236
|
+
<stop
|
|
237
|
+
offset="95%"
|
|
238
|
+
stopColor="var(--color-mobile)"
|
|
239
|
+
stopOpacity={0.1}
|
|
240
|
+
/>
|
|
241
|
+
</linearGradient>
|
|
242
|
+
</defs>
|
|
243
|
+
<CartesianGrid vertical={false} />
|
|
244
|
+
<XAxis
|
|
245
|
+
dataKey="date"
|
|
246
|
+
tickLine={false}
|
|
247
|
+
axisLine={false}
|
|
248
|
+
tickMargin={8}
|
|
249
|
+
minTickGap={32}
|
|
250
|
+
tickFormatter={(value) => {
|
|
251
|
+
const date = new Date(value)
|
|
252
|
+
return date.toLocaleDateString("en-US", {
|
|
253
|
+
month: "short",
|
|
254
|
+
day: "numeric",
|
|
255
|
+
})
|
|
256
|
+
}}
|
|
257
|
+
/>
|
|
258
|
+
<ChartTooltip
|
|
259
|
+
cursor={false}
|
|
260
|
+
content={
|
|
261
|
+
<ChartTooltipContent
|
|
262
|
+
labelFormatter={(value) => {
|
|
263
|
+
return new Date(value).toLocaleDateString("en-US", {
|
|
264
|
+
month: "short",
|
|
265
|
+
day: "numeric",
|
|
266
|
+
})
|
|
267
|
+
}}
|
|
268
|
+
indicator="dot"
|
|
269
|
+
/>
|
|
270
|
+
}
|
|
271
|
+
/>
|
|
272
|
+
<Area
|
|
273
|
+
dataKey="mobile"
|
|
274
|
+
type="natural"
|
|
275
|
+
fill="url(#fillMobile)"
|
|
276
|
+
stroke="var(--color-mobile)"
|
|
277
|
+
stackId="a"
|
|
278
|
+
/>
|
|
279
|
+
<Area
|
|
280
|
+
dataKey="desktop"
|
|
281
|
+
type="natural"
|
|
282
|
+
fill="url(#fillDesktop)"
|
|
283
|
+
stroke="var(--color-desktop)"
|
|
284
|
+
stackId="a"
|
|
285
|
+
/>
|
|
286
|
+
</AreaChart>
|
|
287
|
+
</ChartContainer>
|
|
288
|
+
</CardContent>
|
|
289
|
+
</Card>
|
|
290
|
+
)
|
|
291
|
+
}
|