Skip to content

Commit 3a05886

Browse files
authored
Merge pull request #165 from apsinghdev/feat/sheet
[feat] add sheet and revamp dashboard
2 parents 5445fd9 + 9c655f0 commit 3a05886

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2586
-371
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "User" ADD COLUMN "completedSteps" JSONB;

apps/api/prisma/schema.prisma

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ enum SubscriptionStatus {
3232
}
3333

3434
model User {
35-
id String @id @default(cuid())
36-
email String @unique
37-
firstName String
38-
authMethod String
39-
createdAt DateTime @default(now())
40-
lastLogin DateTime @updatedAt
41-
accounts Account[]
42-
payments Payment[]
43-
subscriptions Subscription[]
35+
id String @id @default(cuid())
36+
email String @unique
37+
firstName String
38+
authMethod String
39+
createdAt DateTime @default(now())
40+
lastLogin DateTime @updatedAt
41+
completedSteps Json?
42+
accounts Account[]
43+
payments Payment[]
44+
subscriptions Subscription[]
4445
}
4546

4647
model Account {

apps/api/src/routers/user.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { router, publicProcedure, protectedProcedure } from "../trpc.js";
22
import { userService } from "../services/user.service.js";
3+
import { z } from "zod";
34

45
export const userRouter = router({
56
// get the total count of users
@@ -12,4 +13,26 @@ export const userRouter = router({
1213
const userId = ctx.user.id;
1314
return await userService.checkSubscriptionStatus(ctx.db.prisma, userId);
1415
}),
16+
17+
// get user's completed steps
18+
getCompletedSteps: protectedProcedure.query(async ({ ctx }: any) => {
19+
const userId = ctx.user.id;
20+
return await userService.getCompletedSteps(ctx.db.prisma, userId);
21+
}),
22+
23+
// update user's completed steps
24+
updateCompletedSteps: protectedProcedure
25+
.input(
26+
z.object({
27+
completedSteps: z.array(z.string()),
28+
})
29+
)
30+
.mutation(async ({ ctx, input }: any) => {
31+
const userId = ctx.user.id;
32+
return await userService.updateCompletedSteps(
33+
ctx.db.prisma,
34+
userId,
35+
input.completedSteps
36+
);
37+
}),
1538
});

apps/api/src/services/user.service.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,43 @@ export const userService = {
4747
: null,
4848
};
4949
},
50+
51+
/**
52+
* Get user's completed steps
53+
*/
54+
async getCompletedSteps(
55+
prisma: ExtendedPrismaClient | PrismaClient,
56+
userId: string
57+
) {
58+
const user = await prisma.user.findUnique({
59+
where: { id: userId },
60+
select: { completedSteps: true },
61+
});
62+
63+
if (!user) {
64+
throw new Error("User not found");
65+
}
66+
67+
const completedSteps = user.completedSteps as string[] | null;
68+
return completedSteps || [];
69+
},
70+
71+
/**
72+
* Update user's completed steps
73+
*/
74+
async updateCompletedSteps(
75+
prisma: ExtendedPrismaClient | PrismaClient,
76+
userId: string,
77+
completedSteps: string[]
78+
) {
79+
const user = await prisma.user.update({
80+
where: { id: userId },
81+
data: {
82+
completedSteps: completedSteps,
83+
},
84+
select: { completedSteps: true },
85+
});
86+
87+
return (user.completedSteps as string[]) || [];
88+
},
5089
};

apps/web/next.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ const nextConfig = {
66
protocol: "https",
77
hostname: "avatars.githubusercontent.com",
88
},
9+
{
10+
protocol: "https",
11+
hostname: "lh3.googleusercontent.com",
12+
},
913
],
1014
},
1115
};

apps/web/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@vercel/speed-insights": "^1.1.0",
2525
"class-variance-authority": "^0.7.0",
2626
"clsx": "^2.1.1",
27+
"dompurify": "^3.3.0",
2728
"framer-motion": "^11.15.0",
2829
"geist": "^1.5.1",
2930
"lucide-react": "^0.456.0",
@@ -41,6 +42,7 @@
4142
"zustand": "^5.0.1"
4243
},
4344
"devDependencies": {
45+
"@types/dompurify": "^3.2.0",
4446
"@types/node": "^20",
4547
"@types/react": "^18",
4648
"@types/react-dom": "^18",

apps/web/public/images/dm.webp

49 KB
Loading

apps/web/public/images/doc.webp

37.1 KB
Loading

apps/web/public/images/lv-1.webp

33.9 KB
Loading
104 KB
Loading

0 commit comments

Comments
 (0)