Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | import { Dispatch, FC } from 'react'; import { Status } from '../../../models/status'; import { ErrorResponse } from '../../../models/errorResponse'; import { OkResponse } from '../../../models/okResponse'; import { Pending } from '../../../models/pending'; import { useFetchUpdateColor } from '../../../hooks/useFetchUpdateColor'; import styled from 'styled-components'; type Props = { id: number; hex_color_code: string; status: Status; setResult: Dispatch<React.SetStateAction<ErrorResponse | OkResponse | Pending | null>>; }; const StyledButton = styled.button` width: 120px; padding: 5px 20px; background-color: #caad63; border: none; font-size: 1.6rem; cursor: pointer; `; const StatusColorButton: FC<Props> = (props) => { const handleClick = async (): Promise<void> => { props.setResult('pending'); const result: OkResponse | ErrorResponse = await useFetchUpdateColor( props.id, props.hex_color_code, props.status, 'status' ); props.setResult(result); }; return <StyledButton onClick={handleClick}>変更する</StyledButton>; }; export default StatusColorButton; |