summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2022-02-16 21:10:39 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2022-02-16 21:10:39 +0100
commita86f0a804bf8d1ff37d9027930aad1fdcbde3ad6 (patch)
treef9c8eff30e1f38cf7f3320590eadbdbe2af5291f /src
parente2aed74b7a9807bf87a9bf337c8a2e84a4bcbfde (diff)
downloadclient-1.4.0.tar.gz
client-1.4.0.tar.bz2
client-1.4.0.zip
Added a timestampv1.4.0.post1v1.4.0
Diffstat (limited to 'src')
-rw-r--r--src/components/RequestList/RequestList.tsx6
-rw-r--r--src/components/RequestSummary/RequestSummary.tsx15
-rw-r--r--src/hooks/useRequests.tsx1
-rw-r--r--src/index.tsx4
4 files changed, 23 insertions, 3 deletions
diff --git a/src/components/RequestList/RequestList.tsx b/src/components/RequestList/RequestList.tsx
index 06a78a3..acef47a 100644
--- a/src/components/RequestList/RequestList.tsx
+++ b/src/components/RequestList/RequestList.tsx
@@ -106,8 +106,7 @@ export default function RequestList({
106 ) 106 )
107 .filter( 107 .filter(
108 ([index, request]) => 108 ([index, request]) =>
109 search === "" || 109 search === "" || searchRegex.test(request.request.path)
110 searchRegex.test(`${request.request.method} ${request.request.path}`)
111 ); 110 );
112 }, [requests, search, enabledMethods, enableRegex]); 111 }, [requests, search, enabledMethods, enableRegex]);
113 112
@@ -168,6 +167,7 @@ export default function RequestList({
168 <RequestSummary 167 <RequestSummary
169 requestResponse={requestResponse} 168 requestResponse={requestResponse}
170 selected={selected} 169 selected={selected}
170 showTime
171 /> 171 />
172 </ListGroup.Item> 172 </ListGroup.Item>
173 ); 173 );
@@ -205,7 +205,7 @@ export default function RequestList({
205 onChange={() => setEnableRegex(!enableRegex)} 205 onChange={() => setEnableRegex(!enableRegex)}
206 /> 206 />
207 </Form.Group> 207 </Form.Group>
208 <Form.Group> 208 <Form.Group className="mb-4">
209 <Form.Label className="fw-bold">Method</Form.Label> 209 <Form.Label className="fw-bold">Method</Form.Label>
210 {Object.entries(methods).map(([method, enabled]) => ( 210 {Object.entries(methods).map(([method, enabled]) => (
211 <Form.Check 211 <Form.Check
diff --git a/src/components/RequestSummary/RequestSummary.tsx b/src/components/RequestSummary/RequestSummary.tsx
index 44254d0..49e6086 100644
--- a/src/components/RequestSummary/RequestSummary.tsx
+++ b/src/components/RequestSummary/RequestSummary.tsx
@@ -3,10 +3,12 @@ import * as React from "react";
3import classNames from "classnames"; 3import classNames from "classnames";
4 4
5import { Badge, Col, Row } from "react-bootstrap"; 5import { Badge, Col, Row } from "react-bootstrap";
6import dayjs from "dayjs";
6 7
7interface RequestSummaryProps { 8interface RequestSummaryProps {
8 selected?: boolean; 9 selected?: boolean;
9 requestResponse: RequestResponse; 10 requestResponse: RequestResponse;
11 showTime?: boolean;
10} 12}
11 13
12function isBetween(value: number, min: number, max: number) { 14function isBetween(value: number, min: number, max: number) {
@@ -32,9 +34,22 @@ function calcBadgeVariant(statusCode: number | undefined): string {
32export default function RequestSummary({ 34export default function RequestSummary({
33 requestResponse: { request, response }, 35 requestResponse: { request, response },
34 selected = false, 36 selected = false,
37 showTime = false,
35}: RequestSummaryProps) { 38}: RequestSummaryProps) {
36 return ( 39 return (
37 <Row> 40 <Row>
41 {showTime && (
42 <Col
43 className={classNames(
44 "flex-grow-0 d-flex align-items-center text-nowrap",
45 {
46 "text-muted": !selected,
47 }
48 )}
49 >
50 {dayjs(request.timestamp).format("LTS")}
51 </Col>
52 )}
38 <Col className="flex-grow-0 d-flex align-items-center"> 53 <Col className="flex-grow-0 d-flex align-items-center">
39 {request.method} 54 {request.method}
40 </Col> 55 </Col>
diff --git a/src/hooks/useRequests.tsx b/src/hooks/useRequests.tsx
index feba4fa..1361949 100644
--- a/src/hooks/useRequests.tsx
+++ b/src/hooks/useRequests.tsx
@@ -15,6 +15,7 @@ export type Method =
15 15
16export interface RequestPayload { 16export interface RequestPayload {
17 id: string; 17 id: string;
18 timestamp: string;
18 body: string; 19 body: string;
19 headers: Headers; 20 headers: Headers;
20 method: Method; 21 method: Method;
diff --git a/src/index.tsx b/src/index.tsx
index 83f8970..d83fd38 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -5,6 +5,10 @@ import App from "~/components/App/App";
5import "~/index.scss"; 5import "~/index.scss";
6import DarkModeProvider from "./contexts/DarkMode"; 6import DarkModeProvider from "./contexts/DarkMode";
7 7
8import dayjs from "dayjs";
9import localizedFormat from "dayjs/plugin/localizedFormat";
10dayjs.extend(localizedFormat);
11
8ReactDOM.render( 12ReactDOM.render(
9 <DarkModeProvider> 13 <DarkModeProvider>
10 <App /> 14 <App />