mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-15 20:01:38 +00:00
Merge branch 'add-starting-example-2' of https://github.com/vercel/next-learn into add-starting-example-2
This commit is contained in:
@@ -9,12 +9,11 @@ import {
|
||||
Revenue,
|
||||
} from './definitions';
|
||||
import { formatCurrency } from './utils';
|
||||
import { unstable_noStore as noStore } from 'next/cache';
|
||||
|
||||
export async function fetchRevenue() {
|
||||
// Add noStore() here prevent the response from being cached.
|
||||
// This is equivalent to in fetch(..., {cache: 'no-store'}).
|
||||
noStore();
|
||||
|
||||
try {
|
||||
// Artificially delay a reponse for demo purposes.
|
||||
// Don't do this in real life :)
|
||||
@@ -34,7 +33,6 @@ export async function fetchRevenue() {
|
||||
}
|
||||
|
||||
export async function fetchLatestInvoices() {
|
||||
noStore();
|
||||
try {
|
||||
const data = await sql<LatestInvoiceRaw>`
|
||||
SELECT invoices.amount, customers.name, customers.image_url, customers.email, invoices.id
|
||||
@@ -55,7 +53,6 @@ export async function fetchLatestInvoices() {
|
||||
}
|
||||
|
||||
export async function fetchCardData() {
|
||||
noStore();
|
||||
try {
|
||||
// You can probably combine these into a single SQL query
|
||||
// However, we are intentionally splitting them to demonstrate
|
||||
@@ -95,7 +92,6 @@ export async function fetchFilteredInvoices(
|
||||
query: string,
|
||||
currentPage: number,
|
||||
) {
|
||||
noStore();
|
||||
const offset = (currentPage - 1) * ITEMS_PER_PAGE;
|
||||
|
||||
try {
|
||||
@@ -128,7 +124,6 @@ export async function fetchFilteredInvoices(
|
||||
}
|
||||
|
||||
export async function fetchInvoicesPages(query: string) {
|
||||
noStore();
|
||||
try {
|
||||
const count = await sql`SELECT COUNT(*)
|
||||
FROM invoices
|
||||
@@ -193,7 +188,6 @@ export async function fetchCustomers() {
|
||||
}
|
||||
|
||||
export async function fetchFilteredCustomers(query: string) {
|
||||
noStore();
|
||||
try {
|
||||
const data = await sql<CustomersTable>`
|
||||
SELECT
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import {
|
||||
UserGroupIcon,
|
||||
HomeIcon,
|
||||
DocumentDuplicateIcon,
|
||||
} from '@heroicons/react/24/outline';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import clsx from 'clsx';
|
||||
|
||||
// Map of links to display in the side navigation.
|
||||
@@ -22,26 +18,21 @@ const links = [
|
||||
];
|
||||
|
||||
export default function NavLinks() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<>
|
||||
{links.map((link) => {
|
||||
const LinkIcon = link.icon;
|
||||
return (
|
||||
<Link
|
||||
<a
|
||||
key={link.name}
|
||||
href={link.href}
|
||||
className={clsx(
|
||||
'flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3',
|
||||
{
|
||||
'bg-sky-100 text-blue-600': pathname === link.href,
|
||||
},
|
||||
)}
|
||||
>
|
||||
<LinkIcon className="w-6" />
|
||||
<p className="hidden md:block">{link.name}</p>
|
||||
</Link>
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
"dev": "next dev",
|
||||
"seed": "node -r dotenv/config ./scripts/seed.js",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user