summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2024-10-11 12:11:28 +0530
committerSunil Shetye2024-10-11 12:38:22 +0530
commitedb902ac9a71b21206df8f27624c81cb8aa4f07f (patch)
treec723ad6e9131e601407710f701f8091f849838c4
parent63bff49a7998750fbc196200017d4e1f9fd720cc (diff)
downloadCommon-Interface-Project-edb902ac9a71b21206df8f27624c81cb8aa4f07f.tar.gz
Common-Interface-Project-edb902ac9a71b21206df8f27624c81cb8aa4f07f.tar.bz2
Common-Interface-Project-edb902ac9a71b21206df8f27624c81cb8aa4f07f.zip
move getDate to utils
-rw-r--r--blocks/eda-frontend/src/components/Dashboard/SchematicCard.js10
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/Header.js10
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js9
-rw-r--r--blocks/eda-frontend/src/utils/GalleryUtils.js16
4 files changed, 19 insertions, 26 deletions
diff --git a/blocks/eda-frontend/src/components/Dashboard/SchematicCard.js b/blocks/eda-frontend/src/components/Dashboard/SchematicCard.js
index 8431639f..b3c2f085 100644
--- a/blocks/eda-frontend/src/components/Dashboard/SchematicCard.js
+++ b/blocks/eda-frontend/src/components/Dashboard/SchematicCard.js
@@ -8,6 +8,7 @@ import DeleteIcon from '@material-ui/icons/Delete'
import { useDispatch } from 'react-redux'
import { deleteSchematic } from '../../redux/actions/index'
import MuiAlert from '@material-ui/lab/Alert'
+import { getDate } from '../../utils/GalleryUtils'
const useStyles = makeStyles((theme) => ({
media: {
@@ -93,15 +94,6 @@ function timeSince (jsonDate) {
return Math.floor(seconds) + ' seconds'
}
-// Display schematic created date (e.g : Created On 29 Jun 2020)
-function getDate (jsonDate) {
- const json = jsonDate
- const date = new Date(json)
- const dateTimeFormat = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short', day: '2-digit' })
- const [{ value: month }, , { value: day }, , { value: year }] = dateTimeFormat.formatToParts(date)
- return `${day}-${month}-${year}`
-}
-
// Card displaying overview of onCloud saved schematic.
export default function SchematicCard ({ sch }) {
const classes = useStyles()
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Header.js b/blocks/eda-frontend/src/components/SchematicEditor/Header.js
index ca84467c..437e8b0a 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/Header.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/Header.js
@@ -32,6 +32,7 @@ import { deepPurple } from '@material-ui/core/colors'
import logo from '../../static/favicon.ico'
import { setTitle, logout, setSchTitle, setSchShared } from '../../redux/actions/index'
import store from '../../redux/store'
+import { getDateTime as getDate } from '../../utils/GalleryUtils'
const useStyles = makeStyles((theme) => ({
toolbarTitle: {
@@ -170,15 +171,6 @@ function Header () {
}
}
- // handle display format of last saved status
- function getDate (jsonDate) {
- const json = jsonDate
- const date = new Date(json)
- const dateTimeFormat = new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
- const [{ value: month }, , { value: day }, , { value: hour }, , { value: minute }, , { value: second }] = dateTimeFormat.formatToParts(date)
- return `${day} ${month} ${hour}:${minute}:${second}`
- }
-
// handle Copy Share Url
const textAreaRef = useRef(null)
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js b/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
index 79b9ca51..601e276e 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
@@ -37,6 +37,7 @@ import { useSelector, useDispatch } from 'react-redux'
import { fetchSchematics, fetchSchematic, loadGallery } from '../../redux/actions/index'
import GallerySchSample from '../../utils/GallerySchSample'
import { blue } from '@material-ui/core/colors'
+import { getDateTime as getDate } from '../../utils/GalleryUtils'
const Transition = forwardRef(function Transition (props, ref) {
return <Slide direction='up' ref={ref} {...props} />
@@ -387,14 +388,6 @@ export function OpenSchDialog (props) {
const auth = useSelector(state => state.authReducer)
const schematics = useSelector(state => state.dashboardReducer.schematics)
- function getDate (jsonDate) {
- const json = jsonDate
- const date = new Date(json)
- const dateTimeFormat = new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
- const [{ value: month }, , { value: day }, , { value: hour }, , { value: minute }, , { value: second }] = dateTimeFormat.formatToParts(date)
- return `${day} ${month} ${hour}:${minute}:${second}`
- }
-
const dispatch = useDispatch()
const title = 'Open ' + process.env.REACT_APP_DIAGRAM_NAME
diff --git a/blocks/eda-frontend/src/utils/GalleryUtils.js b/blocks/eda-frontend/src/utils/GalleryUtils.js
index 54fd408e..5a4363a1 100644
--- a/blocks/eda-frontend/src/utils/GalleryUtils.js
+++ b/blocks/eda-frontend/src/utils/GalleryUtils.js
@@ -41,3 +41,19 @@ export const transformXcos = async (xmlDoc) => {
xmlDoc = processor.transformToDocument(xmlDoc)
return xmlDoc
}
+
+// handle display format of last saved status
+export const getDateTime = (jsonDateTime) => {
+ const date = new Date(jsonDateTime)
+ const dateTimeFormat = new Intl.DateTimeFormat('en', { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
+ const [{ value: month }, , { value: day }, , { value: hour }, , { value: minute }, , { value: second }] = dateTimeFormat.formatToParts(date)
+ return `${day} ${month} ${hour}:${minute}:${second}`
+}
+
+// Display diagram created date (e.g : Created On 29 Jun 2020)
+export const getDate = (jsonDate) => {
+ const date = new Date(jsonDate)
+ const dateTimeFormat = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short', day: '2-digit' })
+ const [{ value: month }, , { value: day }, , { value: year }] = dateTimeFormat.formatToParts(date)
+ return `${day}-${month}-${year}`
+}