All files / src/components/search_item SearchItemResult.tsx

0% Statements 0/42
100% Branches 1/1
100% Functions 1/1
0% Lines 0/42

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110                                                                                                                                                                                                                           
import { FC } from 'react';
import { SearchItemResponse } from '../../models/searchItemResponse';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
 
type Props = {
  item: SearchItemResponse;
};
 
const StyledBox = styled.div`
  margin: 30px auto;
  padding: 0;
  width: 90%;
  max-width: 800px;
  background-color: #f6f6f6;
  border: #b3b3b3 1px solid;
`;
 
const StyledName = styled.h2`
  font-size: 2.8rem;
  font-weight: 400;
  margin: 0;
  padding: 0 0 0 15px;
`;
 
const StyledRent = styled.p`
  font-size: 1.6rem;
  background-color: #c7d01c;
  margin: 6px 15px 0 10px;
  padding: 1px 10px;
  width: 80px;
  height: 25.5px;
`;
 
const StyledLabel = styled.div`
  display: flex;
  width: 100%;
  margin: 15px 0 0 0;
  padding: 0;
`;
 
const StyledTable = styled.table`
  font-size: 1.6rem;
  margin: 0;
  padding: 15px 15px 0 15px;
`;
 
const StyledTdLabel = styled.td`
  padding: 0 15px 0 0;
`;
 
const StyledTdBody = styled.td`
  padding: 0 0 0 0;
`;
 
const StyledButton = styled.div`
  margin: 0;
  padding: 5px 20px;
  background-color: #caad63;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  width: fit-content;
  color: #000000;
`;
 
const StyledButtonWrapper = styled.div`
  display: flex;
  justify-content: end;
  width: calc(100% - 15px);
  margin: 0;
  padding: 15px 15px 15px 0;
`;
 
const SearchItemResult: FC<Props> = (props) => {
  return (
    <StyledBox>
      <StyledLabel>
        <StyledName>{props.item.name}</StyledName>
        {props.item.is_rent ? <StyledRent>貸し出し中</StyledRent> : <></>}
      </StyledLabel>
      <StyledTable>
        <tbody>
          <tr>
            <StyledTdLabel>ラベル ID</StyledTdLabel>
            <td>{props.item.visible_id}</td>
          </tr>
          <tr>
            <StyledTdLabel>端子名</StyledTdLabel>
            <StyledTdBody>{props.item.connector.join('、 ')}</StyledTdBody>
          </tr>
          <tr>
            <StyledTdLabel>ケーブル識別色パターン</StyledTdLabel>
            <StyledTdBody>{props.item.color}</StyledTdBody>
          </tr>
        </tbody>
      </StyledTable>
      <StyledButtonWrapper>
        <StyledButton>
          <Link to={`/item/${props.item.id}`} style={{ textDecoration: 'none' }}>
            詳細
          </Link>
        </StyledButton>
      </StyledButtonWrapper>
    </StyledBox>
  );
};
 
export default SearchItemResult;