Notes
Notes - notes.io |
import {observer} from 'mobx-react';
import moment from 'moment-timezone';
import HorizontalTimeline from 'react-horizontal-timeline';
import Slider from 'react-slick';
import Header from '@aosprodsys/brucke-ui-core/dist/es/components/Header';
import FeedDetails from '../components/FeedDetails';
import Constants from '../constants/AppConstants';
import Loader from '../components/Loader';
import {StoreContext} from '../utils/StoreContext';
import styles from '../sass/pages/feed-details.scss';
import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import {toJS} from 'mobx';
const FeedDetailsPage = ({partnerDetails}) => {
const slickRef = useRef();
const {appState, partnerFeedsAudit} = React.useContext(StoreContext);
const {
selectedFeedId,
marketingContextAudit,
explorerFeedsAudit,
isFetchingPartnerFeedDeatils,
selectedFeedType
} = partnerFeedsAudit;
const filteredFeeds = explorerFeedsAudit.filter(
feed => (selectedFeedType ? feed.feedType.split(',').includes(selectedFeedType.value) : true)
);
console.log(toJS(selectedFeedType), 'selectedFeedType');
console.log(toJS(filteredFeeds), 'filteredFeeds');
const defaultFeedIndex = filteredFeeds.findIndex(
feed => feed.feedId === (partnerDetails?.feedId || selectedFeedId?.feedId)
);
useEffect(
() => {
const partnerParam = partnerDetails?.partner ? partnerDetails?.partner : selectedFeedId?.partner;
const feedIdParam = partnerDetails?.feedId ? partnerDetails?.feedId : selectedFeedId?.feedId;
let feedTypeParam = partnerDetails?.feedType ? partnerDetails?.feedType : selectedFeedId?.feedType;
if (feedTypeParam.includes(',')) {
feedTypeParam = feedTypeParam.split(',')[0];
}
partnerFeedsAudit.fetchPartnerFeedsAudit(partnerParam);
partnerFeedsAudit.fetchPartnerFeedsMarketingContext(partnerParam, feedIdParam, feedTypeParam);
partnerFeedsAudit.reset();
},
[partnerFeedsAudit, partnerDetails, selectedFeedId]
);
const [selectedIndex, setSelectedIndex] = useState(defaultFeedIndex !== -1 ? defaultFeedIndex : 0);
if (isFetchingPartnerFeedDeatils) return <Loader />;
const isFullPage = !partnerDetails?.partner;
const partnerName = partnerDetails?.partner ? partnerDetails?.partner : selectedFeedId?.partner;
const publishedDate = partnerDetails?.publishedTimeStamp
? moment(partnerDetails?.publishedTimeStamp).format(Constants.FORMAT_DATE)
: moment(selectedFeedId?.publishedTimeStamp).format(Constants.FORMAT_DATE);
const dates = filteredFeeds.map(feed => feed.publishedTimeStamp);
return (
<section className={`${styles.feedDetails} feed-details`}>
{isFullPage ? (
<Header
onNavIconClick={appState.toggleLeftNav}
title={() => (
<div className="list-header">
<h4 className="header global-header-super">{partnerName}</h4>
<span className="subtitle">
Published on <strong>{publishedDate}</strong>
</span>
</div>
)}
/>
) : (
<header>
<h3>{partnerName}</h3>
<small>
Published on <strong>{publishedDate}</strong>
</small>
</header>
)}
<section className={isFullPage ? 'well' : 'dock'}>
<section className="timeline-container">
<HorizontalTimeline
index={selectedIndex}
indexClick={i => {
setSelectedIndex(i);
slickRef.current.slickGoTo(i);
const selectedFeed = filteredFeeds[i];
if (selectedFeed) {
const {partner, feedId} = selectedFeed;
partnerFeedsAudit.fetchPartnerFeedsMarketingContext(partner, feedId, selectedFeedType.value);
}
}}
getLabel={(date, i) => {
const isOdd = i % 2 !== 0;
const labelStyle = isOdd ? {bottom: '15px'} : {top: '15px'};
const matchingFeed = filteredFeeds.find(feed => feed.publishedTimeStamp === date);
const feedId = matchingFeed ? matchingFeed.feedId : 'N/A';
return (
<div style={{...labelStyle, position: 'absolute'}}>
<strong>{`${feedId} ${moment(date).format(Constants.FORMAT_DATE)}`}</strong>
</div>
);
}}
values={dates}
/>
</section>
<Slider
{...{
ref: slickRef,
arrows: false,
draggable: false,
dots: false,
slidesToShow: 1,
slidesToScroll: 1,
initialSlide: selectedIndex
}}
>
{filteredFeeds.map((feed, i) => (
<div key={`${feed.feedId}-${i}`} className="slider-item">
<FeedDetails {...feed} isFullPage={isFullPage} marketingContextAudit={marketingContextAudit} />
</div>
))}
</Slider>
</section>
</section>
);
};
export default observer(FeedDetailsPage);
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team