import { useI18n } from '@solid-primitives/i18n' import { IconReload } from '@tabler/icons-solidjs' import InfiniteScroll from 'solid-infinite-scroll' import { For, Show, createMemo, createSignal, onMount } from 'solid-js' import { twMerge } from 'tailwind-merge' import { Button } from '~/components' import { formatTimeFromNow, useStringBooleanMap } from '~/helpers' import { useRules } from '~/signals' export default () => { const [t] = useI18n() const { rules, rulesProviders, updateRules, updateAllRuleProvider, updateRuleProviderByName, } = useRules() const [maxRuleRender, setMaxRuleRender] = createSignal(100) const renderRules = createMemo(() => rules().slice(0, maxRuleRender())) onMount(updateRules) const { map: updatingMap, setWithCallback: setUpdatingMap } = useStringBooleanMap() const [allProviderIsUpdating, setAllProviderIsUpdating] = createSignal(false) const onUpdateProviderClick = (e: MouseEvent, name: string) => { e.stopPropagation() void setUpdatingMap(name, () => updateRuleProviderByName(name)) } const onUpdateAllProviderClick = async (e: MouseEvent) => { e.stopPropagation() setAllProviderIsUpdating(true) try { await updateAllRuleProvider() } catch {} setAllProviderIsUpdating(false) } return (

{t('rules')}

setMaxRuleRender(maxRuleRender() + 100)} > {(rule) => (
{rule.payload} {typeof rule.size === 'number' && rule.size !== -1 && ` (${rule.size})`}
{rule.type} :: {rule.proxy}
)}
0}>

{t('ruleProviders')}

{(rulesProvider) => (
{rulesProvider.name} ({rulesProvider.ruleCount})
{rulesProvider.vehicleType} / {rulesProvider.behavior} / {t('updated')} {formatTimeFromNow(rulesProvider.updatedAt)}
)}
) }