Skip to content

Commit

Permalink
refactor: ScheduleProgress component from jsx to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Oct 4, 2023
1 parent 8f47a0e commit e8eaf41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import * as rb from 'react-bootstrap'
import { Trans, useTranslation } from 'react-i18next'
import styles from './ScheduleProgress.module.css'
import { Schedule } from '../context/ServiceInfoContext'

const scheduleToSteps = (schedule) => {
const scheduleToSteps = (schedule: Schedule) => {
// Example Schedule:
//
// schedule = [
Expand Down Expand Up @@ -34,7 +34,7 @@ const scheduleToSteps = (schedule) => {
// Calculate total wait time. Ignores the last element since there's no reason in waiting after the last element completed.
// This is a lower bound estimate for the time the whole scheduler run will take since it doesn't take into account the time
// it takes to find and talk to makers and wait for tx confirmations on the timechain.
const totalWaitTime = Math.max(
const totalWaitTime: Minutes = Math.max(
1,
schedule.slice(0, schedule.length - 1).reduce((acc, tx) => acc + tx[4] * 60, 0),
)
Expand All @@ -58,7 +58,11 @@ const scheduleToSteps = (schedule) => {
}
}

const ScheduleProgress = ({ schedule }) => {
interface ScheduleProgressProps {
schedule: Schedule
}

const ScheduleProgress = ({ schedule }: ScheduleProgressProps) => {
const { t } = useTranslation()

const steps = scheduleToSteps(schedule)
Expand Down
2 changes: 1 addition & 1 deletion src/context/ServiceInfoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const SESSION_REQUEST_INTERVAL: Milliseconds = 10_000
type AmountFraction = number
type AmountCounterparties = number
type SchedulerDestinationAddress = 'INTERNAL' | Api.BitcoinAddress
type WaitTimeInMinutes = number
type WaitTimeInMinutes = Minutes
type Rounding = number
type StateFlag = 0 | 1 | Api.TxId

Expand Down
1 change: 1 addition & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare type Unit = 'BTC' | 'sats'

type Milliseconds = number
type Seconds = number
type Minutes = number

declare type MnemonicPhrase = string[]

Expand Down

0 comments on commit e8eaf41

Please sign in to comment.