Commit 064062b 1 parent 46d2357 commit 064062b Copy full SHA for 064062b
File tree 3 files changed +17
-6
lines changed
3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,13 @@ const useQuery = () => {
41
41
42
42
import { ElectionContext } from '../Election'
43
43
import LoadingScreen from '../layout/LoadingScreen'
44
+ import { shouldAllowSendingProtocols } from '../../utils/visibility'
44
45
45
46
// Only show results, when they are available and after election day end
46
47
const shouldShowResults = ( results , meta ) => {
47
- if ( ! results || ! meta ) return false
48
+ if ( ! results ) return false
48
49
49
- const { endOfElectionDayTimestamp } = meta
50
-
51
- return results . length > 0 && new Date ( ) > new Date ( endOfElectionDayTimestamp )
50
+ return results . length > 0 && shouldAllowSendingProtocols ( meta )
52
51
}
53
52
54
53
export default ( props ) => {
Original file line number Diff line number Diff line change 1
- import React , { useState } from 'react'
1
+ import React , { useContext , useState } from 'react'
2
2
import { Link } from 'react-router-dom'
3
3
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4
4
import { faBars } from '@fortawesome/free-solid-svg-icons'
5
5
import { slide as Menu } from 'react-burger-menu'
6
6
import styled from 'styled-components'
7
7
import { ROUTES } from '../routes'
8
+ import { ElectionContext } from '../Election'
9
+ import { shouldAllowSendingProtocols } from '../../utils/visibility'
8
10
9
11
const MOBILE_WIDTH = 952
10
12
@@ -115,6 +117,7 @@ const MobileNavMenu = styled.div`
115
117
116
118
export default ( ) => {
117
119
const [ menuOpen , setMenuOpen ] = useState ( false )
120
+ const { meta } = useContext ( ElectionContext )
118
121
119
122
return (
120
123
< >
@@ -125,7 +128,9 @@ export default () => {
125
128
< LogoImage src = "/brand/logo_horizontal_white.png?v=2" />
126
129
</ Link >
127
130
< Navigation >
128
- < Link to = { ROUTES . protocolForm } > Изпрати протокол</ Link >
131
+ { shouldAllowSendingProtocols ( meta ) && (
132
+ < Link to = { ROUTES . protocolForm } > Изпрати протокол</ Link >
133
+ ) }
129
134
< Link to = { ROUTES . violationForm } > Подай сигнал</ Link >
130
135
{ /*<a href="/signup">Запиши се</a>*/ }
131
136
{ /*<a href="/about">Kампанията</a>*/ }
Original file line number Diff line number Diff line change
1
+ export const shouldAllowSendingProtocols = ( meta ) => {
2
+ if ( ! meta ?. endOfElectionDayTimestamp ) {
3
+ return false
4
+ }
5
+
6
+ return new Date ( ) > new Date ( meta . endOfElectionDayTimestamp )
7
+ }
You can’t perform that action at this time.
0 commit comments