Merge branch 'main' into update

This commit is contained in:
Delba de Oliveira
2023-10-19 08:30:46 -07:00
8 changed files with 38 additions and 5 deletions

View File

@@ -1,5 +1,10 @@
import { fetchFilteredCustomers } from '@/app/lib/data';
import CustomersTable from '@/app/ui/customers/table';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Customers',
};
export default async function Page({
searchParams,

View File

@@ -2,6 +2,11 @@ import Form from '@/app/ui/invoices/edit-form';
import Breadcrumbs from '@/app/ui/invoices/breadcrumbs';
import { fetchInvoiceById, fetchCustomers } from '@/app/lib/data';
import { notFound } from 'next/navigation';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Edit Invoice',
};
export default async function Page({ params }: { params: { id: string } }) {
const id = params.id;

View File

@@ -1,6 +1,11 @@
import { fetchCustomers } from '@/app/lib/data';
import Form from '@/app/ui/invoices/create-form';
import Breadcrumbs from '@/app/ui/invoices/breadcrumbs';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Create Invoice',
};
export default async function Page() {
const customers = await fetchCustomers();

View File

@@ -6,6 +6,11 @@ import { lusitana } from '@/app/ui/fonts';
import { InvoicesTableSkeleton } from '@/app/ui/dashboard/skeletons';
import { Suspense } from 'react';
import { fetchInvoicesPages } from '@/app/lib/data';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Invoices',
};
export default async function Page({
searchParams,

View File

@@ -1,11 +1,13 @@
import '@/app/ui/global.css';
import { inter } from '@/app/ui/fonts';
import type { Metadata } from 'next';
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Next.js Dashboard',
description: 'Built as part of nextjs.org/learn.',
metadataBase: new URL('https://next-learn-dashboard.vercel.sh'),
title: {
template: '%s | Acme Dashboard',
default: 'Acme Dashboard',
},
description: 'The official Next.js Learn Dashboard built with App Router.',
};
export default function RootLayout({

View File

@@ -67,7 +67,7 @@ export async function createInvoice(prevState: State, formData: FormData) {
};
}
// Revalidate cache and redirect user to invoices page
// Revalidate the cache for the invoices page and redirect the user.
revalidatePath('/dashboard/invoices');
redirect('/dashboard/invoices');
}

View File

@@ -5,6 +5,7 @@ import {
InvoiceForm,
InvoicesTable,
LatestInvoiceRaw,
User,
Revenue,
} from './definitions';
import { formatCurrency } from './utils';
@@ -290,3 +291,13 @@ export async function fetchFilteredCustomers(query: string) {
throw new Error('Failed to fetch customer table.');
}
}
export async function getUser(email: string) {
try {
const user = await sql`SELECT * from USERS where email=${email}`;
return user.rows[0] as User;
} catch (error) {
console.error('Failed to fetch user:', error);
throw new Error('Failed to fetch user.');
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 238 KiB