Skip to content

Commit 1637235

Browse files
SamSam
Sam
authored and
Sam
committed
refactor code
1 parent 909c524 commit 1637235

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

src/components/Issue/Issue.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ export interface Data {
1313
closedAt: string | undefined;
1414
}
1515

16+
function generateDate(date: string) {
17+
const time = new Date(date).toLocaleTimeString("en", {
18+
timeStyle: "medium",
19+
hour12: false,
20+
});
21+
return `${date.substring(0, 10)} ${time}`;
22+
}
23+
1624
export function Issue(issue: IssueData) {
1725
return (
1826
<tr>
@@ -31,7 +39,7 @@ export function Issue(issue: IssueData) {
3139
</div>
3240
<div className="text-xs leading-5 text-gray-400 font-bold">
3341
{issue.issueState === "OPEN"
34-
? `Created at: ${issue.issueData.createdAt}`
42+
? `Created at: ${generateDate(issue.issueData.createdAt)}`
3543
: `Closed at: ${issue.issueData.closedAt}`}
3644
</div>
3745
</td>

src/components/IssueComment/IssueComment.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ export interface CommentData {
44
}
55

66
export function IssueComment(comment: CommentData) {
7-
const issueDate = comment.publishedAt;
8-
9-
const time = new Date(issueDate).toLocaleTimeString("en", {
10-
timeStyle: "medium",
11-
hour12: false,
12-
});
13-
14-
const date = issueDate.substring(0, 10);
7+
8+
function generateDate(date: string) {
9+
const time = new Date(date).toLocaleTimeString("en", {
10+
timeStyle: "medium",
11+
hour12: false,
12+
});
13+
return `${date.substring(0, 10)} ${time}`;
14+
}
1515

1616
return (
1717
<>
@@ -31,7 +31,7 @@ export function IssueComment(comment: CommentData) {
3131
</p>
3232
</div>
3333
<p className="text-gray-400 text-sm">
34-
{date} {time}
34+
{generateDate(comment.publishedAt)}
3535
</p>
3636
</div>
3737
</div>

src/components/IssuesTable/IssuesTable.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function IssuesTable(issuesTableData: IssuesTableData) {
7878
containerClassName="pagination"
7979
activeClassName="active"
8080
className="flex justify-around w-1/2 rounded-sm border-2 border-indigo-500/75"
81+
8182
/>
8283
</div>
8384
</div>

src/components/NavBar/NavBar.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.navBarWrapper {
2-
@apply bg-gray-800 flex gap-4 text-white justify-start pb-4 mb-10;
2+
@apply bg-gray-800 flex gap-4 text-white justify-start pb-1.5 mb-10;
33
}

src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { BrowserRouter } from 'react-router-dom';
1616
const client = new ApolloClient({
1717
uri: 'https://api.github.com/graphql',
1818
cache: new InMemoryCache(),
19-
headers:{"Authorization": "Bearer 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"}
19+
headers:{"Authorization": "Bearer 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"}
2020
});
2121

2222
ReactDOM.render(

0 commit comments

Comments
 (0)