summaryrefslogtreecommitdiff
path: root/src/components/rules/RulesPageFab.tsx
blob: 91b618fabbbc748cdb63b3680a9650038bcac690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as React from 'react';
import { useTranslation } from 'react-i18next';

import { useUpdateAllRuleProviderItems } from '~/components/rules/rules.hooks';
import { Fab, position as fabPosition } from '~/components/shared/Fab';
import { RotateIcon } from '~/components/shared/RotateIcon';
import { ClashAPIConfig } from '~/types';

type RulesPageFabProps = {
  apiConfig: ClashAPIConfig;
};

export function RulesPageFab({ apiConfig }: RulesPageFabProps) {
  const [update, isLoading] = useUpdateAllRuleProviderItems(apiConfig);
  const { t } = useTranslation();
  return (
    <Fab
      icon={<RotateIcon isRotating={isLoading} />}
      text={t('update_all_rule_provider')}
      style={fabPosition}
      onClick={update}
    />
  );
}