Skip to content

Commit 1f3b39e

Browse files
committed
add FE ListUsers, user component
1 parent 03f30d0 commit 1f3b39e

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<div class="card h-100 w-100">
3+
<div class="card-body">
4+
<router-link :to="{ name: 'ShowDetails', params: { id: user.id } }"
5+
><h5 class="card-title">{{ user.firstName }}</h5></router-link
6+
>
7+
<p class="card-text"><sup>$</sup>{{ user.email }}</p>
8+
<!-- <router-link
9+
id="edit-user"
10+
:to="{ name: 'EditUser', params: { id: RouterLink.id } }"
11+
v-show="$route.name == 'AdminUser'"
12+
>
13+
Edit
14+
</router-link> -->
15+
</div>
16+
</div>
17+
</template>
18+
19+
<!-- NOTE !!!
20+
21+
Will only show product edit button when route name is "AdminProduct"
22+
23+
e.g.
24+
<router-link
25+
id="edit-product"
26+
:to="{ name: 'EditProduct', params: { id: product.id } }"
27+
v-show="$route.name == 'AdminProduct'"
28+
>
29+
Edit
30+
</router-link>
31+
-->
32+
33+
<script>
34+
export default {
35+
name: "UserBox",
36+
props: ["user"],
37+
methods: {
38+
showDetails() {
39+
this.$router.push({
40+
name: "ShowDetails",
41+
params: { id: this.user.id },
42+
});
43+
},
44+
},
45+
};
46+
</script>
47+
48+
<style scoped>
49+
.embed-responsive .card-img-top {
50+
object-fit: cover;
51+
}
52+
53+
a {
54+
text-decoration: none;
55+
}
56+
57+
.card-title {
58+
color: #484848;
59+
font-size: 1.1rem;
60+
font-weight: 400;
61+
}
62+
63+
.card-title:hover {
64+
font-weight: bold;
65+
}
66+
67+
.card-text {
68+
font-size: 0.9rem;
69+
}
70+
71+
#edit-product {
72+
float: right;
73+
}
74+
</style>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<template>
2+
<div class="container">
3+
<div class="row">
4+
<div class="col-12 text-center">
5+
<!-- <h4 class="pt-3">{{ category.categoryName }}</h4> -->
6+
<h1>This is User List</h1>
7+
<h5>{{ msg }}</h5>
8+
</div>
9+
</div>
10+
11+
<div class="row">
12+
<img
13+
v-show="len == 0"
14+
class="img-fluid"
15+
src="../../assets/sorry.jpg"
16+
alt="Sorry"
17+
/>
18+
<div
19+
v-for="product of category.products"
20+
:key="product.id"
21+
class="col-md-6 col-xl-4 col-12 pt-3 justify-content-around d-flex"
22+
>
23+
<UserBox :user="user"> </UserBox>
24+
</div>
25+
</div>
26+
</div>
27+
</template>
28+
29+
<script>
30+
import UserBox from "../../components/User/UserBox";
31+
export default {
32+
name: "ListUsers",
33+
data() {
34+
return {
35+
id: null,
36+
categoryIndex: null,
37+
category: {},
38+
len: 0,
39+
msg: null,
40+
};
41+
},
42+
components: { UserBox },
43+
props: ["baseURL", "categories"],
44+
mounted() {
45+
this.id = this.$route.params.id;
46+
// this.categoryIndex = this.categories.findIndex(
47+
// (category) => category.id == this.id
48+
// );
49+
// this.category = this.categories[this.categoryIndex];
50+
51+
// this.len = this.category.products.length;
52+
if (this.len == 0) {
53+
this.msg = "Sorry, no products found";
54+
} else if (this.len == 1) {
55+
this.msg = "Only 1 product found";
56+
} else {
57+
this.msg = this.len + " products found";
58+
}
59+
},
60+
};
61+
</script>
62+
63+
<style scoped>
64+
h4 {
65+
font-family: "Roboto", sans-serif;
66+
color: #484848;
67+
font-weight: 700;
68+
}
69+
70+
h5 {
71+
font-family: "Roboto", sans-serif;
72+
color: #686868;
73+
font-weight: 300;
74+
}
75+
</style>

0 commit comments

Comments
 (0)