From 3f36c618b422123490610d5360d56c0e3ff83aa2 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Tue, 11 Jan 2022 19:08:03 +0330 Subject: [PATCH] reza added comments --- package.json | 1 + positive.svg | 7 ++ src/App.css | 4 + src/components/Avatar/index.js | 19 +++ src/components/Comments/index.js | 168 +++++++++++++++++++-------- src/components/Comments/negative.svg | 7 ++ src/components/Comments/positive.svg | 9 ++ yarn.lock | 2 +- 8 files changed, 169 insertions(+), 48 deletions(-) create mode 100644 positive.svg create mode 100644 src/components/Avatar/index.js create mode 100644 src/components/Comments/negative.svg create mode 100644 src/components/Comments/positive.svg diff --git a/package.json b/package.json index bea6faa..21c3d8b 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", + "jalali-moment": "^3.3.10", "jalali-react-datepicker": "^1.2.1", "lodash": "^4.17.21", "rc-slider": "^9.7.5", diff --git a/positive.svg b/positive.svg new file mode 100644 index 0000000..ab9d922 --- /dev/null +++ b/positive.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/App.css b/src/App.css index 9092ab7..a1dc8bc 100644 --- a/src/App.css +++ b/src/App.css @@ -1,3 +1,7 @@ body{ direction: rtl; +} + +*{ + font-family: iranSansX; } \ No newline at end of file diff --git a/src/components/Avatar/index.js b/src/components/Avatar/index.js new file mode 100644 index 0000000..33190d0 --- /dev/null +++ b/src/components/Avatar/index.js @@ -0,0 +1,19 @@ +import React from "react"; +import userImage from "../Blogs/assets/blog-author.png"; + +function Avatar({ source, size, rounded, status }) { + return ( +
+ avatar + {status && ( + + )} +
+ ); +} + +export default Avatar; diff --git a/src/components/Comments/index.js b/src/components/Comments/index.js index 2de0124..a9e37bb 100644 --- a/src/components/Comments/index.js +++ b/src/components/Comments/index.js @@ -1,82 +1,156 @@ -import React from 'react' -import { connect } from 'react-redux'; -import { connectToParent } from '../../utils/comments'; -import userImage from './user.svg'; +import React from "react"; +import { connect } from "react-redux"; +import { connectToParent } from "../../utils/comments"; +import userImage from "./user.svg"; +import positiveIcon from "./positive.svg"; +import negativeIcon from "./negative.svg"; +import Avatar from "../Avatar"; +import moment from "jalali-moment"; +import Button from '../Button'; -export const Comments = ({comments}) => { - connectToParent(comments); +export const Comments = ({ comments }) => { + // connectToParent(comments); + const Comment = ({ comment }) => { + return ( +
+
+
+ +
+ {comment.username} +
+ + {comment.product?.color} + + + {comment.product?.name} + +
+
+
+
+ + {moment(comment.data).locale("fa").format("YYYY/MM/DD")} + + + {comment.date.getHours()} : {comment.date.getMinutes()} + +
+
+
+
+
+
+
fuck
+
+ {comment.status === true && ( + <> + + + برای خرید توصیه می‌کنم + + + )} + {comment.status === false && ( + <> + + + برای خرید توصیه نمی‌کنم + + + )} +
+
+

{comment.text}

+
+
+
+
+
+ ); + }; return (
- + {comments.map((comment, index) => ( + + ))}
- ) -} + ); +}; -const mapStateToProps = (state) => ({ - -}) +const mapStateToProps = (state) => ({}); -const mapDispatchToProps = { - -} +const mapDispatchToProps = {}; export default connect(mapStateToProps, mapDispatchToProps)(Comments); Comments.defaultProps = { - comments : [ + comments: [ { id: 0, pid: null, - username : 'آرش سامانی', - date : new Date(), - text : 'به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد', - userImage : userImage, - rate : 4, + username: "آرش سامانی", + date: new Date(), + text: "به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد", + userImage: userImage, + rate: 4, + product: { + name: "مک بوک پرو 16 گیگ", + color: "خاکستری", + }, + status: true, }, { id: 1, pid: 0, - username : 'سورنا عابدی', - date : new Date(), - text : 'به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد', - userImage : userImage, - rate : 4, + username: "سورنا عابدی", + date: new Date(), + text: "به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد", + userImage: userImage, + rate: 4, }, { id: 2, pid: 1, - username : 'آرش سامانی', - date : new Date(), - text : 'به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد', - userImage : userImage, - rate : 4, + username: "آرش سامانی", + date: new Date(), + text: "به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد", + userImage: userImage, + rate: 4, }, { id: 3, pid: 2, - username : 'آرش سامانی', - date : new Date(), - text : 'به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد', - userImage : userImage, - rate : 4, + username: "آرش سامانی", + date: new Date(), + text: "به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد", + userImage: userImage, + rate: 4, }, { id: 4, pid: 3, - username : 'آرش سامانی', - date : new Date(), - text : 'به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد', - userImage : userImage, - rate : 4, + username: "آرش سامانی", + date: new Date(), + text: "به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد", + userImage: userImage, + rate: 4, }, { id: 5, pid: null, - username : 'رضا رحمانی', - date : new Date(), - text : 'به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد', - userImage : userImage, - rate : 4, + username: "رضا رحمانی", + date: new Date(), + text: "به زودی می‌ فهمند که اشتباه کرده‌ اند و عظمت هر ملتی بر روی خرابه‌ های وطن خودش می‌باشد", + userImage: userImage, + rate: 4, }, ], -} +}; diff --git a/src/components/Comments/negative.svg b/src/components/Comments/negative.svg new file mode 100644 index 0000000..ab9d922 --- /dev/null +++ b/src/components/Comments/negative.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/components/Comments/positive.svg b/src/components/Comments/positive.svg new file mode 100644 index 0000000..7b9aa6d --- /dev/null +++ b/src/components/Comments/positive.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/yarn.lock b/yarn.lock index 11c43d5..0f06436 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6719,7 +6719,7 @@ jalaali-js@^1.1.0: resolved "https://registry.yarnpkg.com/jalaali-js/-/jalaali-js-1.2.3.tgz#365775826d2eece5e6552b96aff384c8773bb406" integrity sha512-irl0pXL59Xl0Oz6jyOiJed/NxrVeS6fSx6a8atQOH/LsPWPZwBCxwe5XVEIqjnwt69FRxvnCCwQn5dTMxwbazQ== -jalali-moment@^3.3.1: +jalali-moment@^3.3.1, jalali-moment@^3.3.10: version "3.3.10" resolved "https://registry.yarnpkg.com/jalali-moment/-/jalali-moment-3.3.10.tgz#10cb4c2080925a41ee8c72862ba63f6b5fb04743" integrity sha512-hyNsDJXB23MHLnZWPXY+Mu0zsrp+B+KzabyqPP0oGcMsEGp8yMpeVledOY+B/DrIOVeRY7JLz8b3lyJ3/vajsQ==