Skip to content
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
1 change: 1 addition & 0 deletions src/@types/Compute.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare global {
assets?: any
algorithm?: any
payment?: any
isFree?: boolean
}

interface AlgorithmOption {
Expand Down
24 changes: 24 additions & 0 deletions src/components/Profile/History/ComputeJobs/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import useIsMobile from '@hooks/useIsMobile'
import Link from 'next/link'
import Modal from '@shared/atoms/Modal'

enum JobTypeText {
Free = 'Free',
Paid = 'Paid'
}

const extractString = (
value: string | { '@value': string } | undefined
): string => {
Expand Down Expand Up @@ -245,6 +250,24 @@ export default function Details({
return parts.slice(0, 3).join(' ')
}

const jobCostValue = job?.payment?.cost
const hasJobCostValue = jobCostValue !== undefined && jobCostValue !== null
const jobCostNumber = hasJobCostValue ? Number(jobCostValue) : Number.NaN
const jobTypeFromIsFree =
typeof job.isFree === 'boolean'
? job.isFree
? JobTypeText.Free
: JobTypeText.Paid
: null
const jobTypeFromCost =
hasJobCostValue && !Number.isNaN(jobCostNumber)
? jobCostNumber > 0
? JobTypeText.Paid
: JobTypeText.Free
: null
const hasJobType = jobTypeFromIsFree !== null || jobTypeFromCost !== null
const jobTypeDisplay = hasJobType ? jobTypeFromIsFree ?? jobTypeFromCost : '—'

return (
<>
<Button style="text" size="small" onClick={() => setIsDialogOpen(true)}>
Expand Down Expand Up @@ -319,6 +342,7 @@ export default function Details({
}
/>
)}
<MetaItem title="Job Type" content={jobTypeDisplay} />

{job.dateFinished ? (
// When finished date exists, show JobDID on new line
Expand Down