blob: 3277ff2db99214974ef1ae5a38093f329ffa6d7c (
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
|
---
import Header from '../components/Header.astro';
import Container from '../components/Container.astro';
import { getCart } from '../api';
import { isLoggedIn } from '../models/user';
if(!isLoggedIn(Astro.request)) {
return Astro.redirect('/');
}
// They must be logged in.
const user = { name: 'test'}; // getUser?
const cart = await getCart(Astro.request);
---
<html>
<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>
|