Skip to content

Commit 74a2fc1

Browse files
committed
Fixed payment issue while verifying payment success
1 parent 1653f2a commit 74a2fc1

File tree

11 files changed

+168
-36
lines changed

11 files changed

+168
-36
lines changed

app/(authenticated)/dashboard/page.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import { currentUser } from "@clerk/nextjs/server";
88
import { PlusIcon } from "lucide-react";
99
import Link from "next/link";
1010
import { redirect } from "next/navigation";
11-
import {
12-
hasReachedUploadLimit,
13-
UploadLimitResponse,
14-
} from "@/lib/user";
11+
import { hasReachedUploadLimit, UploadLimitResponse } from "@/lib/user";
1512
import { UploadLimitReached } from "./upload-limit";
1613
import {
1714
MotionDiv,
@@ -89,8 +86,15 @@ export default async function DashboardPage() {
8986
</div>
9087

9188
<MotionDiv
92-
variants={itemVariants}
93-
initial="hidden"
89+
// variants={itemVariants}
90+
initial={{ opacity: 0, x: -300 }}
91+
whileInView={{ opacity: 1, x: 0 }}
92+
transition={{
93+
duration: 0.6,
94+
type: "spring",
95+
stiffness: 70,
96+
// damping: 35,
97+
}}
9498
animate="visible"
9599
className="mb-6"
96100
>

app/api/verify-payment/route.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ export async function POST(req: NextRequest) {
5151
// Insert into payment table
5252
const newPlan = order_amount === 99 ? "basic" : "pro";
5353

54+
console.log("Customer email is: ", customer_email);
55+
5456
await sql`
55-
INSERT INTO payments (cashfree_payment_id, amount, status, price_id, user_email, created_at, updated_at)
57+
INSERT INTO payments (cashfree_payment_id, amount, status, price_id, user_email, created_at, updated_at)
5658
VALUES (${order_id}, ${order_amount}, 'SUCCESS', ${newPlan}, ${customer_email}, NOW(), NOW())`;
5759

5860
await sql`

app/globals.css

+102
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
@custom-variant dark (&:is(.dark *));
66

7+
@property --border-angle {
8+
syntax: "<angle>";
9+
inherits: false;
10+
initial-value: 0deg;
11+
}
12+
713
@theme {
814
--font-sans: var(--font-sans), ui-sans-serif, system-ui, sans-serif,
915
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
@@ -45,6 +51,14 @@
4551
--radius-lg: var(--radius);
4652
--radius-md: calc(var(--radius) - 2px);
4753
--radius-sm: calc(var(--radius) - 4px);
54+
55+
--animate-rotate-border: border-rotate 4s linear infinite;
56+
57+
@keyframes border-rotate {
58+
to {
59+
--border-angle: 360deg;
60+
}
61+
}
4862
}
4963

5064
/*
@@ -195,3 +209,91 @@
195209
.animate-gradient-x {
196210
animation: gradient-x 3s ease infinite;
197211
}
212+
213+
/* .aiSummaryBadge {
214+
position: relative;
215+
padding: 5px 8px;
216+
border-radius: 8px;
217+
background-color: white/80;
218+
}
219+
220+
@property --angle {
221+
syntax: "<angle>";
222+
initial-value: 0deg;
223+
inherits: false;
224+
}
225+
226+
.aiSummaryBadge::after,
227+
.aiSummaryBadge::before {
228+
content: "";
229+
position: absolute;
230+
top: -2px;
231+
left: -2px;
232+
right: -2px;
233+
bottom: -2px;
234+
background-image: conic-gradient(from var(--angle), transparent 70%, blue);
235+
border-radius: 12px;
236+
z-index: -1;
237+
animation: 3s spin linear infinite;
238+
}
239+
240+
.aiSummaryBadge::before {
241+
filter: blur(1.5rem);
242+
opacity: 0.5;
243+
}
244+
245+
@keyframes spin {
246+
from {
247+
--angle: 0deg;
248+
}
249+
to {
250+
--angle: 360deg;
251+
}
252+
} */
253+
254+
.aiSummaryBadge {
255+
position: relative;
256+
padding: 5px 8px;
257+
border-radius: 8px;
258+
background-color: rgba(
259+
255,
260+
255,
261+
255,
262+
0.8
263+
); /* Corrected the background color */
264+
overflow: hidden; /* Ensure the pseudo-elements don't overflow the badge */
265+
}
266+
267+
@property --angle {
268+
syntax: "<angle>";
269+
initial-value: 0deg;
270+
inherits: false;
271+
}
272+
273+
.aiSummaryBadge::after,
274+
.aiSummaryBadge::before {
275+
content: "";
276+
position: absolute;
277+
top: -2px;
278+
left: -2px;
279+
right: -2px;
280+
bottom: -2px;
281+
background-image: conic-gradient(from var(--angle), transparent 70%, blue);
282+
border-radius: 12px;
283+
z-index: -1;
284+
animation: 3s spin linear infinite;
285+
}
286+
287+
.aiSummaryBadge::before {
288+
filter: blur(1.5rem);
289+
opacity: 0.5;
290+
}
291+
292+
@keyframes spin {
293+
from {
294+
--angle: 0deg;
295+
}
296+
to {
297+
--angle: 360deg;
298+
}
299+
}

components/common/header-section.tsx

+26-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Image from "next/image";
22
import { NavLink } from "./nav-links";
33
import { SignedIn, SignedOut, UserButton } from "@clerk/nextjs";
44
import { UserPlanBadge } from "@/components/common/plan-badge";
5+
import { BadgeIndianRupee, BookOpen, Upload, User } from "lucide-react";
56

67
export const Header = () => {
78
return (
@@ -14,28 +15,49 @@ export const Header = () => {
1415
width={150}
1516
height={100}
1617
quality={100}
18+
unoptimized
1719
/>
1820
</NavLink>
1921
</div>
2022
<div className="flex lg:justify-center lg:items-center gap-4 lg:gap-12 lg:flex-1">
21-
<NavLink href={"/#pricing"}>Pricing</NavLink>
23+
<NavLink href={"/#pricing"}>
24+
<span className="flex items-center gap-1">
25+
<BadgeIndianRupee className="!size-4" />
26+
Pricing
27+
</span>
28+
</NavLink>
2229
<SignedIn>
23-
<NavLink href={"/dashboard"}>Your Summaries</NavLink>
30+
<NavLink href={"/dashboard"}>
31+
<span className="flex items-center gap-1">
32+
<BookOpen className="!size-4" />
33+
Your Summaries
34+
</span>
35+
</NavLink>
2436
</SignedIn>
2537
</div>
2638

2739
<div className="flex lg:justify-end">
2840
<SignedIn>
2941
<div className="flex gap-2 items-center">
30-
<NavLink href={"/upload"}>Upload a PDF</NavLink>
42+
<NavLink href={"/upload"}>
43+
<span className="flex items-center gap-1">
44+
<Upload className="!size-4" />
45+
Upload a PDF
46+
</span>
47+
</NavLink>
3148
<UserPlanBadge />
3249
<SignedIn>
3350
<UserButton />
3451
</SignedIn>
3552
</div>
3653
</SignedIn>
3754
<SignedOut>
38-
<NavLink href={"/sign-in"}>Sign In</NavLink>
55+
<NavLink href={"/sign-in"}>
56+
<span className="flex items-center gap-1">
57+
<User className="!size-4" />
58+
Sign In
59+
</span>
60+
</NavLink>
3961
</SignedOut>
4062
</div>
4163
</nav>

components/common/nav-links.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const NavLink = ({ href, children, className }: NavLinkProps) => {
1818
<Link
1919
href={href}
2020
className={cn(
21-
"text-sm transition-colors text-gray-600 hover:text-rose-500",
21+
"text-sm font-medium transition-colors text-gray-600 hover:text-rose-500",
2222
className,
2323
isActive && "text-rose-500"
2424
)}

components/summary/source-information.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const SourceInfo = ({
1919
<div className="flex flex-col lg:flex-row items-center justify-between gap-4 text-sm text-muted-foreground">
2020
<div className="flex items-center justify-center gap-2">
2121
<FileText className="!size-4 text-rose-400" />
22-
<span>Source: {fileName}</span>
22+
<span className="font-medium">Source: {fileName}</span>
2323
</div>
2424
<div className="flex gap-2">
2525
<Button
@@ -33,7 +33,7 @@ export const SourceInfo = ({
3333
View Original
3434
</a>
3535
</Button>
36-
<DownloadSummaryButton
36+
<DownloadSummaryButton
3737
fileName={fileName}
3838
title={title}
3939
summaryText={summaryText}

components/summary/summary-download.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Generated by Saaransh
4242
return (
4343
<Button
4444
size={"sm"}
45-
className="h-8 px-3 bg-rose-100 text-rose-600 hover:bg-rose-50 hover:text-rose-700 hover:shadow-md"
45+
className="h-8 px-3 bg-rose-100 text-rose-600 hover:bg-rose-50 hover:text-rose-700 hover:shadow-md transition-all duration-300"
4646
onClick={handleSummaryDownload}
4747
>
4848
<Download className="!size-4 mr-1" />

components/summary/summary-headersection.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Link from "next/link";
22
import { Button } from "@/components/ui/button";
33
import { Calendar, ChevronLeftIcon, Clock, Sparkles } from "lucide-react";
4-
import { Badge } from "@/components/ui/badge";
54

65
export const SummaryHeader = ({
76
title,
@@ -15,14 +14,15 @@ export const SummaryHeader = ({
1514
return (
1615
<div className="flex gap-4 mb-4 justify-between">
1716
<div className="space-y-6">
18-
<div className="flex flex-wrap items-center gap-4">
19-
<Badge
20-
variant={"secondary"}
21-
className="relative px-4 py-1.5 text-sm font-medium bg-white/80 backdrop-blur-xs rounded-full hover:bg-white/90 transition-all duration-200 shadow-xs hover:shadow-md"
22-
>
23-
<Sparkles className="!size-4 mr-1.5 text-rose-500 animate-pulse" />
24-
AI Summary
25-
</Badge>
17+
<div className="flex flex-wrap items-center gap-4 text-sm ml-3">
18+
<div className="transition-all duration-300 hover:scale-105 cursor-pointer">
19+
<div className="p-0.5 animate-rotate-border bg-conic/[from_var(--border-angle)] from-emerald-400 via-rose-400 to-emerald-400 rounded-lg">
20+
<span className="w-fit rounded-lg bg-white flex gap-1 items-center text-slate-700 font-semibold px-2 py-1">
21+
<Sparkles className="!size-4 mr-1.5 text-rose-500 animate-pulse" />
22+
AI Summary
23+
</span>
24+
</div>
25+
</div>
2626
<div className="flex items-center gap-1.5 text-xs sm:text-sm text-muted-foreground">
2727
<Calendar className="!size-4 text-rose-400" />
2828
{new Date(createdAt).toLocaleDateString("en-US", {

components/upload/upload-form.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export const UploadForm = () => {
3535

3636
const { startUpload } = useUploadThing("pdfUploader", {
3737
onClientUploadComplete: () => {
38-
toast.message("PDFUploaded successfully!");
38+
toast.message(
39+
<span className="text-rose-400">Pdf Uploaded successfully!</span>
40+
);
3941
},
4042
onUploadError: (err) => {
4143
toast.error("Error occurred while uploading!", {
@@ -99,13 +101,16 @@ export const UploadForm = () => {
99101
// call the AI service
100102
const formattedFileName = formatFileNameAsTitle(file.name);
101103

102-
toast.message(<span className="text-indigo-500">🔍 Parsing PDF</span>, {
103-
description: (
104-
<span className="text-rose-400 font-medium">
105-
We are parsing your PDF, this may take a few seconds
106-
</span>
107-
),
108-
});
104+
toast.message(
105+
<span className="text-indigo-500">🔍 Parsing Content From PDF</span>,
106+
{
107+
description: (
108+
<span className="text-rose-400 font-medium">
109+
We are parsing content from your PDF, this may take a few seconds
110+
</span>
111+
),
112+
}
113+
);
109114

110115
const result = await generatePdfText({
111116
fileUrl: resp[0].serverData.file.url,

lib/user.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const getPriceIdByEmail = async (email: string) => {
44
const sql = await getDatabaseConnection();
55

66
const query =
7-
await sql`SELECT price_id FROM users where email = ${email} AND status = 'active'`;
7+
await sql`SELECT price_id FROM users where email = ${email} AND status = 'active' ORDER BY created_at DESC LIMIT 1`;
88

99
return query?.[0]?.price_id || null;
1010
};

next.config.ts

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
/* config options here */
5-
images: {
6-
unoptimized: true,
7-
},
85
};
96

107
export default nextConfig;

0 commit comments

Comments
 (0)