Skip to content

Commit 94d7d59

Browse files
authored
Merge pull request #22 from TryShape/issue-12-creator-info
feat: Now showing the creator name, photo and the formatted creation …
2 parents ac9588e + a1bd85f commit 94d7d59

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

components/core/App.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@ const App = (props) => {
2828
// User is not logged In
2929
shapes = await harperFetch({
3030
operation: "sql",
31-
sql: "SELECT * from tryshape.shapes as s where s.private = false",
31+
sql: `SELECT *
32+
FROM tryshape.shapes s
33+
INNER JOIN tryshape.users u
34+
ON s.createdBy=u.email
35+
WHERE s.private=false`,
3236
});
3337
} else {
3438
// User is logged in. Let's fetch the private shape and pther public shapes.
3539
shapes = await harperFetch({
3640
operation: "sql",
37-
sql: `SELECT * from tryshape.shapes WHERE createdBy = '${user.email}' OR private = false`,
41+
sql: `SELECT *
42+
FROM tryshape.shapes s
43+
INNER JOIN tryshape.users u
44+
ON s.createdBy=u.email
45+
WHERE s.private=false
46+
OR createdBy = '${user.email}'`,
3847
});
3948
}
4049

components/utils/ShapeList.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import { ExportShape } from '..';
2525
// misc unitless
2626
import { getShapeFileName, getShapeId } from '../../utils/misc';
2727

28+
// date-fns
29+
import { formatRelative } from "date-fns";
30+
2831
// Shape Listing Styled-Componentns
2932
const ShapeCards = styled.div`
3033
display: flex;
@@ -178,7 +181,11 @@ const ShapeList = ({ setOpen, user, data }) => {
178181
/>
179182

180183
<div>
181-
<span>Created By {shape.createdBy} at {shape['__createdtime__']}</span>
184+
<span>
185+
Created By
186+
<img src={shape.photoURL} alt={shape.name1} height='30px' width='30px' />
187+
{shape.name1} at {formatRelative(shape['__createdtime__'], new Date())}
188+
</span>
182189
</div>
183190

184191
<ShapeCardSwitch>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"bootstrap": "4.6.0",
12+
"date-fns": "^2.22.1",
1213
"downloadjs": "^1.4.7",
1314
"firebase": "^8.6.7",
1415
"html-to-image": "^1.6.2",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,11 @@ data-uri-to-buffer@3.0.1:
10581058
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636"
10591059
integrity sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==
10601060

1061+
date-fns@^2.22.1:
1062+
version "2.22.1"
1063+
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.22.1.tgz#1e5af959831ebb1d82992bf67b765052d8f0efc4"
1064+
integrity sha512-yUFPQjrxEmIsMqlHhAhmxkuH769baF21Kk+nZwZGyrMoyLA+LugaQtC0+Tqf9CBUUULWwUJt6Q5ySI3LJDDCGg==
1065+
10611066
debug@2:
10621067
version "2.6.9"
10631068
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"

0 commit comments

Comments
 (0)