Skip to content

Commit

Permalink
convert to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Oct 25, 2024
1 parent 8ec78c7 commit 14a4fe6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
16 changes: 0 additions & 16 deletions catalog/app/components/Preview/loaders/Genbank.js

This file was deleted.

33 changes: 33 additions & 0 deletions catalog/app/components/Preview/loaders/Genbank.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as R from 'ramda'

import type * as Model from 'model'

import { PreviewData } from '../types'

import * as utils from './utils'

export const detect = R.pipe(utils.stripCompression, utils.extIs('.gb'))

interface PreviewResult {
html: string
info: {
data: string
note?: string
warnings?: string
}
}

interface GenbankLoaderProps {
children: (result: $TSFixMe) => React.ReactNode
handle: Model.S3.S3ObjectLocation
}

export const Loader = function GenbankLoader({ handle, children }: GenbankLoaderProps) {
const data = utils.usePreview({ type: 'gb', handle, query: undefined })
const processed = utils.useProcessing(data.result, (json: PreviewResult) =>
PreviewData.Genbank({
src: json.info.data,
}),
)
return children(utils.useErrorHandling(processed, { handle, retry: data.fetch }))
}

0 comments on commit 14a4fe6

Please sign in to comment.