kafka-ui/kafka-ui-react-app/src/components/Topics/shared/Form/TimeToRetainBtn.tsx
Mgrdich 913b8921b4
Issues/1738 Time to retain data rendenring Styling (#1780)
* TimeToRetainBtn Fix Styling during non active state + write test suites for these components

* TimeToRetainBtn Fix Style during initial render phase

* TimeToRetainBtn Spec suites changes
2022-03-30 16:33:38 +03:00

28 lines
676 B
TypeScript

import React from 'react';
import { useFormContext } from 'react-hook-form';
import { MILLISECONDS_IN_WEEK } from 'lib/constants';
import * as S from './TopicForm.styled';
export interface Props {
inputName: string;
text: string;
value: number;
}
const TimeToRetainBtn: React.FC<Props> = ({ inputName, text, value }) => {
const { setValue, watch } = useFormContext();
const watchedValue = watch(inputName, MILLISECONDS_IN_WEEK.toString());
return (
<S.Button
isActive={parseFloat(watchedValue) === value}
type="button"
onClick={() => setValue(inputName, value)}
>
{text}
</S.Button>
);
};
export default TimeToRetainBtn;