// Dependencies
import { orderBy, cloudflareImageUrl, getSearchParam, formatMm } from '@freesewing/utils'
import { isDegreeMeasurement } from '@freesewing/config'
import { measurements as measurementTranslations } from '@freesewing/i18n'
// Hooks
import { useBackend } from '@freesewing/react/hooks/useBackend'
import React, { useState, useEffect } from 'react'
// Components
import { Link as WebLink } from '@freesewing/react/components/Link'
import { MiniWarning } from '@freesewing/react/components/Mini'
import { Spinner } from '@freesewing/react/components/Spinner'
import { Markdown } from '@freesewing/react/components/Markdown'
import { KeyVal } from '@freesewing/react/components/KeyVal'
export const CuratedSetLineup = ({ href = false, clickHandler = false, Link = false }) => {
if (!Link) Link = WebLink
// Hooks
const backend = useBackend()
// State (local)
const [sets, setSets] = useState([])
// Effects
useEffect(() => {
const getSets = async () => {
const [status, body] = await backend.getCuratedSets()
if (status === 200 && body.result === 'success') {
const allSets = []
for (const set of body.curatedSets) {
if (set.published) allSets.push(set)
}
setSets(orderBy(allSets, 'height', 'asc'))
}
}
getSets()
}, [])
if (!href && !clickHandler)
return (
href
or clickHandler
prop to the{' '}
CuratedSetLineup
component.
Measurement | Metric | Imperial |
---|---|---|
{entry.t} | {isDegreeMeasurement(entry.id) ? `${entry.val}°` : formatMm(entry.val)} |