<commit_before>// @flow
import * as React from 'react'
import {Text, View, ScrollView, StyleSheet} from 'react-native'
import {sendEmail} from '../../../components/send-email'
import {Card} from '../../../components/card'
import moment from 'moment'
import {openUrl} from '@frogpond/open-url'
import * as c from '@frogpond/colors'
import type {JobType} from './types'
import {ShareButton} from '../../../components/nav-buttons'
import {shareJob} from './lib'

const styles = StyleSheet.create({
	name: {
		textAlign: 'center',
		marginTop: 20,
		marginBottom: 15,
		paddingHorizontal: 5,
		color: c.black,
		fontSize: 32,
		fontWeight: '300',
	},
	subtitle: {
		textAlign: 'center',
		marginBottom: 15,
		paddingHorizontal: 5,
		color: c.black,
		fontSize: 16,
		fontWeight: '300',
	},
	card: {
		marginBottom: 20,
	},
	cardBody: {
		color: c.black,
		paddingTop: 13,
		paddingBottom: 13,
		paddingLeft: 16,
		paddingRight: 16,
		fontSize: 16,
	},
	lastUpdated: {
		paddingBottom: 20,
	},
	footer: {
		fontSize: 10,
		color: c.iosDisabledText,
		textAlign: 'center',
	},
})

function Title({job}: {job: JobType}) {
	return job.title || job.type ? (
		<View>
			<Text style={styles.name}>{job.title}</Text>
			<Text style={styles.subtitle}>{job.type}</Text>
		</View>
	) : null
}

function Contact({job}: {job: JobType}) {
	let contactName = job.contactName || job.contactEmail

	return job.office || contactName ? (
		<Card header="Contact" style={styles.card}>
			<Text
				onPress={() =>
					job.contactEmail
						? sendEmail({to: [job.contactEmail], subject: job.title, body: ''})
						: null
				}
				style={styles.cardBody}
			>
				{contactName} {job.title ? `(${job.title})` : ''}
				{'\n'}
				{job.office}
			</Text>
		</Card>
	) : null
}

function Hours({job}: {job: JobType}) {
	const ending = job.hoursPerWeek === 'Full-time' ? '' : ' hrs/week'
	return job.timeOfHours && job.hoursPerWeek ? (
		<Card header="Hours" style={styles.card}>
			<Text style={styles.cardBody}>
				{job.timeOfHours}
				{'\n'}
				{job.hoursPerWeek + ending}
			</Text>
		</Card>
	) : null
}

function Description({job}: {job: JobType}) {
	return job.description ? (
		<Card header="Description" style={styles.card}>
			<Text style={styles.cardBody}>{job.description}</Text>
		</Card>
	) : null
}

function Skills({job}: {job: JobType}) {
	return job.skills ? (
		<Card header="Skills" style={styles.card}>
			<Text style={styles.cardBody}>{job.skills}</Text>
		</Card>
	) : null
}

function Comments({job}: {job: JobType}) {
	return job.comments ? (
		<Card header="Comments" style={styles.card}>
			<Text style={styles.cardBody}>{job.comments}</Text>
		</Card>
	) : null
}

function Links({job}: {job: JobType}) {
	const {links} = job
	return links.length ? (
		<Card header="LINKS" style={styles.card}>
			{links.map(url => (
				<Text key={url} onPress={() => openUrl(url)} style={styles.cardBody}>
					{url}
				</Text>
			))}
		</Card>
	) : null
}

function LastUpdated({when}: {when: string}) {
	return when ? (
		<Text selectable={true} style={[styles.footer, styles.lastUpdated]}>
			Last updated: {moment(when, 'YYYY/MM/DD').calendar()}
			{'\n'}
			Powered by St. Olaf Student Employment job postings
		</Text>
	) : null
}

type Props = {
	navigation: {state: {params: {job: JobType}}},
}

export class JobDetailView extends React.PureComponent<Props> {
	static navigationOptions = ({navigation}: any) => {
		const {job} = navigation.state.params
		return {
			title: job.title,
			headerRight: <ShareButton onPress={() => shareJob(job)} />,
		}
	}

	render() {
		const job = this.props.navigation.state.params.job

		return (
			<ScrollView>
				<Title job={job} />
				<Contact job={job} />
				<Hours job={job} />
				<Description job={job} />
				<Skills job={job} />
				<Comments job={job} />
				<Links job={job} />
				<LastUpdated when={job.lastModified} />
			</ScrollView>
		)
	}
}<commit_msg>update android detail with new job fields<commit_after>// @flow
import * as React from 'react'
import {Text, View, ScrollView, StyleSheet} from 'react-native'
import {sendEmail} from '../../../components/send-email'
import {callPhone} from '../../../components/call-phone'
import {Card} from '../../../components/card'
import moment from 'moment'
import {openUrl} from '@frogpond/open-url'
import * as c from '@frogpond/colors'
import type {JobType} from './types'
import {ShareButton} from '../../../components/nav-buttons'
import {shareJob} from './lib'

