Skip to content

Commit

Permalink
fix: date for topics table
Browse files Browse the repository at this point in the history
  • Loading branch information
kevkevinpal committed Oct 31, 2023
1 parent 67236e1 commit a5415c3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
91 changes: 49 additions & 42 deletions src/components/SourcesTableModal/SourcesView/Topics/Table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IconButton, Table as MaterialTable, TableRow } from '@mui/material'
import moment from 'moment'
// import moment from 'moment'
import React, { useState } from 'react'
import { MdCancel, MdCheckCircle } from 'react-icons/md'
import { ClipLoader } from 'react-spinners'
Expand Down Expand Up @@ -52,48 +52,55 @@ const Table: React.FC<TopicTableProps> = ({ data, showMuted, setSelectedTopic })
</StyledTableHead>
{data?.length && (
<tbody>
{data?.map((i: Topic) => (
<StyledTableRow key={i.topic}>
<StyledTableCell className="empty" />
<StyledTableCell>{i.topic.replace(/\n/g, '')}</StyledTableCell>
<StyledTableCell>{i.edgeCount}</StyledTableCell>
<StyledTableCell>
{i.edgeList.map((topic) => (
<span key={topic}>{topic}</span>
))}
</StyledTableCell>
<StyledTableCell>
{i.date_added_to_graph ? <span>{moment(i.date_added_to_graph).format('MM.DD.YYYY')}</span> : null}
</StyledTableCell>
{data?.map((i: Topic) => {
const date = i.date_added_to_graph.toString()
// const date2 = i.date_added_to_graph.toString().split('.')[1]

<StyledTableCell className="cell-center">
<Flex direction="row" justify="space-between">
<div className="approve-wrapper">
{loadingId === i.ref_id ? (
<ClipLoader color={colors.white} size={16} />
) : (
<>
{i.muted_topic ? (
<IconWrapper className="centered" onClick={() => handleMute(i.ref_id, false)}>
<MdCheckCircle color={colors.primaryGreen} fontSize={24} />
</IconWrapper>
) : (
<IconWrapper className="centered" onClick={() => handleMute(i.ref_id, true)}>
<MdCancel color={colors.primaryRed} fontSize={24} />
</IconWrapper>
)}
</>
)}
</div>
</Flex>
</StyledTableCell>
<StyledTableCell>
<IconButton onClick={() => setSelectedTopic(i)}>
<SettingsIcon />
</IconButton>
</StyledTableCell>
</StyledTableRow>
))}
console.log(date, i.date_added_to_graph)

return (
<StyledTableRow key={i.topic}>
<StyledTableCell className="empty" />
<StyledTableCell>{i.topic.replace(/\n/g, '')}</StyledTableCell>
<StyledTableCell>{i.edgeCount}</StyledTableCell>
<StyledTableCell>
{i.edgeList.map((topic) => (
<span key={topic}>{topic}</span>
))}
</StyledTableCell>
<StyledTableCell>
<span>{new Date(Number(date) * 1000).toDateString()}</span>
</StyledTableCell>

<StyledTableCell className="cell-center">
<Flex direction="row" justify="space-between">
<div className="approve-wrapper">
{loadingId === i.ref_id ? (
<ClipLoader color={colors.white} size={16} />
) : (
<>
{i.muted_topic ? (
<IconWrapper className="centered" onClick={() => handleMute(i.ref_id, false)}>
<MdCheckCircle color={colors.primaryGreen} fontSize={24} />
</IconWrapper>
) : (
<IconWrapper className="centered" onClick={() => handleMute(i.ref_id, true)}>
<MdCancel color={colors.primaryRed} fontSize={24} />
</IconWrapper>
)}
</>
)}
</div>
</Flex>
</StyledTableCell>
<StyledTableCell>
<IconButton onClick={() => setSelectedTopic(i)}>
<SettingsIcon />
</IconButton>
</StyledTableCell>
</StyledTableRow>
)
})}
</tbody>
)}
</MaterialTable>
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export type Topic = {
muted_topic: string
edgeList: Array<string>
edgeCount: number
date_added_to_graph: null
date_added_to_graph: string
}

export type TopicFilter = {
Expand Down

0 comments on commit a5415c3

Please sign in to comment.