add setting

This commit is contained in:
hamid zarghami
2026-05-06 12:33:23 +03:30
parent e15dc76468
commit 192036e519
7 changed files with 384 additions and 30 deletions
+7 -5
View File
@@ -22,17 +22,19 @@ const Editor: FC = () => {
}
}, [])
const [isLayersPanelOpen, setIsLayersPanelOpen] = useState(false)
const { loadPages, pages } = useEditorStore()
const { loadPages, pages, documentSettings } = useEditorStore()
const { data } = useGetCatalogById(id!)
const { scheduleUpdate, isSaving } = useUpdateCatalog()
useEffect(() => {
if (data?.data && data?.data?.content) {
const json = JSON.parse(data?.data?.content)
console.log(json);
if (!json) return
if (json) {
if (Array.isArray(json)) {
loadPages(json)
} else if (json.pages) {
loadPages(json.pages, json.documentSettings)
}
}
@@ -45,11 +47,11 @@ const Editor: FC = () => {
scheduleUpdate({
id,
content: JSON.stringify(pages),
content: JSON.stringify({ pages, documentSettings }),
})
// عمداً scheduleUpdate را در وابستگی‌ها نیاوردیم تا از لوپ ذخیره‌سازی جلوگیری شود
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id, pages])
}, [id, pages, documentSettings])
return (