diff --git a/app/dashboard/expenses/page.tsx b/app/dashboard/expenses/page.tsx
new file mode 100644
index 0000000..7d656a0
--- /dev/null
+++ b/app/dashboard/expenses/page.tsx
@@ -0,0 +1,11 @@
+import { lusitana } from '@/app/ui/fonts';
+
+export default function Page () {
+ return (
+
+
+
Expenses
+
+
+ );
+}
\ No newline at end of file
diff --git a/app/dashboard/guests/page.tsx b/app/dashboard/guests/page.tsx
new file mode 100644
index 0000000..4a4cb1e
--- /dev/null
+++ b/app/dashboard/guests/page.tsx
@@ -0,0 +1,11 @@
+import { lusitana } from '@/app/ui/fonts';
+
+export default function Page () {
+ return (
+
+
+
Guests
+
+
+ );
+}
\ No newline at end of file
diff --git a/app/dashboard/layout.tsx b/app/dashboard/layout.tsx
new file mode 100644
index 0000000..79bd4c3
--- /dev/null
+++ b/app/dashboard/layout.tsx
@@ -0,0 +1,12 @@
+import SideNav from '@/app/ui/dashboard/sidenav';
+
+export default function Layout({ children }: { children: React.ReactNode }) {
+ return (
+
+
+
+
+
{children}
+
+ );
+}
\ No newline at end of file
diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx
new file mode 100644
index 0000000..c820d9f
--- /dev/null
+++ b/app/dashboard/page.tsx
@@ -0,0 +1,3 @@
+export default function Page() {
+ return
Dashboard Page
;
+}
\ No newline at end of file
diff --git a/app/dashboard/tables/page.tsx b/app/dashboard/tables/page.tsx
new file mode 100644
index 0000000..81c472e
--- /dev/null
+++ b/app/dashboard/tables/page.tsx
@@ -0,0 +1,11 @@
+import { lusitana } from '@/app/ui/fonts';
+
+export default function Page () {
+ return (
+
+
+
Table distributions
+
+
+ );
+}
\ No newline at end of file
diff --git a/app/layout.tsx b/app/layout.tsx
index 225b603..e18935c 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,3 +1,6 @@
+import '@/app/ui/global.css'
+import { inter } from '@/app/ui/fonts';
+
export default function RootLayout({
children,
}: {
@@ -5,7 +8,7 @@ export default function RootLayout({
}) {
return (
- {children}
+ {children}
);
}
diff --git a/app/lib/data.ts b/app/lib/data.ts
deleted file mode 100644
index edb4964..0000000
--- a/app/lib/data.ts
+++ /dev/null
@@ -1,217 +0,0 @@
-import { sql } from '@vercel/postgres';
-import {
- CustomerField,
- CustomersTableType,
- InvoiceForm,
- InvoicesTable,
- LatestInvoiceRaw,
- Revenue,
-} from './definitions';
-import { formatCurrency } from './utils';
-
-export async function fetchRevenue() {
- try {
- // Artificially delay a response for demo purposes.
- // Don't do this in production :)
-
- // console.log('Fetching revenue data...');
- // await new Promise((resolve) => setTimeout(resolve, 3000));
-
- const data = await sql`SELECT * FROM revenue`;
-
- // console.log('Data fetch completed after 3 seconds.');
-
- return data.rows;
- } catch (error) {
- console.error('Database Error:', error);
- throw new Error('Failed to fetch revenue data.');
- }
-}
-
-export async function fetchLatestInvoices() {
- try {
- const data = await sql`
- SELECT invoices.amount, customers.name, customers.image_url, customers.email, invoices.id
- FROM invoices
- JOIN customers ON invoices.customer_id = customers.id
- ORDER BY invoices.date DESC
- LIMIT 5`;
-
- const latestInvoices = data.rows.map((invoice) => ({
- ...invoice,
- amount: formatCurrency(invoice.amount),
- }));
- return latestInvoices;
- } catch (error) {
- console.error('Database Error:', error);
- throw new Error('Failed to fetch the latest invoices.');
- }
-}
-
-export async function fetchCardData() {
- try {
- // You can probably combine these into a single SQL query
- // However, we are intentionally splitting them to demonstrate
- // how to initialize multiple queries in parallel with JS.
- const invoiceCountPromise = sql`SELECT COUNT(*) FROM invoices`;
- const customerCountPromise = sql`SELECT COUNT(*) FROM customers`;
- const invoiceStatusPromise = sql`SELECT
- SUM(CASE WHEN status = 'paid' THEN amount ELSE 0 END) AS "paid",
- SUM(CASE WHEN status = 'pending' THEN amount ELSE 0 END) AS "pending"
- FROM invoices`;
-
- const data = await Promise.all([
- invoiceCountPromise,
- customerCountPromise,
- invoiceStatusPromise,
- ]);
-
- const numberOfInvoices = Number(data[0].rows[0].count ?? '0');
- const numberOfCustomers = Number(data[1].rows[0].count ?? '0');
- const totalPaidInvoices = formatCurrency(data[2].rows[0].paid ?? '0');
- const totalPendingInvoices = formatCurrency(data[2].rows[0].pending ?? '0');
-
- return {
- numberOfCustomers,
- numberOfInvoices,
- totalPaidInvoices,
- totalPendingInvoices,
- };
- } catch (error) {
- console.error('Database Error:', error);
- throw new Error('Failed to fetch card data.');
- }
-}
-
-const ITEMS_PER_PAGE = 6;
-export async function fetchFilteredInvoices(
- query: string,
- currentPage: number,
-) {
- const offset = (currentPage - 1) * ITEMS_PER_PAGE;
-
- try {
- const invoices = await sql`
- SELECT
- invoices.id,
- invoices.amount,
- invoices.date,
- invoices.status,
- customers.name,
- customers.email,
- customers.image_url
- FROM invoices
- JOIN customers ON invoices.customer_id = customers.id
- WHERE
- customers.name ILIKE ${`%${query}%`} OR
- customers.email ILIKE ${`%${query}%`} OR
- invoices.amount::text ILIKE ${`%${query}%`} OR
- invoices.date::text ILIKE ${`%${query}%`} OR
- invoices.status ILIKE ${`%${query}%`}
- ORDER BY invoices.date DESC
- LIMIT ${ITEMS_PER_PAGE} OFFSET ${offset}
- `;
-
- return invoices.rows;
- } catch (error) {
- console.error('Database Error:', error);
- throw new Error('Failed to fetch invoices.');
- }
-}
-
-export async function fetchInvoicesPages(query: string) {
- try {
- const count = await sql`SELECT COUNT(*)
- FROM invoices
- JOIN customers ON invoices.customer_id = customers.id
- WHERE
- customers.name ILIKE ${`%${query}%`} OR
- customers.email ILIKE ${`%${query}%`} OR
- invoices.amount::text ILIKE ${`%${query}%`} OR
- invoices.date::text ILIKE ${`%${query}%`} OR
- invoices.status ILIKE ${`%${query}%`}
- `;
-
- const totalPages = Math.ceil(Number(count.rows[0].count) / ITEMS_PER_PAGE);
- return totalPages;
- } catch (error) {
- console.error('Database Error:', error);
- throw new Error('Failed to fetch total number of invoices.');
- }
-}
-
-export async function fetchInvoiceById(id: string) {
- try {
- const data = await sql`
- SELECT
- invoices.id,
- invoices.customer_id,
- invoices.amount,
- invoices.status
- FROM invoices
- WHERE invoices.id = ${id};
- `;
-
- const invoice = data.rows.map((invoice) => ({
- ...invoice,
- // Convert amount from cents to dollars
- amount: invoice.amount / 100,
- }));
-
- return invoice[0];
- } catch (error) {
- console.error('Database Error:', error);
- throw new Error('Failed to fetch invoice.');
- }
-}
-
-export async function fetchCustomers() {
- try {
- const data = await sql`
- SELECT
- id,
- name
- FROM customers
- ORDER BY name ASC
- `;
-
- const customers = data.rows;
- return customers;
- } catch (err) {
- console.error('Database Error:', err);
- throw new Error('Failed to fetch all customers.');
- }
-}
-
-export async function fetchFilteredCustomers(query: string) {
- try {
- const data = await sql`
- SELECT
- customers.id,
- customers.name,
- customers.email,
- customers.image_url,
- COUNT(invoices.id) AS total_invoices,
- SUM(CASE WHEN invoices.status = 'pending' THEN invoices.amount ELSE 0 END) AS total_pending,
- SUM(CASE WHEN invoices.status = 'paid' THEN invoices.amount ELSE 0 END) AS total_paid
- FROM customers
- LEFT JOIN invoices ON customers.id = invoices.customer_id
- WHERE
- customers.name ILIKE ${`%${query}%`} OR
- customers.email ILIKE ${`%${query}%`}
- GROUP BY customers.id, customers.name, customers.email, customers.image_url
- ORDER BY customers.name ASC
- `;
-
- const customers = data.rows.map((customer) => ({
- ...customer,
- total_pending: formatCurrency(customer.total_pending),
- total_paid: formatCurrency(customer.total_paid),
- }));
-
- return customers;
- } catch (err) {
- console.error('Database Error:', err);
- throw new Error('Failed to fetch customer table.');
- }
-}
diff --git a/app/lib/definitions.ts b/app/lib/definitions.ts
index b1a4fbf..3f601a9 100644
--- a/app/lib/definitions.ts
+++ b/app/lib/definitions.ts
@@ -44,7 +44,7 @@ export type LatestInvoiceRaw = Omit & {
amount: number;
};
-export type InvoicesTable = {
+export type guestsTable = {
id: string;
customer_id: string;
name: string;
@@ -60,7 +60,7 @@ export type CustomersTableType = {
name: string;
email: string;
image_url: string;
- total_invoices: number;
+ total_guests: number;
total_pending: number;
total_paid: number;
};
@@ -70,7 +70,7 @@ export type FormattedCustomersTable = {
name: string;
email: string;
image_url: string;
- total_invoices: number;
+ total_guests: number;
total_pending: string;
total_paid: string;
};
diff --git a/app/lib/placeholder-data.ts b/app/lib/placeholder-data.ts
index 257fb14..76892d5 100644
--- a/app/lib/placeholder-data.ts
+++ b/app/lib/placeholder-data.ts
@@ -48,7 +48,7 @@ const customers = [
},
];
-const invoices = [
+const guests = [
{
customer_id: customers[0].id,
amount: 15795,
@@ -144,4 +144,4 @@ const revenue = [
{ month: 'Dec', revenue: 4800 },
];
-export { users, customers, invoices, revenue };
+export { users, customers, guests, revenue };
diff --git a/app/page.tsx b/app/page.tsx
index 8e0184f..ce4a8cf 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,33 +1,10 @@
-import AcmeLogo from '@/app/ui/acme-logo';
-import { ArrowRightIcon } from '@heroicons/react/24/outline';
import Link from 'next/link';
+import styles from '@/app/ui/home.module.css';
export default function Page() {
return (
-
- {/* */}
-
-
-
-
- Welcome to Acme. This is the example for the{' '}
-
- Next.js Learn Course
-
- , brought to you by Vercel.
-
-
- Log in
-
-
-
- {/* Add Hero Images Here */}
-
-
+
);
}
diff --git a/app/seed/route.ts b/app/seed/route.ts
index ce31c7a..944672c 100644
--- a/app/seed/route.ts
+++ b/app/seed/route.ts
@@ -1,6 +1,6 @@
// import bcrypt from 'bcrypt';
// import { db } from '@vercel/postgres';
-// import { invoices, customers, revenue, users } from '../lib/placeholder-data';
+// import { guests, customers, revenue, users } from '../lib/placeholder-data';
// const client = await db.connect();
@@ -29,11 +29,11 @@
// return insertedUsers;
// }
-// async function seedInvoices() {
+// async function seedguests() {
// await client.sql`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`;
// await client.sql`
-// CREATE TABLE IF NOT EXISTS invoices (
+// CREATE TABLE IF NOT EXISTS guests (
// id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
// customer_id UUID NOT NULL,
// amount INT NOT NULL,
@@ -42,17 +42,17 @@
// );
// `;
-// const insertedInvoices = await Promise.all(
-// invoices.map(
+// const insertedguests = await Promise.all(
+// guests.map(
// (invoice) => client.sql`
-// INSERT INTO invoices (customer_id, amount, status, date)
+// INSERT INTO guests (customer_id, amount, status, date)
// VALUES (${invoice.customer_id}, ${invoice.amount}, ${invoice.status}, ${invoice.date})
// ON CONFLICT (id) DO NOTHING;
// `,
// ),
// );
-// return insertedInvoices;
+// return insertedguests;
// }
// async function seedCustomers() {
@@ -110,7 +110,7 @@ export async function GET() {
// await client.sql`BEGIN`;
// await seedUsers();
// await seedCustomers();
- // await seedInvoices();
+ // await seedguests();
// await seedRevenue();
// await client.sql`COMMIT`;
diff --git a/app/ui/customers/table.tsx b/app/ui/customers/table.tsx
index fce2f55..190a43d 100644
--- a/app/ui/customers/table.tsx
+++ b/app/ui/customers/table.tsx
@@ -57,7 +57,7 @@ export default async function CustomersTable({