Skip to content

Commit

Permalink
fix: add reloading admin data after changes of id
Browse files Browse the repository at this point in the history
  • Loading branch information
akhmyrov committed Feb 21, 2023
1 parent 2ade12a commit c18cee5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bestdoctor/ke-beta",
"version": "13.3.0",
"version": "13.3.1",
"description": "BestDoctor back-office UI constructor",
"author": "pro100filipp",
"main": "dist/index.js",
Expand Down
14 changes: 10 additions & 4 deletions src/DetailView/RenderDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Это легаси
/* eslint-disable react/jsx-props-no-spreading */
import React, { useEffect, useRef, useState } from 'react'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useToast, Box, Spinner, Alert, AlertTitle, AlertIcon, AlertDescription } from '@chakra-ui/react'
import { useParams } from 'react-router-dom'
import { Row, Col } from 'react-flexbox-grid'
Expand Down Expand Up @@ -88,13 +88,19 @@ const RenderDetail = (props: RenderDetailProps): JSX.Element => {
}
setFavicon(favicon)

const refreshMainDetailObject = (): void => {
const refreshMainDetailObject = useCallback(() => {
setNeedRefreshDetailObject(true)
}
}, [])

// update data if id has changed
useEffect(() => {
refreshMainDetailObject()
}, [id, refreshMainDetailObject])

useEffect(() => {
const backendResourceUrl = admin.getResource(id)
if (needRefreshDetailObject) {
const backendResourceUrl = admin.getResource(id)

provider
.getObject(backendResourceUrl)
.then(async (res) => {
Expand Down

0 comments on commit c18cee5

Please sign in to comment.