Skip to content

Commit 7f0d641

Browse files
Merge pull request #2 from cloudshopt/dev
Dev
2 parents 71c83f8 + 4030206 commit 7f0d641

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/layouts/AppLayout.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useRoute } from "vue-router";
55
const route = useRoute();
66
77
const isProducts = computed(() => route.path.startsWith("/products"));
8+
const isOrders = computed(() => route.path.startsWith("/orders"));
89
910
const linkClass = (active: boolean) =>
1011
[
@@ -35,6 +36,13 @@ const linkClass = (active: boolean) =>
3536
Products
3637
</router-link>
3738

39+
<router-link
40+
to="/orders"
41+
:class="linkClass(isOrders)"
42+
>
43+
Orders
44+
</router-link>
45+
3846
<!-- placeholder za kasneje -->
3947
<button
4048
class="px-3 py-2 rounded-lg text-sm text-zinc-700 hover:bg-zinc-100 transition"

src/pages/OrdersPage.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script setup lang="ts">
2+
import { onMounted, ref } from "vue";
3+
4+
const items = ref<any[]>([]);
5+
const loading = ref(true);
6+
7+
onMounted(async () => {
8+
try {
9+
const r = await fetch("/api/orders/orders", {
10+
headers: { Accept: "application/json" },
11+
});
12+
items.value = await r.json();
13+
} finally {
14+
loading.value = false;
15+
}
16+
});
17+
</script>
18+
19+
<template>
20+
<div class="flex items-end justify-between mb-6">
21+
<div>
22+
<h1 class="text-2xl font-semibold">Orderss</h1>
23+
<p class="text-sm text-zinc-500">Check all orders</p>
24+
</div>
25+
26+
<div class="text-sm text-zinc-500">
27+
<!-- placeholder -->
28+
<span class="px-2 py-1 rounded-md bg-zinc-100">v0</span>
29+
</div>
30+
</div>
31+
32+
<div>
33+
<h1 class="text-2xl font-semibold mb-4">Orders</h1>
34+
35+
<div v-if="loading">Loading…</div>
36+
37+
<div v-else class="grid grid-cols-1 md:grid-cols-3 gap-4">
38+
<router-link
39+
v-for="p in items"
40+
:key="p.id"
41+
:to="`/products/${p.id}`"
42+
class="rounded-xl border p-4 hover:shadow"
43+
>
44+
<div class="font-medium">{{ p.name }}</div>
45+
<div class="text-sm opacity-70">{{ p.total_cost }} {{ p.currency }}</div>
46+
</router-link>
47+
</div>
48+
</div>
49+
</template>

src/router.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { createRouter, createWebHistory } from "vue-router";
33
import ProductsPage from "./pages/ProductsPage.vue";
44
import ProductDetailPage from "./pages/ProductDetailPage.vue";
55
import NotFoundPage from "./pages/NotFoundPage.vue";
6+
import OrdersPage from "./pages/OrdersPage.vue";
67

78
const router = createRouter({
89
history: createWebHistory(),
910
routes: [
1011
{ path: "/", redirect: "/products" },
1112
{ path: "/products", component: ProductsPage },
1213
{ path: "/products/:id", component: ProductDetailPage, props: true },
14+
{ path: "/orders", component: OrdersPage },
1315
{ path: "/:pathMatch(.*)*", component: NotFoundPage }
1416
],
1517
});

0 commit comments

Comments
 (0)