Fix history render

This commit is contained in:
Paulo Gustavo Veiga 2022-01-27 19:07:43 -08:00
parent dec26d64ba
commit 14db85ec5a
2 changed files with 27 additions and 3 deletions

View File

@ -252,7 +252,7 @@ export default class RestClient implements Client {
revertHistory(id: number, hid: number): Promise<void> { revertHistory(id: number, hid: number): Promise<void> {
const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { const handler = (success: () => void, reject: (error: ErrorInfo) => void) => {
axios axios
.post(`${this.baseUrl}/maps/${id}/history/${hid}`, null, { .post(`${this.baseUrl}/c/restful/maps/${id}/history/${hid}`, null, {
headers: { 'Content-Type': 'text/pain' }, headers: { 'Content-Type': 'text/pain' },
}) })
.then(() => { .then(() => {
@ -267,7 +267,31 @@ export default class RestClient implements Client {
} }
fetchHistory(id: number): Promise<ChangeHistory[]> { fetchHistory(id: number): Promise<ChangeHistory[]> {
throw new Error(`Method not implemented. ${id}`); const handler = (
success: (historyList: ChangeHistory[]) => void,
reject: (error: ErrorInfo) => void
) => {
axios
.get(`${this.baseUrl}/c/restful/maps/${id}/history/`, {
headers: { 'Content-Type': 'application/json' },
})
.then((response) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const historyList: ChangeHistory[] = (response.data.changes as any[]).map((h) => {
return {
id: h.id,
lastModificationBy: h.creator,
lastModificationTime: h.creationTime,
};
});
success(historyList);
})
.catch((error) => {
const errorInfo = this.parseResponseOnError(error.response);
reject(errorInfo);
});
};
return new Promise(handler);
} }
renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> { renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> {

View File

@ -99,7 +99,7 @@ const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
</TableCell> </TableCell>
<TableCell align="left"> <TableCell align="left">
<Link <Link
href={`c/maps/${mapId}/${row.id}/view`} href={`/c/maps/${mapId}/${row.id}/view`}
target="history" target="history"
> >
<FormattedMessage <FormattedMessage