fix error
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# VITE_API_URL = 'https://dpage.liara.run'
|
|
||||||
VITE_API_URL = 'http://188.121.103.8:4141'
|
VITE_API_URL = 'http://188.121.103.8:4141'
|
||||||
|
# VITE_API_URL = 'http://188.121.103.8:4141'
|
||||||
VITE_TOKEN_NAME = 'dpage-editor-t'
|
VITE_TOKEN_NAME = 'dpage-editor-t'
|
||||||
VITE_REFRESH_TOKEN_NAME = 'dpage-editor-refresh-t'
|
VITE_REFRESH_TOKEN_NAME = 'dpage-editor-refresh-t'
|
||||||
BIN
Binary file not shown.
Generated
+3325
-40
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@liara/cli": "^9.4.7",
|
||||||
"@radix-ui/react-switch": "^1.2.6",
|
"@radix-ui/react-switch": "^1.2.6",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
"@tanstack/react-query": "^5.90.21",
|
"@tanstack/react-query": "^5.90.21",
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ type EditorStoreType = {
|
|||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
value: string;
|
value: string;
|
||||||
} | null
|
} | null,
|
||||||
) => void;
|
) => void;
|
||||||
addTable: (x: number, y: number, rows?: number, cols?: number) => void;
|
addTable: (x: number, y: number, rows?: number, cols?: number) => void;
|
||||||
addRow: (tableId: string) => void;
|
addRow: (tableId: string) => void;
|
||||||
@@ -121,12 +121,12 @@ type EditorStoreType = {
|
|||||||
changeCellBackground: (
|
changeCellBackground: (
|
||||||
tableId: string,
|
tableId: string,
|
||||||
cellId: string,
|
cellId: string,
|
||||||
color: string
|
color: string,
|
||||||
) => void;
|
) => void;
|
||||||
applyTableResize: (
|
applyTableResize: (
|
||||||
tableId: string,
|
tableId: string,
|
||||||
newWidth: number,
|
newWidth: number,
|
||||||
newHeight: number
|
newHeight: number,
|
||||||
) => void;
|
) => void;
|
||||||
stageRef: React.RefObject<Konva.Stage | null> | null;
|
stageRef: React.RefObject<Konva.Stage | null> | null;
|
||||||
setStageRef: (ref: React.RefObject<Konva.Stage | null>) => void;
|
setStageRef: (ref: React.RefObject<Konva.Stage | null>) => void;
|
||||||
@@ -155,7 +155,7 @@ const createInitialCells = (
|
|||||||
rows: number,
|
rows: number,
|
||||||
cols: number,
|
cols: number,
|
||||||
cellWidth: number,
|
cellWidth: number,
|
||||||
cellHeight: number
|
cellHeight: number,
|
||||||
): Record<string, TableCell> => {
|
): Record<string, TableCell> => {
|
||||||
const cells: Record<string, TableCell> = {};
|
const cells: Record<string, TableCell> = {};
|
||||||
for (let row = 0; row < rows; row++) {
|
for (let row = 0; row < rows; row++) {
|
||||||
@@ -174,7 +174,7 @@ const createInitialCells = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createInitialPage = (name: string): Page => ({
|
const createInitialPage = (name: string): Page => ({
|
||||||
id: `page-${crypto.randomUUID()}`,
|
id: `page-${crypto.randomUUID?.()}`,
|
||||||
name,
|
name,
|
||||||
objects: [],
|
objects: [],
|
||||||
});
|
});
|
||||||
@@ -193,7 +193,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
const state = get();
|
const state = get();
|
||||||
if (state.currentPageId) {
|
if (state.currentPageId) {
|
||||||
const currentPage = state.pages.find(
|
const currentPage = state.pages.find(
|
||||||
(p) => p.id === state.currentPageId
|
(p) => p.id === state.currentPageId,
|
||||||
);
|
);
|
||||||
if (currentPage) {
|
if (currentPage) {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
@@ -201,7 +201,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? { ...p, objects: [...p.objects, object] }
|
? { ...p, objects: [...p.objects, object] }
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
@@ -214,24 +214,24 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
if (state.currentPageId) {
|
if (state.currentPageId) {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
objects: state.objects.map((obj) =>
|
objects: state.objects.map((obj) =>
|
||||||
obj.id === id ? { ...obj, ...updates } : obj
|
obj.id === id ? { ...obj, ...updates } : obj,
|
||||||
),
|
),
|
||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? {
|
? {
|
||||||
...p,
|
...p,
|
||||||
objects: p.objects.map((obj) =>
|
objects: p.objects.map((obj) =>
|
||||||
obj.id === id ? { ...obj, ...updates } : obj
|
obj.id === id ? { ...obj, ...updates } : obj,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
objects: state.objects.map((obj) =>
|
objects: state.objects.map((obj) =>
|
||||||
obj.id === id ? { ...obj, ...updates } : obj
|
obj.id === id ? { ...obj, ...updates } : obj,
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@@ -243,7 +243,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? { ...p, objects: p.objects.filter((obj) => obj.id !== id) }
|
? { ...p, objects: p.objects.filter((obj) => obj.id !== id) }
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
selectedObjectId:
|
selectedObjectId:
|
||||||
state.selectedObjectId === id ? null : state.selectedObjectId,
|
state.selectedObjectId === id ? null : state.selectedObjectId,
|
||||||
@@ -282,8 +282,8 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
...cell,
|
...cell,
|
||||||
id: `cell-${crypto.randomUUID()}`,
|
id: `cell-${crypto.randomUUID()}`,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -295,7 +295,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? { ...p, objects: [...p.objects, duplicatedObject] }
|
? { ...p, objects: [...p.objects, duplicatedObject] }
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
selectedObjectId: duplicatedObject.id,
|
selectedObjectId: duplicatedObject.id,
|
||||||
}));
|
}));
|
||||||
@@ -333,7 +333,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
removeFromSelection: (id) => {
|
removeFromSelection: (id) => {
|
||||||
const state = get();
|
const state = get();
|
||||||
const newIds = state.selectedObjectIds.filter(
|
const newIds = state.selectedObjectIds.filter(
|
||||||
(selectedId) => selectedId !== id
|
(selectedId) => selectedId !== id,
|
||||||
);
|
);
|
||||||
set({
|
set({
|
||||||
selectedObjectIds: newIds,
|
selectedObjectIds: newIds,
|
||||||
@@ -592,7 +592,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const newPage: Page = {
|
const newPage: Page = {
|
||||||
id: `page-${crypto.randomUUID()}`,
|
id: `page-${crypto.randomUUID?.()}`,
|
||||||
name: `${pageToDuplicate.name} (کپی)`,
|
name: `${pageToDuplicate.name} (کپی)`,
|
||||||
objects: duplicatedObjects,
|
objects: duplicatedObjects,
|
||||||
};
|
};
|
||||||
@@ -628,7 +628,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
// Save current objects to current page before switching
|
// Save current objects to current page before switching
|
||||||
const updatedPages = state.currentPageId
|
const updatedPages = state.currentPageId
|
||||||
? state.pages.map((p) =>
|
? state.pages.map((p) =>
|
||||||
p.id === state.currentPageId ? { ...p, objects: state.objects } : p
|
p.id === state.currentPageId ? { ...p, objects: state.objects } : p,
|
||||||
)
|
)
|
||||||
: state.pages;
|
: state.pages;
|
||||||
|
|
||||||
@@ -660,17 +660,17 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
if (state.currentPageId) {
|
if (state.currentPageId) {
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
objects: state.objects.map((obj) =>
|
objects: state.objects.map((obj) =>
|
||||||
obj.id === id ? { ...obj, visible: newVisible } : obj
|
obj.id === id ? { ...obj, visible: newVisible } : obj,
|
||||||
),
|
),
|
||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? {
|
? {
|
||||||
...p,
|
...p,
|
||||||
objects: p.objects.map((obj) =>
|
objects: p.objects.map((obj) =>
|
||||||
obj.id === id ? { ...obj, visible: newVisible } : obj
|
obj.id === id ? { ...obj, visible: newVisible } : obj,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
selectedObjectId: shouldDeselect ? null : state.selectedObjectId,
|
selectedObjectId: shouldDeselect ? null : state.selectedObjectId,
|
||||||
selectedTableId: shouldDeselect ? null : state.selectedTableId,
|
selectedTableId: shouldDeselect ? null : state.selectedTableId,
|
||||||
@@ -679,7 +679,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
}
|
}
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
objects: state.objects.map((obj) =>
|
objects: state.objects.map((obj) =>
|
||||||
obj.id === id ? { ...obj, visible: newVisible } : obj
|
obj.id === id ? { ...obj, visible: newVisible } : obj,
|
||||||
),
|
),
|
||||||
selectedObjectId: shouldDeselect ? null : state.selectedObjectId,
|
selectedObjectId: shouldDeselect ? null : state.selectedObjectId,
|
||||||
selectedTableId: shouldDeselect ? null : state.selectedTableId,
|
selectedTableId: shouldDeselect ? null : state.selectedTableId,
|
||||||
@@ -710,7 +710,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
} else if (obj?.groupId) {
|
} else if (obj?.groupId) {
|
||||||
// اگر این آبجکت در یک گروه است، همه آبجکتهای آن گروه را اضافه کن
|
// اگر این آبجکت در یک گروه است، همه آبجکتهای آن گروه را اضافه کن
|
||||||
const oldGroupMembers = state.objects.filter(
|
const oldGroupMembers = state.objects.filter(
|
||||||
(o) => o.groupId === obj.groupId
|
(o) => o.groupId === obj.groupId,
|
||||||
);
|
);
|
||||||
oldGroupMembers.forEach((member) => {
|
oldGroupMembers.forEach((member) => {
|
||||||
if (member.type !== "group") {
|
if (member.type !== "group") {
|
||||||
@@ -729,7 +729,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
|
|
||||||
const groupId = `group-${crypto.randomUUID()}`;
|
const groupId = `group-${crypto.randomUUID()}`;
|
||||||
const objectsToGroup = state.objects.filter(
|
const objectsToGroup = state.objects.filter(
|
||||||
(obj) => allObjectIdsToGroup.has(obj.id) && obj.type !== "group"
|
(obj) => allObjectIdsToGroup.has(obj.id) && obj.type !== "group",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (objectsToGroup.length === 0) return;
|
if (objectsToGroup.length === 0) return;
|
||||||
@@ -891,7 +891,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? { ...p, objects: [...updateObjects(p.objects), groupObject] }
|
? { ...p, objects: [...updateObjects(p.objects), groupObject] }
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
selectedObjectId: groupId,
|
selectedObjectId: groupId,
|
||||||
selectedObjectIds: [groupId],
|
selectedObjectIds: [groupId],
|
||||||
@@ -910,7 +910,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
const updateObjects = (objects: EditorObject[]) =>
|
const updateObjects = (objects: EditorObject[]) =>
|
||||||
objects
|
objects
|
||||||
.map((obj) =>
|
.map((obj) =>
|
||||||
obj.groupId === groupId ? { ...obj, groupId: undefined } : obj
|
obj.groupId === groupId ? { ...obj, groupId: undefined } : obj,
|
||||||
)
|
)
|
||||||
.filter((obj) => obj.id !== groupId); // حذف group object
|
.filter((obj) => obj.id !== groupId); // حذف group object
|
||||||
|
|
||||||
@@ -920,7 +920,7 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
|||||||
pages: state.pages.map((p) =>
|
pages: state.pages.map((p) =>
|
||||||
p.id === state.currentPageId
|
p.id === state.currentPageId
|
||||||
? { ...p, objects: updateObjects(p.objects) }
|
? { ...p, objects: updateObjects(p.objects) }
|
||||||
: p
|
: p,
|
||||||
),
|
),
|
||||||
selectedObjectId: null,
|
selectedObjectId: null,
|
||||||
selectedObjectIds: [],
|
selectedObjectIds: [],
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const BuyCatalog: FC = () => {
|
|||||||
mutate({ count: count }, {
|
mutate({ count: count }, {
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
// TODO منتقل بشه به صفحه صورت حساب
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast(extractErrorMessage(error), 'error')
|
toast(extractErrorMessage(error), 'error')
|
||||||
|
|||||||
Reference in New Issue
Block a user