import { configs } from 'shared/designs/index.js'
import { useTranslation } from 'next-i18next'
import PageLink from 'shared/components/page-link.js'
const renderOptions = (groups, pattern, t) => {
const list = []
for (let l1 in groups) {
let children = []
for (let l2 of groups[l1]) {
if (typeof l2 === 'string') {
children.push(
)
} else {
for (let l3 in l2) {
let grandchildren = []
for (let l4 of l2[l3]) {
grandchildren.push(
)
}
children.push(
{t(`og:${l3}`)}
)
}
}
}
list.push(
{t(`og:${l1}`)}
)
}
return
}
const PatternOptions = ({ pattern, before=null, after=null }) => {
const { t } = useTranslation([`o_${pattern}`, 'og'])
const sortOptions = (options) => {
if (typeof options === 'undefined') return []
const sorted = []
const translated = {}
for (const o of options) {
const translation = intl.messages['measurements.' + o] || o
translated[translation] = o
}
const order = Object.keys(translated)
order.sort()
for (const o of order) sorted.push(translated[o])
return sorted
}
return (
{before}
{renderOptions(configs[pattern].optionGroups, pattern, t)}
{after}
)
}
export default PatternOptions