blob: 40e5cf1265473c9ddb798119fc45d0511b3fc8aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
---
import Header from '../components/Header.astro';
import Container from '../components/Container.astro';
import { getCart } from '../api';
if (!Astro.cookies.get('user-id')) {
return Astro.redirect('/');
}
// They must be logged in.
const user = { name: 'test' }; // getUser?
const cart = await getCart(Astro.request);
---
<html lang="en">
<head>
<title>Cart | Online Store</title>
<style>
h1 {
font-size: 36px;
}
</style>
</head>
<body>
<Header />
<Container tag="main">
<h1>Cart</h1>
<p>Hi {user.name}! Here are your cart items:</p>
<table>
<thead>
<tr>
<th>Item</th>
<th>Count</th>
</tr>
</thead>
<tbody>
{
cart.items.map((item) => (
<tr>
<td>{item.name}</td>
<td>{item.count}</td>
</tr>
))
}
</tbody>
</table>
</Container>
</body>
</html>
|