Skip to content

Commit

Permalink
remove console log statememts
Browse files Browse the repository at this point in the history
relates #9
  • Loading branch information
Israa91 committed Feb 15, 2021
1 parent ad7080d commit 1ed58c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
26 changes: 13 additions & 13 deletions client/src/containers/KindergartenProfilePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ import { Alert, Typography, Image, Carousel, Form, Button } from 'antd';
import Spinner from '../../Components/Common/Spinner';
import Rating from '../../Components/Common/Rating';
import MainInput from '../../Components/Common/MainInput';

import CommentContainer from '../../Components/CommentContainer';
import locationIcon from '../../assets/icons/location1.svg';
import price from '../../assets/icons/price.svg';
import time from '../../assets/icons/time.svg';
import phone from '../../assets/icons/phone.svg';
import commentIcon from '../../assets/icons/comment.svg';

import './style.css';

const { Title } = Typography;

const KindergartenProfilePage = ({ match }) => {
const [kindergartenProfile, setKindergartenProfile] = useState();
const [kindergartenComments, setKindergartenComments] = useState();
const [error, setError] = useState(null);
const [rating, setRating] = useState(0);
const { kindergartenId } = match.params;

// Fetch kindergarten data
const getKindergartenData = async (id) => {
try {
console.log('hi');
const { data: kindergartenData } = await Axios.get(
`/api/v1/kindergarten/${id}`
);
console.log({ kindergartenData });
setKindergartenProfile(kindergartenData.data[0]);
} catch (err) {
let e;
Expand All @@ -42,13 +42,12 @@ const KindergartenProfilePage = ({ match }) => {
}
};

// fetch all comments on this kindergarten
const getKindergartenComments = async (id) => {
try {
console.log('hi');
const { data: kindergartenReview } = await Axios.get(
`/api/v1/kindergarten/${id}/comments`
);
console.log({ kindergartenReview });
setKindergartenComments(kindergartenReview.data);
} catch (err) {
let e;
Expand All @@ -60,9 +59,9 @@ const KindergartenProfilePage = ({ match }) => {
setError(e);
}
};

// add a new comment
const onFinish = async ({ userName, comment }) => {
console.log({ userName, comment, rating, kindergartenId });
console.log('finish');
try {
const { data } = await Axios.post(
`/api/v1/kindergarten/${kindergartenId}/comments`,
Expand All @@ -72,8 +71,9 @@ const KindergartenProfilePage = ({ match }) => {
rating,
}
);
console.log({ data });
getKindergartenComments(kindergartenId);
if (data.length !== 0) {
getKindergartenComments(kindergartenId);
}
} catch (err) {
let e;
if (err.message === 'There is no kindergarten with this id') {
Expand All @@ -85,17 +85,18 @@ const KindergartenProfilePage = ({ match }) => {
}
};

// fetch the data when the kindergarten id change
useEffect(() => {
let isActive = true;
if (isActive) {
getKindergartenData(kindergartenId);
getKindergartenComments(kindergartenId);
}

return () => {
isActive = false;
};
}, [kindergartenId]);

return (
<div className="profile-container">
{
Expand Down Expand Up @@ -138,7 +139,7 @@ const KindergartenProfilePage = ({ match }) => {
<Image src={commentIcon} alt="comment" />
<span className="info-text">
{kindergartenProfile.rating_count} مراجعات
</span>{' '}
</span>
</span>
</div>
<p className="desc">{kindergartenProfile.description}</p>
Expand All @@ -152,7 +153,7 @@ const KindergartenProfilePage = ({ match }) => {
</Title>

<div className="carousal-container">
<Carousel autoplay>
<Carousel autoplay adaptiveHeight>
{kindergartenProfile.image_gallery.map((e) => (
<div className="image-container">
<Image
Expand Down Expand Up @@ -191,7 +192,6 @@ const KindergartenProfilePage = ({ match }) => {
<Rating
setRating={(val) => {
setRating(val);
console.log(val);
}}
/>
<Form.Item>
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ed58c6

Please sign in to comment.