Skip to content

Commit

Permalink
Set findings start and end time to UTC timezone (#957)
Browse files Browse the repository at this point in the history
* Set findings start and end time to UTC timezone

* Update findings dashboard styles
  • Loading branch information
majakomel authored Sep 6, 2024
1 parent 7e037be commit 788b4bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 40 deletions.
25 changes: 5 additions & 20 deletions pages/findings/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ const Dashboard = () => {
header: 'Reported by',
accessorKey: 'reported_by',
},
{
header: 'Email Address',
accessorKey: 'email_address',
},
{
header: 'Start Date',
accessorKey: 'start_time',
Expand All @@ -115,16 +111,13 @@ const Dashboard = () => {
cell: (info) => (
<>
<Link href={`/findings/edit/${info.getValue()}`}>
<button
className="mr-1 btn btn-primary-hollow btn-sm"
type="button"
>
<button className="btn btn-primary-hollow btn-sm" type="button">
{intl.formatMessage({ id: 'Findings.Dashboard.Edit' })}
</button>
</Link>
{info.row.original.published ? (
<button
className="btn btn-primary-hollow btn-sm p-1"
className="btn btn-primary-hollow btn-sm"
onClick={() => unpublish({ id: info.getValue() })}
disabled={isPublishMutating}
type="button"
Expand All @@ -133,7 +126,7 @@ const Dashboard = () => {
</button>
) : (
<button
className="btn btn-primary-hollow btn-sm mr-1"
className="btn btn-primary-hollow btn-sm"
onClick={() => publish({ id: info.getValue() })}
disabled={isUnpublishMutating}
type="button"
Expand Down Expand Up @@ -161,20 +154,12 @@ const Dashboard = () => {

return (
<>
{/* <Head>
<title></title>
</Head> */}
{user?.role === 'admin' ? (
<div className="container">
<ToastContainer />
<h1 className="mt-8">
{intl.formatMessage({ id: 'Findings.Dashboard.Title' })}
</h1>

{/*
th, td {
border: 1px solid gray;
} */}
<table className="w-full border-collapse">
<thead>
{table.getHeaderGroups().map((headerGroup) => (
Expand Down Expand Up @@ -228,9 +213,9 @@ th, td {
))}
</thead>
<tbody>
{table.getRowModel().rows.map((row) => {
{table.getRowModel().rows.map((row, i) => {
return (
<tr key={row.id}>
<tr key={row.id} className={i % 2 && 'bg-gray-100'}>
{row.getVisibleCells().map((cell) => {
return (
<td key={cell.id}>
Expand Down
33 changes: 13 additions & 20 deletions utils/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
const isGreater = (key, a, b) => {
a = a[key]
b = b[key]
const isGreater = (key, x, y) => {
const a = x[key]
const b = y[key]
return a < b ? -1 : a > b ? 1 : 0
}

export const sortByKey = (key, secondaryKey) => {
return (a, b) => {
let r = isGreater(key, a, b)
const r = isGreater(key, a, b)
if (secondaryKey === undefined) {
return r
}
if (r === 0) {
return isGreater(secondaryKey, a, b)
} else {
return r
}
return r
}
}

Expand All @@ -31,11 +30,8 @@ export const toCompactNumberUnit = (n) => {
return { unit, value }
}

export const truncateString = (s, maxStart, maxEnd) => {
export const truncateString = (s, maxStart, maxEnd = 0) => {
let truncatedString = ''
if (maxEnd === undefined) {
maxEnd = 0
}
if (maxStart + maxEnd > s.length) {
return s
}
Expand All @@ -51,16 +47,13 @@ export const getRange = (start, end) => {
}

export const formatLongDate = (date, locale) =>
new Intl.DateTimeFormat(locale, { dateStyle: 'long' }).format(new Date(date))

export const formatMediumDateTime = (date, locale) =>
new Intl.DateTimeFormat(locale, {
dateStyle: 'medium',
timeStyle: 'medium',
`${new Intl.DateTimeFormat(locale, {
dateStyle: 'long',
timeZone: 'UTC',
}).format(new Date(date))
}).format(new Date(date))} UTC`

export const formatMediumDate = (date, locale) =>
new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(
new Date(date),
)
`${new Intl.DateTimeFormat(locale, {
dateStyle: 'medium',
timeZone: 'UTC',
}).format(new Date(date))} UTC`

0 comments on commit 788b4bd

Please sign in to comment.