Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Events page updated #11

Merged
merged 17 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
https://github.com/coderplex/coderplex/pull/11#issuecomment-336893097
  • Loading branch information
M-ZubairAhmed committed Oct 17, 2017
commit a88a09b7623acb6029c3ea20a9ac3bb98b59abfa
62 changes: 31 additions & 31 deletions components/count-down.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import React, { Component } from 'react';
import PropTypes from 'prop-types';

class Countdown extends Component {
constructor(props) {
super(props)
super(props);

this.state = {
days: 0,
hours: 0,
min: 0,
sec: 0,
}
};
}

componentDidMount() {
// Update every second
this.interval = setInterval(() => {
const date = this.calculateCountdown(this.props.date)
if (date) this.setState(date)
else this.stop()
}, 1000)
const date = this.calculateCountdown(this.props.date);
if (date) this.setState(date);
else this.stop();
}, 1000);
}

componentWillUnmount() {
this.stop()
this.stop();
}

calculateCountdown(endDate) {
let diff = (Date.parse(new Date(endDate)) - Date.parse(new Date())) / 1000
let diff = (Date.parse(new Date(endDate)) - Date.parse(new Date())) / 1000;

// Clear countdown when date is reached
if (diff <= 0) return false
if (diff <= 0) return false;

const timeLeft = {
years: 0,
Expand All @@ -39,47 +39,47 @@ class Countdown extends Component {
min: 0,
sec: 0,
millisec: 0,
}
};

// Calculate time difference between now and expected date
if (diff >= 365.25 * 86400) {
// 365.25 * 24 * 60 * 60
timeLeft.years = Math.floor(diff / (365.25 * 86400))
diff -= timeLeft.years * 365.25 * 86400
timeLeft.years = Math.floor(diff / (365.25 * 86400));
diff -= timeLeft.years * 365.25 * 86400;
}
if (diff >= 86400) {
// 24 * 60 * 60
timeLeft.days = Math.floor(diff / 86400)
diff -= timeLeft.days * 86400
timeLeft.days = Math.floor(diff / 86400);
diff -= timeLeft.days * 86400;
}
if (diff >= 3600) {
// 60 * 60
timeLeft.hours = Math.floor(diff / 3600)
diff -= timeLeft.hours * 3600
timeLeft.hours = Math.floor(diff / 3600);
diff -= timeLeft.hours * 3600;
}
if (diff >= 60) {
timeLeft.min = Math.floor(diff / 60)
diff -= timeLeft.min * 60
timeLeft.min = Math.floor(diff / 60);
diff -= timeLeft.min * 60;
}
timeLeft.sec = diff
timeLeft.sec = diff;

return timeLeft
return timeLeft;
}

stop() {
clearInterval(this.interval)
clearInterval(this.interval);
}

addLeadingZeros(value) {
value = String(value)
value = String(value);
while (value.length < 2) {
value = '0' + value
value = '0' + value;
}
return value
return value;
}

render() {
const countDown = this.state
const countDown = this.state;

return (
<div className="countdown">
Expand Down Expand Up @@ -125,16 +125,16 @@ class Countdown extends Component {
}
`}</style>
</div>
)
);
}
}

Countdown.propTypes = {
date: PropTypes.string.isRequired,
}
};

Countdown.defaultProps = {
date: new Date(),
}
};

export default Countdown
export default Countdown;
12 changes: 6 additions & 6 deletions components/footer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import FaFacebook from 'react-icons/lib/fa/facebook'
import FaYoutube from 'react-icons/lib/fa/youtube-play'
import FaGithub from 'react-icons/lib/fa/github-alt'
import FaInstagram from 'react-icons/lib/fa/instagram'
import React from 'react';
import FaFacebook from 'react-icons/lib/fa/facebook';
import FaYoutube from 'react-icons/lib/fa/youtube-play';
import FaGithub from 'react-icons/lib/fa/github-alt';
import FaInstagram from 'react-icons/lib/fa/instagram';

export default () => (
<footer>
Expand Down Expand Up @@ -80,4 +80,4 @@ export default () => (
}
`}</style>
</footer>
)
);
4 changes: 2 additions & 2 deletions components/global-styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React from 'react';

