usePreview.ts 580 Bytes
import { fetchRouteParamsLocation, JSONParse, } from '@/utils'
import { getDataView } from '@/api/external/contentSave/content'
import { ChartEditStorageType } from '..'

export const getSessionStorageInfo = async (): Promise<ChartEditStorageType> => {
  const id = fetchRouteParamsLocation()

  const res = await getDataView(id)
  if (res) {
    const { dataViewContent, dataViewName, dataViewId } = res
    return { ...JSONParse(dataViewContent?.content), id: dataViewId, projectName: dataViewName } as ChartEditStorageType
  }
  return {} as unknown as ChartEditStorageType
}