-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented review rendering for both user view org profile, as well …
…as regular org profile Took 41 minutes
- Loading branch information
Showing
3 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import Meteor from 'meteor/meteor'; | ||
import { useTracker } from 'meteor/react-meteor-data'; | ||
import PropTypes from 'prop-types'; | ||
import { Container } from 'react-bootstrap'; | ||
import { Star } from 'react-bootstrap-icons'; | ||
import { UserProfiles } from '../../api/user/UserProfileCollection'; | ||
import LoadingSpinner from './LoadingSpinner'; | ||
|
||
const OrgReview = ({ review }) => { | ||
const { ready, profile } = useTracker(() => { | ||
// Note that this subscription will get cleaned up | ||
// when your component is unmounted or deps change. | ||
// Get access to Stuff documents. | ||
const profileSubscription = UserProfiles.subscribeUser(); | ||
// Determine if the subscription is ready | ||
const rdy = profileSubscription.ready(); | ||
// Get the profile whose email matches the reviewer's | ||
const reviewerProfile = UserProfiles.findOne({ _id: { $eq: review.reviewerID } }); | ||
return { | ||
profile: reviewerProfile, | ||
ready: rdy, | ||
}; | ||
}, []); | ||
return (ready ? ( | ||
<Container> | ||
<Container className="d-inline-block"> | ||
<h6>{profile.firstName} {profile.lastName}</h6> | ||
{review.rating === null ? ( | ||
<h6>Rating: <Star className="pb-1" /> 0</h6> | ||
) : ( | ||
<h6>Rating: <Star className="pb-1" /> {review.rating}</h6> | ||
)} | ||
{review.content} | ||
<hr /> | ||
</Container> | ||
</Container> | ||
) : (<LoadingSpinner />)); | ||
}; | ||
|
||
// Require a document to be passed to this component. | ||
OrgReview.propTypes = { | ||
review: PropTypes.shape({ | ||
rating: { type: Number, min: 1, max: 5 }, | ||
reviewerID: { type: String }, // userID | ||
reviewFor: { type: Object }, | ||
'reviewFor.type': { type: String, allowedValues: ['event', 'organization'] }, // ["event", "organization"] | ||
'reviewFor.ID': { type: String }, // eventID/organizationID | ||
content: { type: String }, | ||
}).isRequired, | ||
}; | ||
|
||
export default OrgReview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters