mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-25 05:35:53 +00:00
Merge branch 'main' into update
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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 |
Reference in New Issue
Block a user