From c30b6f7c17eb99ade141e7abf14481180d013aa4 Mon Sep 17 00:00:00 2001 From: Sonia Karungi Date: Thu, 22 Oct 2020 21:40:57 +0300 Subject: [PATCH 1/4] Added try me function --- src/components/business/business.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/business/business.js b/src/components/business/business.js index 78bbcc6..54ce23a 100644 --- a/src/components/business/business.js +++ b/src/components/business/business.js @@ -44,11 +44,16 @@ class BusinessOne extends Component { if (popup === true) { this.props.deleteBusiness(this.props.match.params.bizid) this.props.history.push("/businesses") - NotificationManager.success("Business successfully deleted", "", 5000); + NotificationManager.success("Business object successfully deleted", "", 5000); } } + tryMe=()=>{ + alert("Yay! You're a strong one"); + + } + //Function to a add to review to a business addOneReview=(event)=>{ event.preventDefault(); @@ -63,7 +68,7 @@ class BusinessOne extends Component { //Notification for when a business has no reviews notificationMessage=()=>{ - if(this.props.getReviewsMessage.message === "Business doesn't have reviews yet!!"){ + if(this.props.getReviewsMessage.message === "Business object doesn't have reviews yet!!"){ document.getElementById("noReviews").className = "show"; } } From 0622f20b8171b747e57cdc50d3d02319fd50af71 Mon Sep 17 00:00:00 2001 From: Sonia Karungi Date: Thu, 22 Oct 2020 21:47:31 +0300 Subject: [PATCH 2/4] Added try me function --- src/components/business/business.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/business/business.js b/src/components/business/business.js index 54ce23a..5cb0a44 100644 --- a/src/components/business/business.js +++ b/src/components/business/business.js @@ -42,9 +42,10 @@ class BusinessOne extends Component { deleteOneBusiness=()=>{ const popup = window.confirm('Are you sure you want to delete this business?'); if (popup === true) { - this.props.deleteBusiness(this.props.match.params.bizid) - this.props.history.push("/businesses") - NotificationManager.success("Business object successfully deleted", "", 5000); + // this.props.deleteBusiness(this.props.match.params.bizid) + // this.props.history.push("/businesses") + // NotificationManager.success("Business object successfully deleted", "", 5000); + console.log("lET's see what happens") } } From 7c04334c58fcab236da933e3e4b19b64251e2e89 Mon Sep 17 00:00:00 2001 From: Sonia Karungi Date: Thu, 22 Oct 2020 21:51:24 +0300 Subject: [PATCH 3/4] Added try me function --- src/components/business/business.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/business/business.js b/src/components/business/business.js index 5cb0a44..54ce23a 100644 --- a/src/components/business/business.js +++ b/src/components/business/business.js @@ -42,10 +42,9 @@ class BusinessOne extends Component { deleteOneBusiness=()=>{ const popup = window.confirm('Are you sure you want to delete this business?'); if (popup === true) { - // this.props.deleteBusiness(this.props.match.params.bizid) - // this.props.history.push("/businesses") - // NotificationManager.success("Business object successfully deleted", "", 5000); - console.log("lET's see what happens") + this.props.deleteBusiness(this.props.match.params.bizid) + this.props.history.push("/businesses") + NotificationManager.success("Business object successfully deleted", "", 5000); } } From 327571f6c434e027ff6962412b66d90ecce9e52c Mon Sep 17 00:00:00 2001 From: Sonia Karungi Date: Thu, 22 Oct 2020 21:53:45 +0300 Subject: [PATCH 4/4] Added try me function --- src/components/business/business.js | 208 +--------------------------- 1 file changed, 4 insertions(+), 204 deletions(-) diff --git a/src/components/business/business.js b/src/components/business/business.js index 54ce23a..a224fc1 100644 --- a/src/components/business/business.js +++ b/src/components/business/business.js @@ -1,204 +1,4 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { withRouter, NavLink } from 'react-router-dom'; -import decode from 'jwt-decode'; -import {NotificationManager} from 'react-notifications'; -import changeCase from 'change-case'; - -import 'react-notifications/lib/notifications.css'; -import 'bootstrap/dist/css/bootstrap.min.css'; -import { getBusiness, deleteBusiness, addReview, getReviews } from '../../actions/getOneBusinessActions'; -import AuthNavigationBar from '../navBar/authNavigationBar'; -import {receivedDataStringify} from '../helper/utilities'; - - -/** - * Business Component where a logged in user can view a business, add a review and view all the reviews. - * Also, a user is able to delete or edit a business they created via this component - * - * ```html - * - * ``` - */ -class BusinessOne extends Component { - - componentDidMount=()=>{ - - //check validity of token before mounting the component - var userToken = sessionStorage.getItem("access_token"); - var userDecoded = decode(userToken); - if ((userToken !== null) && (userDecoded.exp > Date.now() / 1000)) { - const bizId = this.props.match.params.bizid - this.props.getBusiness(bizId) - this.props.getReviews(bizId); - } - else { - this.props.history.push("/") - } - } - - //Function to delete a business - deleteOneBusiness=()=>{ - const popup = window.confirm('Are you sure you want to delete this business?'); - if (popup === true) { - this.props.deleteBusiness(this.props.match.params.bizid) - this.props.history.push("/businesses") - NotificationManager.success("Business object successfully deleted", "", 5000); - } - - } - - tryMe=()=>{ - alert("Yay! You're a strong one"); - - } - - //Function to a add to review to a business - addOneReview=(event)=>{ - event.preventDefault(); - let reviewBusinessData={ - review_title:event.target.elements.reviewTitle.value, - review_msg:event.target.elements.reviweMsg.value - }; - const bizId = this.props.match.params.bizid - this.props.addReview(bizId, receivedDataStringify(reviewBusinessData)) - window.location.reload(); - } - - //Notification for when a business has no reviews - notificationMessage=()=>{ - if(this.props.getReviewsMessage.message === "Business object doesn't have reviews yet!!"){ - document.getElementById("noReviews").className = "show"; - } - } - - //hide edit and delete buttons on the business page when a logged in user did not create the business - hideEditButtons=(userDecoded, businessCreatedBy)=>{ - if (userDecoded.username === businessCreatedBy){ - return "row show" - }else{ - return "row collapse" - } - } - - //hide the add review form if the user who created the business is viewing the business - hideAddReviewForm=(userDecoded, businessCreatedBy)=>{ - if (userDecoded.username === businessCreatedBy){ - return "collapse" - }else{ - return "col bg-light show" - } - } - - //hide the line for a better view when the edit and delete buttons are hidden - hideLine=(userDecoded, businessCreatedBy)=>{ - if (userDecoded.username === businessCreatedBy){ - return "show" - }else{ - return "collapse" - } - } - - render() { - - const oneBusiness=this.props.getBusinessMessage.business; - const reviews=Object.values({...this.props.getReviewsMessage.Reviews}); - - if(oneBusiness){ - var businessID = oneBusiness.id - var businessCreatedBy = oneBusiness.CreatedBy - var businessName = oneBusiness.BusinessName - var businessProfile = oneBusiness.BusinessProfile - var businessCategory = oneBusiness.Category - var businessLocation = oneBusiness.Location - } - - //condition to either show or hide the Delete and Update buttons depending on the logged in user - var userToken = sessionStorage.getItem("access_token"); - var userDecoded = decode(userToken); - let EditDeleteButtonClass = this.hideEditButtons(userDecoded, businessCreatedBy) - let LineClass = this.hideLine(userDecoded, businessCreatedBy) - let addReviewClass = this.hideAddReviewForm(userDecoded, businessCreatedBy) - - if (reviews){ - Array.prototype.reverse.call(reviews) - } - - return ( -
- -
-

{businessName}


-
-   -
-
-
-

-
-


About {businessName}

-
{businessCategory} | {businessLocation}
-
-

- {businessProfile} -

-
-
-


Add a Review


-
-
- -
-
-