Skip to content

Commit 942b191

Browse files
ee added legal settings and credits
1 parent 957fb2c commit 942b191

File tree

6 files changed

+86
-20
lines changed

6 files changed

+86
-20
lines changed

src/app/auth/layout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect } from "react"
55
import { checkAuth } from "../console/actions"
66
import { redirect } from "next/navigation"
77
import Image from "next/image"
8+
import Link from "next/link"
89

910
export default function AuthLayout({ children }: { children: React.ReactNode }) {
1011

@@ -31,6 +32,11 @@ export default function AuthLayout({ children }: { children: React.ReactNode })
3132
{children}
3233
</CardContent>
3334
</Card>
35+
<div className="absolute bottom-5 right-5 flex gap-3 items-center">
36+
<Link href="/ee/legal/privacy-policy">Privacy Policy</Link>
37+
<Link href="/ee/legal/refund-policy">Refund Policy</Link>
38+
<Link href="/ee/legal/terms-of-service">Terms of Service</Link>
39+
</div>
3440
</div>
3541
)
3642
}

src/app/console/ee/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ export async function getPlans() {
4747
return [
4848
{
4949
name: "FREE",
50-
price: "0",
50+
price: "$0",
5151
credits: "1000",
5252
for: "lifetime",
5353
purchaseUrl: "",
5454
},
5555
{
5656
name: "PRO_MONTHLY",
57-
price: "35",
57+
price: "$35",
5858
credits: "15000",
5959
for: "monthly",
6060
purchaseUrl: "", // TODO: Stripe Link
6161
},
6262
{
6363
name: "PRO_YEARLY",
64-
price: "350",
64+
price: "$350",
6565
credits: "15000",
6666
for: "yearly",
6767
purchaseUrl: "", // TODO: Stripe Link

src/app/console/ee/billing.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function BillingComponent({ billingState }: { billingState: Billi
1717
purchaseUrl: string
1818
}
1919

20-
const [billing, setBilling] = useState<Billing | null>(billingState)
20+
const [billing, setBilling] = useState<Billing>(billingState)
2121
const [plans, setPlans] = useState<Plan[]>([])
2222
const { toast } = useToast()
2323
const router = useRouter()
@@ -33,7 +33,9 @@ export default function BillingComponent({ billingState }: { billingState: Billi
3333

3434
const fetchBilling = async () => {
3535
const billing = await getBillingAndCreateIfNotExists()
36-
setBilling(billing)
36+
if (billing) {
37+
setBilling(billing)
38+
}
3739
}
3840

3941
const planButtonText = (plan: Plan) => {
@@ -88,19 +90,29 @@ export default function BillingComponent({ billingState }: { billingState: Billi
8890

8991
return (
9092
<div>
91-
{/* TODO: Billing goes here */}
92-
{plans.map((plan, index) => (
93-
<div key={`plan-${index}`} className="flex justify-between items-center p-2 rounded-md border-b-[1px] border-gray-200">
94-
<div className="flex items-center gap-3">
95-
<p className="text-xl flex items-center gap-2 font-bold">{plan.price} / {plan.for}</p>
93+
<p className="text-lg font-bold mt-5">Available Credits: {billing.credits}</p>
94+
<div className="space-y-3 mt-2">
95+
{plans.map((plan, index) => (
96+
<div key={`plan-${index}`} className="flex justify-between items-center p-5 rounded-md border-[1px] border-gray-200">
9697
<div className="flex flex-col gap-1">
97-
<p className="text-lg">{plan.name}</p>
98-
<p className="text-sm">{plan.credits}/month</p>
98+
<p className="flex items-center gap-2 font-bold">{plan.price} / {plan.for}</p>
99+
<p>{plan.name}</p>
100+
<p className="text-sm">{plan.credits} Credits / month</p>
99101
</div>
102+
<Button
103+
className="w-[150px]"
104+
disabled={planButtonText(plan) === "Current Plan"}
105+
onClick={
106+
() => planButtonText(plan) === "Contact Support" ?
107+
window.location.href = "mailto:support@rowfill.com" :
108+
handlePlanButton(plan)
109+
}
110+
>
111+
{planButtonText(plan)}
112+
</Button>
100113
</div>
101-
<Button disabled={planButtonText(plan) === "Current Plan" || planButtonText(plan) === "Contact Support"} onClick={() => handlePlanButton(plan)}>{planButtonText(plan)}</Button>
102-
</div>
103-
))}
114+
))}
115+
</div>
104116
</div>
105117
)
106118
}

src/app/console/layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { PiDatabaseBold, PiGearBold, PiMagnifyingGlass, PiPlusBold, PiTableBold
66
import { Button } from "@/components/ui/button"
77
import { AddSheetDialog } from './sheetsDialog'
88
import { checkAuth, fetchSheets } from './actions'
9-
import { Sheet } from '@prisma/client'
9+
import { Billing, Sheet } from '@prisma/client'
1010
import { Separator } from '@/components/ui/separator'
1111
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog'
1212
import SettingsPage from './settingsDialog'
@@ -23,13 +23,12 @@ export default function ConsoleLayoutContent({ children }: { children: React.Rea
2323
const pathname = usePathname()
2424
const { dueForRefresh, setDueForRefresh } = useSheetStore()
2525
const [isSearchOpen, setIsSearchOpen] = useState(false)
26+
const [billing, setBilling] = useState<Billing | null>(null)
2627

2728
useEffect(() => {
2829
init()
2930
}, [])
3031

31-
32-
3332
useEffect(() => {
3433
// Check if /sheets/slug pattern is in the pathname
3534
if (sheets.length > 0 && !pathname.includes('/sheets/')) {
@@ -50,7 +49,7 @@ export default function ConsoleLayoutContent({ children }: { children: React.Rea
5049
if (!auth) {
5150
redirect('/auth/login')
5251
}
53-
await getBillingAndCreateIfNotExists()
52+
setBilling(await getBillingAndCreateIfNotExists())
5453
await handleFetchSheets()
5554
}
5655

@@ -92,6 +91,7 @@ export default function ConsoleLayoutContent({ children }: { children: React.Rea
9291
</div>
9392
<div className="flex flex-col gap-2">
9493
<Separator className="my-2" />
94+
{billing && <p className="text-sm font-bold mb-2">Available Credits: {billing.credits}</p>}
9595
<Dialog>
9696
<DialogTrigger asChild>
9797
<Button variant="outline" className="w-full flex justify-start">

src/app/console/settingsDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default function SettingsPage() {
154154
</Card>
155155
</div>
156156
</TabsContent>
157-
{billing && <BillingComponent billingState={billing} />}
157+
{billing && <TabsContent value="billing"><BillingComponent billingState={billing} /></TabsContent>}
158158
</Tabs>
159159
</div>
160160
)

src/app/ee/legal/[slug]/page.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import axios from "axios"
2+
import Image from "next/image"
3+
4+
export default async function LegalPage({ params }: { params: Promise<{ slug: string }> }) {
5+
const { slug } = await params
6+
let legalPageContent = ""
7+
8+
if (!process.env.EE_ENABLED || process.env.EE_ENABLED === "false") {
9+
return (
10+
<div className="flex flex-col gap-5 items-center justify-center h-screen">
11+
<Image src="/logo.svg" alt="404" width={50} height={50} />
12+
<p className="text-lg">You are not authorized to access this page</p>
13+
</div>
14+
)
15+
}
16+
17+
if (slug === "privacy-policy" && process.env.PRIVACY_POLICY_URL) {
18+
const response = await axios.get(process.env.PRIVACY_POLICY_URL || "")
19+
legalPageContent = response.data
20+
}
21+
22+
23+
if (slug === "refund-policy" && process.env.REFUND_POLICY_URL) {
24+
const response = await axios.get(process.env.REFUND_POLICY_URL || "")
25+
legalPageContent = response.data
26+
}
27+
28+
if (slug === "terms-of-service" && process.env.TERMS_OF_SERVICE_URL) {
29+
const response = await axios.get(process.env.TERMS_OF_SERVICE_URL || "")
30+
legalPageContent = response.data
31+
}
32+
33+
if (legalPageContent) {
34+
return (
35+
<div className="p-10">
36+
<Image src="/logo-full.svg" alt="Rowfill" width={150} height={150} />
37+
<div className="mt-10" dangerouslySetInnerHTML={{ __html: legalPageContent }} />
38+
</div>
39+
)
40+
}
41+
42+
return (
43+
<div className="flex flex-col gap-5 items-center justify-center h-screen">
44+
<Image src="/logo.svg" alt="404" width={50} height={50} />
45+
<p className="text-lg">Unable to find the legal page</p>
46+
</div>
47+
)
48+
}

0 commit comments

Comments
 (0)