From 871a85d9343cf49646d13dc455c062efadcb959a Mon Sep 17 00:00:00 2001
From: Tom van der Lee <tom@vanderlee.io>
Date: Sat, 12 Feb 2022 11:33:52 +0100
Subject: Beatified code

---
 src/components/RequestSummary/RequestSummary.tsx | 41 +++++++++++++-----------
 1 file changed, 23 insertions(+), 18 deletions(-)

(limited to 'src/components/RequestSummary/RequestSummary.tsx')

diff --git a/src/components/RequestSummary/RequestSummary.tsx b/src/components/RequestSummary/RequestSummary.tsx
index b3e7ddc..db2f69c 100644
--- a/src/components/RequestSummary/RequestSummary.tsx
+++ b/src/components/RequestSummary/RequestSummary.tsx
@@ -1,49 +1,54 @@
-import {RequestResponse} from "~hooks/useRequests";
+import { RequestResponse } from "~hooks/useRequests";
 import * as React from "react";
 import classNames from "classnames";
 
-import {Badge, Card, Col, Row} from "react-bootstrap";
+import { Badge, Card, Col, Row } from "react-bootstrap";
 
 interface RequestSummaryProps {
-  selected?: boolean
-  requestResponse: RequestResponse
+  selected?: boolean;
+  requestResponse: RequestResponse;
 }
 
 function isBetween(value: number, min: number, max: number) {
-  return value >= min && value <= max
+  return value >= min && value <= max;
 }
 
 function calcBadgeVariant(statusCode: number | undefined): string {
   if (statusCode === undefined) {
-    return 'secondary';
+    return "secondary";
   } else if (isBetween(statusCode, 100, 199)) {
-    return 'info';
+    return "info";
   } else if (isBetween(statusCode, 200, 299)) {
-    return 'success';
+    return "success";
   } else if (isBetween(statusCode, 300, 399)) {
-    return 'primary';
+    return "primary";
   } else if (isBetween(statusCode, 400, 499)) {
-    return 'danger';
+    return "danger";
   } else if (isBetween(statusCode, 500, 599)) {
-    return 'warning';
+    return "warning";
   }
 }
 
-export default function RequestSummary({ requestResponse: { request, response }, selected = false }: RequestSummaryProps) {
+export default function RequestSummary({
+  requestResponse: { request, response },
+  selected = false,
+}: RequestSummaryProps) {
   return (
     <Row>
-      <Col className='flex-grow-0 d-flex align-items-center'>{request.method}</Col>
-      <Col className='flex-grow-1'>{ request.path }</Col>
-      <Col className='flex-grow-0 d-flex align-items-center'>
+      <Col className="flex-grow-0 d-flex align-items-center">
+        {request.method}
+      </Col>
+      <Col className="flex-grow-1">{request.path}</Col>
+      <Col className="flex-grow-0 d-flex align-items-center">
         <Badge
           className={classNames({
-            'border': selected,
+            border: selected,
           })}
           bg={calcBadgeVariant(response?.status)}
         >
-          { response?.status ?? 'Loading...'}
+          {response?.status ?? "Loading..."}
         </Badge>
       </Col>
     </Row>
-  )
+  );
 }
-- 
cgit v1.2.3

