// Dependencies import orderBy from 'lodash.orderby' import { measurements } from 'site/prebuild/design-measurements.mjs' // Hooks import { useState, useEffect } from 'react' import { useTranslation } from 'next-i18next' import { useAccount } from 'shared/hooks/use-account.mjs' import { useBackend } from 'shared/hooks/use-backend.mjs' // Components import { SetCandidate, ns as setNs } from 'shared/components/sets/set-candidate.mjs' import { CuratedSetCandidate } from 'shared/components/sets/curated-set-candidate.mjs' import { PopoutWrapper } from 'shared/components/wrappers/popout.mjs' export const ns = setNs export const CuratedSetPicker = ({ design }) => { // Hooks const { account, token } = useAccount() const backend = useBackend(token) const { t } = useTranslation('sets') // State const [curatedSets, setCuratedSets] = useState({}) const [list, setList] = useState([]) // Effects useEffect(() => { const getCuratedSets = async () => { const result = await backend.getCuratedSets() if (result.success) { const all = {} for (const set of result.data.curatedSets) all[set.id] = set setCuratedSets(all) } } getCuratedSets() }, []) // Need to sort designs by their translated title const translated = {} for (const d of list) translated[t(`${d}.t`)] = d return ( <>

{t('chooseSet')}

{t('patternForWhichSet')}

{t('fsmtm')}

{Object.keys(curatedSets).length > 0 ? ( <>
{orderBy(curatedSets, ['name'], ['asc']).map((set) => (
))}
) : ( Implement UI for when there are no sets )} ) } export const UserSetPicker = ({ design }) => { // Hooks const { account, token } = useAccount() const backend = useBackend(token) const { t } = useTranslation('sets') // State const [sets, setSets] = useState({}) const [list, setList] = useState([]) // Effects useEffect(() => { const getSets = async () => { const result = await backend.getSets() if (result.success) { const all = {} for (const set of result.data.sets) all[set.id] = set setSets(all) } } getSets() }, []) // Need to sort designs by their translated title const translated = {} for (const d of list) translated[t(`${d}.t`)] = d return ( <>

{t('chooseSet')}

{t('patternForWhichSet')}

{t('fsmtm')}

{Object.keys(sets).length > 0 ? ( <>
{orderBy(sets, ['name'], ['asc']).map((set) => (
))}
) : ( Implement UI for when there are no sets )} ) } export const SetPicker = ({ design }) => ( <> )