Skip to content

Commit 154c2b0

Browse files
committed
Get frontend properties from api & use of Placeholders
1 parent 7508403 commit 154c2b0

File tree

8 files changed

+82
-65
lines changed

8 files changed

+82
-65
lines changed

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"eslint-plugin-import": "^2.18.2",
5858
"eslint-plugin-jsx-a11y": "^6.2.3",
5959
"eslint-plugin-react": "^7.14.3",
60+
"file-loader": "^5.0.2",
6061
"html-loader": "^0.5.5",
6162
"html-webpack-plugin": "^3.2.0",
6263
"json-loader": "^0.5.7",

src/assets/img/placeholder.png

5.26 KB
Loading

src/components/Dashboard/Sidebar.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,7 @@ const Sidebar = () => {
188188
</LogoContainer>
189189
<SidebarContent>
190190
<Navigation>
191-
<NavElement selected>
192-
<CustomLink to="/" onClick={handleLinkClick}>
193-
<i className="fas fa-columns" />
194-
<p>Dashboard</p>
195-
</CustomLink>
196-
</NavElement>
191+
197192
{
198193
dashboardRoutes.map((route, index) => {
199194
return route.sidebar ? (

src/pages/Dashboard/Properties.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import { getProperties, deleteProperty } from '../../data/crudProperties';
88
import TitleBar from '../../components/Dashboard/TitleBar';
99
import IconAction from '../../components/Atoms/IconAction';
1010
import Modal from '../../components/Modal/AsyncModal';
11+
import placeholder from '../../assets/img/placeholder.png';
12+
13+
const placeholder2 = `/${placeholder}`;
1114

1215
const Table = styled.table`
1316
max-width: 100%;
@@ -193,7 +196,7 @@ const Properties = () => {
193196
key={_id}
194197
>
195198
<TableCell>
196-
<Image src={img.src} alt={title} />
199+
<Image src={img.src || placeholder2} alt={title} />
197200
</TableCell>
198201
<TableCell>
199202
{title}

src/pages/Front/PropertiesFront/PropertiesFront.jsx

Lines changed: 48 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
import React from 'react';
1+
import React, { useState, useEffect } from 'react';
22

33
import PropertyList, { Item } from '../../../components/PropertyList';
4+
import propertiesMock from '../../../mock/properties1.json';
5+
import { getProperties } from '../../../data/crudProperties';
6+
import placeholder from '../../../assets/img/placeholder.png';
47

58
const Properties = () => {
9+
const [properties, setProperties] = useState(propertiesMock);
10+
11+
async function fetchMyAPI() {
12+
const data = await getProperties();
13+
setProperties(data.data);
14+
}
15+
16+
useEffect(() => {
17+
fetchMyAPI();
18+
}, []);
19+
620
return (
721
<PropertyList>
822
<Item
@@ -19,62 +33,39 @@ const Properties = () => {
1933
age: [16, 'y'],
2034
}}
2135
/>
22-
<Item
23-
cover="https://media.truehome.com.mx/media/original_images/663_HCPortada.jpg"
24-
type="apartment"
25-
price={['5300000', 'MXN']}
26-
title="Hacienda del Ciervo, Hacienda de las Palmas"
27-
description="Hacienda de las Palmas, Huixquilucan, Estado de México"
28-
characteristics={{
29-
bedrooms: 2,
30-
bathrooms: 2,
31-
parkingLots: 2,
32-
surface: [155, 'm2'],
33-
age: [16, 'y'],
34-
}}
35-
/>
36-
<Item
37-
cover="https://media.truehome.com.mx/media/original_images/663_HCPortada.jpg"
38-
type="apartment"
39-
price={['5300000', 'MXN']}
40-
title="Hacienda del Ciervo, Hacienda de las Palmas"
41-
description="Hacienda de las Palmas, Huixquilucan, Estado de México"
42-
characteristics={{
43-
bedrooms: 2,
44-
bathrooms: 2,
45-
parkingLots: 2,
46-
surface: [155, 'm2'],
47-
age: [16, 'y'],
48-
}}
49-
/>
50-
<Item
51-
cover="https://media.truehome.com.mx/media/original_images/663_HCPortada.jpg"
52-
type="apartment"
53-
price={['5300000', 'MXN']}
54-
title="Hacienda del Ciervo, Hacienda de las Palmas"
55-
description="Hacienda de las Palmas, Huixquilucan, Estado de México"
56-
characteristics={{
57-
bedrooms: 2,
58-
bathrooms: 2,
59-
parkingLots: 2,
60-
surface: [155, 'm2'],
61-
age: [16, 'y'],
62-
}}
63-
/>
64-
<Item
65-
cover="https://media.truehome.com.mx/media/original_images/663_HCPortada.jpg"
66-
type="apartment"
67-
price={['5300000', 'MXN']}
68-
title="Hacienda del Ciervo, Hacienda de las Palmas"
69-
description="Hacienda de las Palmas, Huixquilucan, Estado de México"
70-
characteristics={{
71-
bedrooms: 2,
72-
bathrooms: 2,
73-
parkingLots: 2,
74-
surface: [155, 'm2'],
75-
age: [16, 'y'],
76-
}}
77-
/>
36+
{
37+
properties.map((property) => {
38+
const {
39+
_id,
40+
title,
41+
img,
42+
description,
43+
prices,
44+
} = property;
45+
console.log('placeholder', placeholder);
46+
const placeholder2 = `/${placeholder}`;
47+
const to = `/admin/property/${_id}`;
48+
return (
49+
<Item
50+
to={to}
51+
cover={img.src || placeholder2}
52+
type="apartment"
53+
price={[prices.amount, 'MXN']}
54+
title={title}
55+
description={description}
56+
characteristics={{
57+
bedrooms: 2,
58+
bathrooms: 2,
59+
parkingLots: 2,
60+
surface: [155, 'm2'],
61+
age: [16, 'y'],
62+
}}
63+
/>
64+
65+
);
66+
})
67+
}
68+
7869
</PropertyList>
7970
);
8071
};

src/routes/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const dashboardRoutes = [
7272
path: '/properties',
7373
name: 'Properties',
7474
rtlName: 'Properties',
75-
icon: 'fas fa-home',
75+
icon: 'fas fa-columns',
7676
component: Properties,
7777
layout: '/admin',
7878
exact: false,

webpack.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ module.exports = {
1919
module: {
2020

2121
rules: [
22+
{
23+
test: /\.(jpe?g|png|gif)$/i,
24+
loader: 'file-loader?name=img/[name].[ext]',
25+
},
26+
2227
{
2328
test: /\.(js|jsx)$/,
2429
exclude: /node_modules/,

0 commit comments

Comments
 (0)