Skip to content

Commit d9e0380

Browse files
committed
integrated new trial search functionality. Added a detailed trial search page with advanced filters and UI enhancements, including a user-friendly search interface and error handling.
Took 55 seconds
1 parent 5eb88be commit d9e0380

File tree

25 files changed

+4799
-76
lines changed

25 files changed

+4799
-76
lines changed

app/dfda/claude/page.tsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

app/dfda/cost-savings.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface CostItem {
2+
name: string
3+
currentCost: number
4+
currentExplanation: string
5+
newCost: number
6+
reductionExplanation: string
7+
remainingExplanation: string
8+
emoji?: string
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Metadata } from "next"
2+
3+
import MarkdownFileRenderer from "@/components/MarkdownFileRenderer"
4+
5+
export const metadata: Metadata = {
6+
title: "Docs",
7+
description: "Info about the project",
8+
}
9+
10+
interface DocsProps {
11+
params: { filename: string }
12+
}
13+
14+
export default async function Docs({ params }: DocsProps) {
15+
let { filename } = params
16+
// implode filename to string if it's an array
17+
if (Array.isArray(filename)) {
18+
filename = filename.join("/")
19+
}
20+
console.log(`filename: ${filename}`)
21+
filename = filename.replace(/\.md$/, "")
22+
return <MarkdownFileRenderer url={`/${filename}.md`} />
23+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use client'
2+
3+
import { useState } from 'react'
4+
import dynamic from 'next/dynamic'
5+
6+
const MarkdownModal = dynamic(() => import('@/components/markdown-modal'), {
7+
ssr: false
8+
})
9+
10+
interface MarkdownFile {
11+
path: string
12+
content: string
13+
title: string
14+
}
15+
16+
export function FileLink({ file }: { file: MarkdownFile }) {
17+
const [isModalOpen, setIsModalOpen] = useState(false)
18+
19+
return (
20+
<>
21+
<div className="hover:bg-neutral-50 rounded p-2">
22+
<button
23+
onClick={() => setIsModalOpen(true)}
24+
className="text-primary hover:text-primary/80 text-left w-full"
25+
>
26+
{file.title}
27+
</button>
28+
</div>
29+
<MarkdownModal
30+
isOpen={isModalOpen}
31+
onClose={() => setIsModalOpen(false)}
32+
content={file.content}
33+
title={file.title}
34+
/>
35+
</>
36+
)
37+
}

app/dfda/docs/page.tsx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { Shell } from "@/components/layout/shell"
2+
import { readdir, stat, readFile } from "fs/promises"
3+
import path from "path"
4+
import { FileLink } from "./components/file-link"
5+
6+
interface MarkdownFile {
7+
path: string
8+
content: string
9+
title: string // Extracted from first heading or filename
10+
}
11+
12+
// Helper function to extract title from markdown content
13+
function extractTitle(content: string, fallbackPath: string): string {
14+
// Try to find the first heading
15+
const headingMatch = content.match(/^#\s+(.+)$/m)
16+
if (headingMatch) {
17+
return headingMatch[1]
18+
}
19+
20+
// Fallback to filename without extension and path
21+
const fileName = path.basename(fallbackPath, '.md')
22+
return fileName
23+
.split('-')
24+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
25+
.join(' ')
26+
}
27+
28+
// Helper function to recursively get markdown files
29+
async function getMarkdownFiles(dir: string): Promise<MarkdownFile[]> {
30+
const files = await readdir(dir)
31+
const markdownFiles: MarkdownFile[] = []
32+
33+
for (const file of files) {
34+
const filePath = path.join(dir, file)
35+
const stats = await stat(filePath)
36+
37+
if (stats.isDirectory()) {
38+
const nestedFiles = await getMarkdownFiles(filePath)
39+
markdownFiles.push(...nestedFiles)
40+
} else if (file.endsWith('.md')) {
41+
const content = await readFile(filePath, 'utf-8')
42+
const relativePath = path.relative(
43+
path.join(process.cwd(), 'public/globalSolutions/dfda'),
44+
filePath
45+
)
46+
markdownFiles.push({
47+
path: relativePath,
48+
content,
49+
title: extractTitle(content, relativePath)
50+
})
51+
}
52+
}
53+
54+
return markdownFiles
55+
}
56+
57+
export default async function MarkdownPageListPage() {
58+
const baseDir = path.join(process.cwd(), 'public/globalSolutions/dfda')
59+
const markdownFiles = await getMarkdownFiles(baseDir)
60+
61+
return (
62+
<Shell>
63+
<div className="mx-auto max-w-4xl py-8">
64+
<h1 className="text-3xl font-bold mb-8">Documentation</h1>
65+
<div className="space-y-4">
66+
{Object.entries(
67+
markdownFiles.reduce((acc: Record<string, MarkdownFile[]>, file) => {
68+
const dirPath = path.dirname(file.path)
69+
if (!acc[dirPath]) {
70+
acc[dirPath] = []
71+
}
72+
acc[dirPath].push(file)
73+
return acc
74+
}, {})
75+
).map(([dirPath, files]) => (
76+
<div key={dirPath} className="border rounded-lg p-4 border-border">
77+
<h2 className="text-xl font-semibold mb-3">
78+
{dirPath === '.' ? 'Root' : dirPath}
79+
</h2>
80+
<div className="pl-4 space-y-2">
81+
{files.map((file: MarkdownFile) => (
82+
<FileLink key={file.path} file={file} />
83+
))}
84+
</div>
85+
</div>
86+
))}
87+
</div>
88+
</div>
89+
</Shell>
90+
)
91+
}

0 commit comments

Comments
 (0)