export default () => (
<div>
Expand Down Expand Up @@ -51,4 +51,4 @@ export default () => (
}
`}</style>
</div>
)
);
6 changes: 3 additions & 3 deletions components/head.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import Head from 'next/head'
import React from 'react';
import Head from 'next/head';

export default ({ title }) => (
<Head>
Expand Down Expand Up @@ -50,4 +50,4 @@ export default ({ title }) => (
<meta property="og:site_name" content="coderplex" />
<meta property="og:description" content="coderplex" />
</Head>
)
);
40 changes: 20 additions & 20 deletions components/header.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import React from 'react'
import Headroom from 'react-headroom'
import NProgress from 'nprogress'
import Router from 'next/router'
import Link from 'next/link'
import { Dropdown } from 'semantic-ui-react'
import React from 'react';
import Headroom from 'react-headroom';
import NProgress from 'nprogress';
import Router from 'next/router';
import Link from 'next/link';
import { Dropdown } from 'semantic-ui-react';

import { logout } from '../utils/authenticate'
import GlobalStyles from './global-styles'
import Head from './head'
import { logout } from '../utils/authenticate';
import GlobalStyles from './global-styles';
import Head from './head';

Router.onRouteChangeStart = () => {
NProgress.start()
}
NProgress.start();
};

Router.onRouteChangeComplete = () => {
NProgress.done()
}
NProgress.done();
};

Router.onRouteChangeError = () => {
NProgress.done()
}
NProgress.done();
};

export default props => {
const title =
props.url.pathname === '/'
? 'Home'
: props.url.pathname.split('/')[1].toUpperCase()
: props.url.pathname.split('/')[1].toUpperCase();
const navItems = [
{
title: 'Home',
Expand Down Expand Up @@ -59,7 +59,7 @@ export default props => {
title: 'Login/Register',
path: '/login',
},
].filter(item => (props.username ? item.path !== '/login' : true))
].filter(item => (props.username ? item.path !== '/login' : true));
return (
<Headroom>
<header>
Expand Down Expand Up @@ -89,7 +89,7 @@ export default props => {
</a>
</Link>
</li>
)
);
})}
{props.username && (
<li className="nav__linkItem">
Expand Down Expand Up @@ -206,5 +206,5 @@ export default props => {
}
`}</style>
</Headroom>
)
}
);
};
34 changes: 17 additions & 17 deletions pages/jobs/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from 'react'
import Link from 'next/link'
import { Input, Dropdown, Button, Header, Icon } from 'semantic-ui-react'
import FaBuilding from 'react-icons/lib/fa/building'
import FaLocation from 'react-icons/lib/fa/map-marker'
import React from 'react';
import Link from 'next/link';
import { Input, Dropdown, Button, Header, Icon } from 'semantic-ui-react';
import FaBuilding from 'react-icons/lib/fa/building';
import FaLocation from 'react-icons/lib/fa/map-marker';
// Import FaArrowRight from 'react-icons/lib/fa/angle-right'

import publicPage from '../../hocs/public-page'
import { client as feathersClient } from '../../utils/feathers-client'
import truncateString from '../../utils'
import publicPage from '../../hocs/public-page';
import { client as feathersClient } from '../../utils/feathers-client';
import truncateString from '../../utils';

const _jobTypes = ['FullTime', 'PartTime', 'Remote', 'Consulting', 'Freelance']
const _jobTypes = ['FullTime', 'PartTime', 'Remote', 'Consulting', 'Freelance'];

const jobTypes = _jobTypes.map(type => ({
key: type,
text: type,
value: type,
}))
}));

const technologies = [
{ key: 'all', text: 'All', value: 'all' },
Expand All @@ -34,7 +34,7 @@ const technologies = [
{ key: 'ruby', text: 'Ruby', value: 'ruby' },
{ key: 'ui', text: 'UI Design', value: 'ui' },
{ key: 'ux', text: 'User Experience', value: 'ux' },
]
];

const Jobs = props => (
<div>
Expand Down Expand Up @@ -124,7 +124,7 @@ const Jobs = props => (
</Link>
</div>
</div>
)
);
})}
</div>
{/* <div className="jobs__more">
Expand Down Expand Up @@ -364,7 +364,7 @@ const Jobs = props => (
}
`}</style>
</div>
)
);

Jobs.getInitialProps = async () => {
const jobs = await feathersClient
Expand All @@ -376,8 +376,8 @@ Jobs.getInitialProps = async () => {
},
},
})
.then(res => res.data)
return { jobs }
}
.then(res => res.data);
return { jobs };
};

export default publicPage(Jobs)
export default publicPage(Jobs);
Loading