const styles = StyleSheet.create({
	name: {
		textAlign: 'center',
		marginTop: 20,
		marginBottom: 15,
		paddingHorizontal: 5,
		color: c.black,
		fontSize: 32,
		fontWeight: '300',
	},
	subtitle: {
		textAlign: 'center',
		marginBottom: 15,
		paddingHorizontal: 5,
		color: c.black,
		fontSize: 16,
		fontWeight: '300',
	},
	card: {
		marginBottom: 20,
	},
	cardBody: {
		color: c.black,
		paddingTop: 13,
		paddingBottom: 13,
		paddingLeft: 16,
		paddingRight: 16,
		fontSize: 16,
	},
	lastUpdated: {
		paddingBottom: 20,
	},
	footer: {
		fontSize: 10,
		color: c.iosDisabledText,
		textAlign: 'center',
	},
})

function Title({job}: {job: JobType}) {
	return job.title || job.type ? (
		<View>
			<Text style={styles.name}>{job.title}</Text>
			<Text style={styles.subtitle}>{job.type}</Text>
		</View>
	) : null
}

function Contact({job}: {job: JobType}) {
	const contactName = job.contactName
	const contactEmail = job.contactEmail
	const contactNumber = job.contactPhone

	return job.office || contactName ? (
		<Card header="Contact" style={styles.card}>
			<Text style={styles.cardBody}>{contactName}</Text>

			{contactEmail ? (
				<Text
					onPress={() =>
						job.contactEmail
							? sendEmail({to: [contactEmail], subject: job.title, body: ''})
							: null
					}
					style={styles.cardBody}
				>
					{contactEmail}
				</Text>
			) : null}

			{contactNumber ? (
				<Text
					onPress={() => (job.contactPhone ? callPhone(contactNumber) : null)}
					style={styles.cardBody}
				>
					{contactNumber}
				</Text>
			) : null}

			{job.office ? <Text style={styles.cardBody}>{job.office}</Text> : null}
		</Card>
	) : null
}

function Hours({job}: {job: JobType}) {
	const ending = job.hoursPerWeek === 'Full-time' ? '' : ' hrs/week'
	return job.timeOfHours && job.hoursPerWeek ? (
		<Card header="Hours" style={styles.card}>
			<Text style={styles.cardBody}>
				{job.timeOfHours}
				{'\n'}
				{job.hoursPerWeek + ending}
			</Text>
		</Card>
	) : null
}

function GeneralInfo({job}: {job: JobType}) {
	return job.year || job.openPositions ? (
		<Card header="General" style={styles.card}>
			<Text style={styles.cardBody}>
				{job.year ? `${job.year}\n\n` : null}
				{job.openPositions ? `Positions: ${job.openPositions}\n\n` : null}
				{job.goodForIncomingStudents
					? 'Appropriate for First Year Students'
					: 'Not Appropriate for First Year Students'}
			</Text>
		</Card>
	) : null
}

function Description({job}: {job: JobType}) {
	return job.description ? (
		<Card header="Description" style={styles.card}>
			<Text style={styles.cardBody}>{job.description}</Text>
		</Card>
	) : null
}

function Skills({job}: {job: JobType}) {
	return job.skills ? (
		<Card header="Skills" style={styles.card}>
			<Text style={styles.cardBody}>{job.skills}</Text>
		</Card>
	) : null
}

function Comments({job}: {job: JobType}) {
	return job.comments ? (
		<Card header="Comments" style={styles.card}>
			<Text style={styles.cardBody}>{job.comments}</Text>
		</Card>
	) : null
}

function HowToApply({job}: {job: JobType}) {
	return job.howToApply ? (
		<Card header="How To Apply" style={styles.card}>
			<Text style={styles.cardBody}>{job.howToApply}</Text>
		</Card>
	) : null
}

function Timeline({job}: {job: JobType}) {
	return job.timeline ? (
		<Card header="Timeline" style={styles.card}>
			<Text style={styles.cardBody}>{job.timeline}</Text>
		</Card>
	) : null
}

function Links({job}: {job: JobType}) {
	const {links} = job
	return links.length ? (
		<Card header="LINKS" style={styles.card}>
			{links.map(url => (
				<Text key={url} onPress={() => openUrl(url)} style={styles.cardBody}>
					{url}
				</Text>
			))}
		</Card>
	) : null
}

function LastUpdated({when}: {when: string}) {
	return when ? (
		<Text selectable={true} style={[styles.footer, styles.lastUpdated]}>
			Last updated: {moment(when, 'YYYY/MM/DD').calendar()}
			{'\n'}
			Powered by St. Olaf Student Employment job postings
		</Text>
	) : null
}

type Props = {
	navigation: {state: {params: {job: JobType}}},
}

export class JobDetailView extends React.PureComponent<Props> {
	static navigationOptions = ({navigation}: any) => {
		const {job} = navigation.state.params
		return {
			title: job.title,
			headerRight: <ShareButton onPress={() => shareJob(job)} />,
		}
	}

	render() {
		const job = this.props.navigation.state.params.job

		return (
			<ScrollView>
				<Title job={job} />
				<Contact job={job} />
				<GeneralInfo job={job} />
				<Hours job={job} />
				<Description job={job} />
				<Skills job={job} />
				<Comments job={job} />
				<Timeline job={job} />
				<HowToApply job={job} />
				<Links job={job} />
				<LastUpdated when={job.lastModified} />
			</ScrollView>
		)
	}
}
{'fraction_non_alphanumeric': 0.1841732883422227, 'fraction_numerical': 0.007401763361271361, 'mean_word_length': 3.555280118988597, 'pattern_counts': {'":': 0, '<': 112, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2004936', 'n_tokens_mistral': 3698, 'n_tokens_neox': 3219, 'n_words': 717}