Rev 1068 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from "react";
import { useState } from "react";
import { connect } from "react-redux";
import FeedSection from "../../../dashboard/components/feed-section/FeedSection";
import ShareFeed from "../../../dashboard/components/share-feed/ShareFeed";
import { setTimelineUrl } from "../../../redux/feed/feed.actions";
import { feedTypes } from "../../../redux/feed/feed.types";
import GroupMembersHelper from "../../../shared/helpers/group-members-helper/GroupMembersHelper";
import SuggestedGroupsHelper from "../../../shared/helpers/suggested-groups-helper/SuggestedGroupsHelper";
import styled from "styled-components";
import parse from "html-react-parser";
import { axios } from "../../../utils";
import { addNotification } from "../../../redux/notification/notification.actions";
const StyledTabWrapper = styled.div`
ul {
display: flex;
li a {
margin: 1rem;
width: 25px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: black;
img {
filter: grayscale(100%);
}
}
li.active a {
img {
filter: grayscale(0);
}
}
}
`;
const View = (props) => {
// backendVars Destructuring
const {
routeTimeline,
groupId,
cover,
image,
totalMembers,
name,
overview,
groupType,
industry,
privacy,
accessibility,
website,
withoutFeeds,
linkInmail
} = props.backendVars;
// redux destructuring
const { setTimelineUrl, addNotification: AddNotification } = props;
const groupTabs = {
FEED_TAB: "FEED_TAB",
INFO_TAB: "INFO_TAB",
};
// states
const [currentTab, setCurrentTab] = useState(withoutFeeds ? groupTabs.INFO_TAB : groupTabs.FEED_TAB);
const [actionLinks, setActionLinks] = useState({})
const [linkInvite, setLinkInvite] = useState('')
setTimelineUrl(routeTimeline);
const load = () =>{
axios.get('')
.then(res => {
if(res.data.success){
setActionLinks(res.data.data)
}else{
AddNotification({
type: 'error',
payload: res.data.data
})
}
})
.catch(err => {
console.log('>>: err > ', err)
})
}
React.useEffect(() =>{
load()
}, [])
const handleActionLink = (url) => {
axios.post(url)
.then(res => {
if(res.data.success){
AddNotification({
style: 'success',
msg: res.data.data
})
window.location.reload()
}else{
AddNotification({
style: 'error',
msg: res.data.data
})
}
})
.catch(err => {
console.log('>>: err > ', err)
})
}
return (
<React.Fragment>
<section className="cover-sec">
<img
// src="<?php echo $this->url('storage', ['type' => 'group-cover', 'code' => $group_id_encrypted, 'filename' => $cover]) ?>"
src={`/storage/type/group-cover/code/${groupId}/${
cover ? `filename/${cover}` : ""
}`}
alt="cover-image"
/>
</section>
<main>
<div className="main-section">
<div className="container">
<div className="main-section-data">
<div className="row">
<div className="col-lg-3">
<div className="main-left-sidebar">
<div className="user_profile">
<div className="user-pro-img">
<img
// src="<?php echo $this->url('storage', ['type' => 'group', 'code' => $group_id_encrypted, 'filename' => $image]) ?>"
src={`/storage/type/group/code/${groupId}/${
image ? `filename/${image}` : ""
}`}
alt="profile-image"
/>
</div>
<div className="user_pro_status">
<h1 className="font-weight-bold" style={{fontSize: '1.5rem'}} >{name}</h1>
<ul className="flw-status">
<li>
<p>Miembros</p>
<b style={{fontSize: '1rem'}} >{totalMembers}</b>
</li>
</ul>
</div>
</div>
</div>
<GroupMembersHelper groupId={groupId} handleFirstLinkInvite={link => setLinkInvite(link)} />
</div>
<div className="col-lg-6">
<div className="message-btn d-block d-md-none d-lg-none d-sm-none">
<a
href={linkInmail || '#'}
className="btn-send-message"
title=""
>
<i className="fa fa-envelope"></i> Mensaje
</a>
{
actionLinks.link_accept && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_accept)}
className="btn btn-success"
title=""
>
<i className="fa fa-check"></i> Aceptar invitacion
</a>
)
}
{
actionLinks.link_cancel && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_cancel)}
className="btn btn-danger"
title=""
>
<i className="fa fa-close"></i> Cancelar invitacion
</a>
)
}
{
(!linkInvite && actionLinks.link_leave) && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_leave)}
className="btn btn-danger"
title=""
>
<i className="fas fa-door-open"></i> Abandonar grupo
</a>
)
}
{
actionLinks.link_request && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_request)}
className="btn btn-primary"
title=""
>
<i className="fa fa-plus"></i> Solicitar membresia
</a>
)
}
</div>
<div className="main-ws-sec">
<div className="user-tab-sec">
{
!withoutFeeds && (
<StyledTabWrapper>
<ul>
<li
className={` ${
currentTab === groupTabs.FEED_TAB ? "active" : ""
} animated fadeIn`}
onClick={(e) => {
e.preventDefault();
setCurrentTab(groupTabs.FEED_TAB);
(groupTabs.FEED_TAB);
}}
>
<a href="#" title="">
<img
// src="<?php echo $this->basePath('images/ic1.png') ?>"
src="/images/ic1.png"
alt=""
/>
<span>Publicaciones</span>
</a>
</li>
<li
className={`${
currentTab === groupTabs.INFO_TAB ? "active" : ""
} animated fadeIn group-view-tab`}
onClick={(e) => {
e.preventDefault();
setCurrentTab(groupTabs.INFO_TAB);
(groupTabs.INFO_TAB);
}}
>
<a href="#" title="">
<img
// src="<?php echo $this->basePath('images/ic2.png') ?>"
src="/images/ic2.png"
alt=""
/>
<span className="ellipsis">Info. del grupo</span>
</a>
</li>
</ul>
</StyledTabWrapper>
)
}
{/* <!-- tab-feed end--> */}
</div>
{/* <!--user-tab-sec end--> */}
<div
className="product-feed-tab animated fadeIn"
id="feed-dd"
style={{
display:
currentTab === groupTabs.FEED_TAB ? "block" : "none",
}}
>
<div className="">
<ShareFeed
feedType={feedTypes.GROUP}
postUrl={`/feed/add/group/${groupId}`}
/>
</div>
{/* <!--posts-section star--> */}
<div className="posts-section">
<FeedSection routeTimeline={routeTimeline} />
</div>
{/* <!--posts-section end--> */}
</div>
{/* <!--product-feed-tab end--> */}
<div
className="product-feed-tab animated fadeIn"
id="info-dd"
style={{
display:
currentTab === groupTabs.INFO_TAB ? "block" : "none",
}}
>
<div className="main-ws-sec">
{/* <!--user-tab-sec start--> */}
{!!overview && (
<div className="user-profile-extended-ov">
<h3>Visión General</h3>
<span id="overview-description">
{parse(overview)}
</span>
</div>
)}
{/* <!--user-tab-sec endit--> */}
{/* <!--user-tab-sec start--> */}
{!!groupType && (
<div className="user-profile-extended-ov">
<h3>Tipo</h3>
<span id="overview-type">{groupType}</span>
</div>
)}
{/* <!--user-tab-sec endit--> */}
{/* <!--user-tab-sec start--> */}
{!!industry && (
<div className="user-profile-extended-ov">
<h3>Industria</h3>
<span id="overview-industry">{industry}</span>
</div>
)}
{/* <!--user-tab-sec endit--> */}
{/* <!--user-tab-sec start--> */}
{/* <?php if($privacy) : ?> */}
{!!privacy && (
<div className="user-profile-extended-ov">
<h3>Privacidad</h3>
<span id="overview-privacy">{privacy}</span>
</div>
)}
{/* <!--user-tab-sec endit--> */}
{/* <!--user-tab-sec start--> */}
{!!accessibility && (
<div className="user-profile-extended-ov">
<h3>Accesibilidad</h3>
<span id="overview-accessibility">
{accessibility}
</span>
</div>
)}
{/* <!--user-tab-sec endit--> */}
{/* <!--user-tab-sec start--> */}
{!!website && (
<div className="user-profile-extended-ov">
<h3>Página Web</h3>
<span id="overview-website">{website}</span>
</div>
)}
{/* <!--user-tab-sec endit--> */}
{/* <!--user-profile-ov end--> */}
</div>
{/* <!--main-ws-sec end--> */}
</div>
</div>
</div>
{/* <!--main-ws-sec end--> */}
<div className="col-lg-3 d-sm-none d-none d-md-block d-lg-block">
<div className="right-sidebar">
<div className="message-btn">
<a
href={linkInmail || '#'}
className="btn-send-message"
title=""
>
<i className="fa fa-envelope"></i> Mensaje
</a>
{
actionLinks.link_accept && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_accept)}
className="btn btn-success"
title=""
>
<i className="fa fa-check"></i> Aceptar invitacion
</a>
)
}
{
actionLinks.link_cancel && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_cancel)}
className="btn btn-danger"
title=""
>
<i className="fa fa-close"></i> Cancelar invitacion
</a>
)
}
{
(!linkInvite && actionLinks.link_leave) && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_leave)}
className="btn btn-danger"
title=""
>
<i className="fas fa-door-open"></i> Abandonar grupo
</a>
)
}
{
actionLinks.link_request && (
<a
href="#"
onClick={() => handleActionLink(actionLinks.link_request)}
className="btn btn-primary"
title=""
>
<i className="fa fa-plus"></i> Solicitar membresia
</a>
)
}
</div>
{/* <?php echo $this->similarGroupsHelper($group_id) ?> */}
<SuggestedGroupsHelper groupId={groupId} />
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</React.Fragment>
);
};
const mapDispatchToProps = {
setTimelineUrl: (url) => setTimelineUrl(url),
addNotification: (notification) => addNotification(notification),
};
export default connect(null, mapDispatchToProps)(View);