Skip to content

Commit 13f3e76

Browse files
committed
content history same fix
1 parent 7301939 commit 13f3e76

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

apps/sensenet/src/components/Home.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'
1717
import { useRepository } from '@sensenet/hooks-react'
1818
import React, { lazy, useEffect, useState } from 'react'
1919
// import { useAuth } from '../context/auth-provider'
20+
import { useLocalization } from '../hooks'
2021
import { DateTimeFormatter } from './grid/Formatters/DateTimeFormatter'
2122

2223
const DashboardComponent = lazy(() => import(/* webpackChunkName: "dashboard" */ './dashboard'))
@@ -176,14 +177,15 @@ const useStyles = makeStyles((theme: Theme) =>
176177
export const Home = () => {
177178
const classes = useStyles()
178179
const repo = useRepository()
180+
const localization = useLocalization().home
179181
// const { user } = useAuth()
180182

181183
const [lastMinuteLogs, setLastMinuteLogs] = useState<any[]>([])
182184
// const [myLogs, setMyLogs] = useState<any[]>([])
183185
const [hasGetLogs, setHasGetLogs] = useState(false)
184186
// const [hasGetTopLogsByUser, setHasGetTopLogsByUser] = useState(false)
185187
const [canContentHistory, setCanContentHistory] = useState(false)
186-
const [contentHistory, setContentHistory] = useState<any[]>([])
188+
const [contentHistories, setContentHistories] = useState<Record<string, any[]>>({})
187189

188190
useEffect(() => {
189191
async function getActionsAndLogs() {
@@ -279,10 +281,10 @@ export const Home = () => {
279281
<TableRow>
280282
<TableCell />
281283
<TableCell>
282-
<strong>Old Value</strong>
284+
<strong>{localization.oldValue}</strong>
283285
</TableCell>
284286
<TableCell>
285-
<strong>New Value</strong>
287+
<strong>{localization.newValue}</strong>
286288
</TableCell>
287289
</TableRow>
288290
</TableHead>
@@ -309,8 +311,10 @@ export const Home = () => {
309311
method: 'GET',
310312
oDataOptions: { contentId, limit: 10 } as any,
311313
})
312-
console.log('response:', response)
313-
setContentHistory(response || [])
314+
setContentHistories((prev) => ({
315+
...prev,
316+
[contentId]: response || [],
317+
}))
314318
} catch (error: any) {
315319
console.error('GetTopLogsByContentId error:', error.message)
316320
}
@@ -323,7 +327,7 @@ export const Home = () => {
323327
<div className={classes.gridsCont}>
324328
{hasGetLogs && (
325329
<div className={classes.gridCont}>
326-
<h2>Latest Changes</h2>
330+
<h2>{localization.latestChanges}</h2>
327331
{lastMinuteLogs.map((log, index) => {
328332
const hasChanges = log.ExtendedProperties?.ChangedData?.length > 0
329333
return (
@@ -360,10 +364,10 @@ export const Home = () => {
360364
aria-controls="content-history-content"
361365
id="content-history-header"
362366
className={''}>
363-
<Typography>Content History</Typography>
367+
<Typography>{localization.contentHistory}</Typography>
364368
</AccordionSummary>
365369
<AccordionDetails style={{ display: 'flex', flexDirection: 'column' }}>
366-
{contentHistory.map((historyLog, idx) => (
370+
{(contentHistories[log.ContentId] || []).map((historyLog, idx) => (
367371
<div key={idx}>{getTable(historyLog)}</div>
368372
))}
369373
</AccordionDetails>

apps/sensenet/src/localization/default.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,12 @@ const values = {
691691
cancel: 'Cancel',
692692
success: 'Succesfull Operation',
693693
},
694+
home: {
695+
latestChanges: 'Latest Changes',
696+
oldValue: 'Old Value',
697+
newValue: 'New Value',
698+
contentHistory: 'Content History',
699+
},
694700
}
695701

696702
export default values

0 commit comments

Comments
 (0)