Skip to content

Commit 83c1d20

Browse files
committed
migration
1 parent b37efc0 commit 83c1d20

21 files changed

Lines changed: 130 additions & 83 deletions

.env.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ UPSTASH_REDIS_REST_TOKEN=upstash-redis-token
3737
NEXT_PUBLIC_MAPBOX_API=mapbox-key
3838

3939
# Cron (openssl rand -hex 32)
40-
CRON_SECRET=some-random-secret
40+
CRON_SECRET=some-random-secret
41+
42+
# Supabase
43+
SUPABASE_URL=
44+
SUPABASE_PUBLISHABLE_DEFAULT_KEY=
45+
SUPABASE_ANON_KEY=
46+
SUPABASE_SERVICE_ROLE_KEY=

drizzle.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { defineConfig } from "drizzle-kit"
22

3-
import { getXataClient } from "~/server/db/xata"
4-
53
export default defineConfig({
64
out: "./src/server/db/migrations",
75
schema: "./src/server/db/schema.ts",
86
verbose: true,
97
dialect: "postgresql",
108
tablesFilter: ["cfc-website_*"],
119
dbCredentials: {
12-
url: getXataClient().sql.connectionString,
10+
url: process.env.SUPABASE_DB_URL!,
1311
},
1412
})

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"next": "14.2.26",
7272
"next-themes": "0.3.0",
7373
"pg": "^8.14.1",
74+
"pg-native": "^3.5.2",
7475
"react": "18.3.1",
7576
"react-day-picker": "8.10.0",
7677
"react-dom": "18.3.1",
@@ -96,6 +97,7 @@
9697
"@types/eslint": "8.56.6",
9798
"@types/mapbox-gl": "3.1.0",
9899
"@types/node": "20.12.2",
100+
"@types/pg": "^8.16.0",
99101
"@types/react": "18.3.3",
100102
"@types/react-dom": "18.2.23",
101103
"@typescript-eslint/eslint-plugin": "7.4.0",

pnpm-lock.yaml

Lines changed: 65 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dashboard/admin/@tools/export.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export default function ExportButton({ data, label }: ExportButtonProps) {
2828
const headers = Object.keys(data[0] as Record<string, unknown>).join(",")
2929
const escapeCSV = (value: unknown) => {
3030
if (value == null) return ""
31+
if (value instanceof Date) return value.toISOString()
32+
if (typeof value === "string" && !isNaN(Date.parse(value))) {
33+
return new Date(value).toISOString()
34+
}
3135
const str = String(value)
3236
if (/[",\n]/.test(str)) {
3337
return `"${str.replace(/"/g, '""')}"`

src/app/dashboard/admin/@users/table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import { api } from "~/trpc/react"
6666
import ExportButton from "../@tools/export"
6767
import AddUserForm from "./form"
6868

69-
type DisplayColumn = Omit<User, "subscribe" | "square_customer_id" | "updatedAt" | "reminder_pending">
69+
type DisplayColumn = Omit<User, "subscribe" | "square_customer_id" | "updated_at" | "reminder_pending">
7070

7171
export interface TableProps {
7272
data: Array<User>
@@ -167,7 +167,7 @@ const columns = (updateRole: ({ id, role }: UpdateUserRoleFunctionProps) => void
167167
id: "Date joined",
168168
header: "Date joined",
169169
cell: (cell) => <span className="text-xs">{cell.getValue<React.ReactNode>()}</span>,
170-
accessorFn: (user) => format(user.createdAt, "Pp", { locale: enAU }),
170+
accessorFn: (user) => format(user.created_at, "Pp", { locale: enAU }),
171171
},
172172
{
173173
id: "Membership expiry",

src/app/dashboard/admin/layout.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
"use client"
2-
31
import * as React from "react"
4-
import type { ImperativePanelHandle } from "react-resizable-panels"
52

6-
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "~/components/ui/resizable"
7-
import { Separator } from "~/components/ui/separator"
83
import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs"
94

5+
import NotFound from "~/app/not-found"
106
import type { PropsWithChildren } from "~/lib/types"
11-
import { cn } from "~/lib/utils"
7+
import { api } from "~/trpc/server"
128

139
interface AdminDashLayoutProps extends PropsWithChildren {
1410
users: React.ReactNode
@@ -18,7 +14,12 @@ interface AdminDashLayoutProps extends PropsWithChildren {
1814
tools: React.ReactNode
1915
}
2016

21-
const Layout = ({ children, ...props }: AdminDashLayoutProps) => {
17+
const Layout = async ({ children, ...props }: AdminDashLayoutProps) => {
18+
const user = await api.users.getCurrent.query()
19+
if (!["admin", "committee"].includes(user?.role ?? "")) {
20+
return <NotFound />
21+
}
22+
2223
const sidebarItems = [
2324
{ text: "Users", icon: "group", component: props.users },
2425
{ text: "Projects", icon: "devices", component: props.projects },

src/app/profile/[id]/profile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const ProfilePage = ({ id, currentUser }: ProfilePageProps) => {
146146
user.membership_expiry && (
147147
<div>
148148
Your membership will expire on{" "}
149-
<span className="text-destructive">
149+
<span className="text-primary">
150150
{format(new Date(String(user.membership_expiry)), "dd MMMM yyyy")}
151151
</span>
152152
</div>

0 commit comments

Comments
 (0)