Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 12 additions & 10 deletions packages/hackathon/src/scenes/HomeScene/HomeScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type { FC } from 'react'
import React from 'react'

import { Heading, SpaceVertical, Paragraph, Span } from '@looker/components'
import { getExtensionSDK } from '@looker/extension-sdk'
import type { IHackerProps } from '../../models'
import { ExtMarkdown } from '../../components'
import { Agenda } from './components'
Expand All @@ -41,6 +42,16 @@ const MARKDOWN_LINEBREAK = ' '

export const HomeScene: FC<HomeSceneProps> = ({ hacker }) => {
const schedule = localAgenda(hacker.locale)
const host = getExtensionSDK().lookerHostData?.hostUrl
const intro =
hacker.locale === 'ja_JP'
? `### ハッカソン詳細については、[よくある質問記事](https://community.looker.com/hackathome-2021-1026/hackathome-2021-%E3%82%88%E3%81%8F%E3%81%82%E3%82%8B%E8%B3%AA%E5%95%8F-28518)をご確認いただけます。
現地時間が表示されるため、[アカウント](${host}/account)の「タイムゾーン」を設定できます。${MARKDOWN_LINEBREAK}
アジェンダが日本語で表示されるため、[アカウント](${host}/account)の「Locale」は「ja_JP」に指定できます。
`
: `### Our [Hackathon FAQ](https://community.looker.com/hackathome-2021-1026/hackathome-2021-attendee-faq-28429) contains all event details!
*Change your [account](${host}/account) timezone to display times in your timezone*${MARKDOWN_LINEBREAK}
*Change your [account](${host}/account) locale to \`ja_JP\` to display the agenda in Japanese.*`

return (
<>
Expand All @@ -50,16 +61,7 @@ export const HomeScene: FC<HomeSceneProps> = ({ hacker }) => {
Agenda
</Heading>
<Paragraph>
<ExtMarkdown
source={`### Our [Hackathon FAQ](https://community.looker.com/hackathome-2021-1026/hackathome-2021-attendee-faq-28429) contains all event details!
*Change your [account](https://hack.looker.com/account) timezone to display times in your timezone*${MARKDOWN_LINEBREAK}
*Change your [account](https://hack.looker.com/account) locale to ${'`ja_JP`'} to display agenda in Japanese.*${MARKDOWN_LINEBREAK}
${MARKDOWN_LINEBREAK}${MARKDOWN_LINEBREAK}
### ハッカソン詳細については、[よくある質問記事](https://community.looker.com/hackathome-2021-1026/hackathome-2021-%E3%82%88%E3%81%8F%E3%81%82%E3%82%8B%E8%B3%AA%E5%95%8F-28518)をご確認いただけます。
現地時間が表示されるため、[アカウント](https://hack.looker.com/account)の「タイムゾーン」を設定できます。${MARKDOWN_LINEBREAK}
アジェンダが日本語で表示されるため、[アカウント](https://hack.looker.com/account)の「Locale」は「ja_JP」に指定できます。
`}
/>
<ExtMarkdown source={intro} />
</Paragraph>
</Span>
<Agenda schedule={schedule} hacker={hacker} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,27 @@ export const dateLocale = (locale: string) => (locale === 'ja_JP' ? ja : enUS)
export const dateString = (
value: AgendaTime,
locale: string,
template = 'LLL'
template = 'PPpp'
) => {
return format(value, template, { locale: dateLocale(locale) })
}

/**
* Localized, zoned time
* @param value to zone and localize
* @param zone to use
* @param locale to use
* @param template override for dateString()
*/
export const zonedLocaleDate = (
value: AgendaTime,
zone: string,
locale: string,
template = 'PPpp'
) => {
return dateString(zoneDate(value, zone), locale, template)
}

/**
* Display the Month abbreviation and nth day
* @param date to display
Expand Down
33 changes: 30 additions & 3 deletions packages/hackathon/src/scenes/ProjectsScene/ProjectsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ import type { FC } from 'react'
import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { useHistory } from 'react-router-dom'
import { Button, Space, Heading } from '@looker/components'
import { Button, Space, Heading, Span } from '@looker/components'
import { Add } from '@styled-icons/material-outlined/Add'
import { Create } from '@styled-icons/material-outlined/Create'
import { Lock } from '@styled-icons/material-outlined/Lock'
import { lockProjects } from '../../data/projects/actions'
import { isLoadingState } from '../../data/common/selectors'
import { Loading } from '../../components'
import { Routes } from '../../routes/AppRouter'
import { Routes } from '../../routes'
import {
getCurrentHackathonState,
getHackerState,
} from '../../data/hack_session/selectors'
import { canLockProject } from '../../utils'
import { Era, eraColor, zonedLocaleDate } from '../HomeScene/components'
import { ProjectList } from './components'

interface ProjectSceneProps {}
Expand All @@ -63,6 +65,24 @@ export const ProjectsScene: FC<ProjectSceneProps> = () => {
if (hackathon) dispatch(lockProjects(false, hackathon._id))
}

let judgingStarted = false
let judgingString = ''
if (hackathon && hacker) {
judgingStarted = hackathon.judging_starts?.getTime() < new Date().getTime()

const dateString = zonedLocaleDate(
hackathon.judging_starts,
hacker.timezone,
hacker.locale
)

if (judgingStarted) {
judgingString = `Judging started: ${dateString}`
} else {
judgingString = `Judging starts: ${dateString}`
}
}

return (
<>
<Space>
Expand All @@ -73,7 +93,11 @@ export const ProjectsScene: FC<ProjectSceneProps> = () => {
</Space>
<ProjectList />
<Space pt="xlarge">
<Button iconBefore={<Add />} onClick={handleAdd} disabled={isLoading}>
<Button
iconBefore={<Add />}
onClick={handleAdd}
disabled={(isLoading || judgingStarted) && !canLockProject(hacker)}
>
Add Project
</Button>
<>
Expand All @@ -96,6 +120,9 @@ export const ProjectsScene: FC<ProjectSceneProps> = () => {
</>
)}
</>
<Span color={eraColor(judgingStarted ? Era.past : Era.future)}>
{judgingString}
</Span>
</Space>
</>
)
Expand Down