@@ -3,8 +3,6 @@ import { HomeResTypeEnum } from "../../types/homeRes";
33import { exportApplicationAsJSONFile } from "./components/AppImport" ;
44import { CustomModal , EditPopover , EditPopoverItemType , PointIcon } from "lowcoder-design" ;
55import { HomeResInfo } from "../../util/homeResUtils" ;
6- import { recycleApplication } from "../../redux/reduxActions/applicationActions" ;
7- import { deleteFolder } from "../../redux/reduxActions/folderActions" ;
86import { useDispatch } from "react-redux" ;
97import React , { useState } from "react" ;
108import styled from "styled-components" ;
@@ -13,6 +11,9 @@ import { useParams } from "react-router-dom";
1311import { AppTypeEnum } from "constants/applicationConstants" ;
1412import { CopyModal } from "pages/common/copyModal" ;
1513import { messageInstance } from "lowcoder-design/src/components/GlobalInstances" ;
14+ import ApplicationApi from "../../api/applicationApi" ;
15+ import { FolderApi } from "../../api/folderApi" ;
16+ import { ReduxActionTypes } from "constants/reduxActionConstants" ;
1617
1718const PopoverIcon = styled ( PointIcon ) `
1819 cursor: pointer;
@@ -80,23 +81,20 @@ export const HomeResOptions = (props: {
8081 type : HomeResInfo [ res . type ] . name ,
8182 name : < b > { res . name } </ b > ,
8283 } ) ,
83- onConfirm : ( ) => {
84- new Promise ( ( resolve , reject ) => {
85- dispatch (
86- recycleApplication (
87- { applicationId : res . id , folderId : folderId } ,
88- ( ) => {
89- messageInstance . success ( trans ( "success" ) ) ;
90- resolve ( true ) ;
91- } ,
92- ( ) => reject ( )
93- )
94- ) ;
84+ onConfirm : async ( ) => {
85+ try {
86+ await ApplicationApi . recycleApplication ( {
87+ applicationId : res . id ,
88+ folderId : folderId || ""
89+ } ) ;
90+ messageInstance . success ( trans ( "success" ) ) ;
9591 setTimeout ( ( ) => {
9692 setModify ( ! modify ) ;
9793 } , 200 ) ;
98- } )
99-
94+ } catch ( error ) {
95+ console . error ( "Failed to recycle application:" , error ) ;
96+ messageInstance . error ( "Failed to delete application" ) ;
97+ }
10098 } ,
10199 confirmBtnType : "delete" ,
102100 okText : trans ( "home.moveToTrash" ) ,
@@ -122,22 +120,27 @@ export const HomeResOptions = (props: {
122120 type : HomeResInfo [ res . type ] . name . toLowerCase ( ) ,
123121 name : < b > { res . name } </ b > ,
124122 } ) ,
125- onConfirm : ( ) => {
126- new Promise ( ( resolve , reject ) => {
127- dispatch (
128- deleteFolder (
129- { folderId : res . id , parentFolderId : folderId } ,
130- ( ) => {
131- messageInstance . success ( trans ( "home.deleteSuccessMsg" ) ) ;
132- resolve ( true ) ;
133- } ,
134- ( ) => reject ( )
135- )
136- ) ;
137- } )
138- setTimeout ( ( ) => {
139- setModify ( ! modify ) ;
140- } , 200 ) ;
123+ onConfirm : async ( ) => {
124+ try {
125+ await FolderApi . deleteFolder ( {
126+ folderId : res . id ,
127+ parentFolderId : folderId || ""
128+ } ) ;
129+
130+ // Update Redux state to remove deleted folder from dropdown
131+ dispatch ( {
132+ type : ReduxActionTypes . DELETE_FOLDER_SUCCESS ,
133+ payload : { folderId : res . id , parentFolderId : folderId || "" }
134+ } ) ;
135+
136+ messageInstance . success ( trans ( "home.deleteSuccessMsg" ) ) ;
137+ setTimeout ( ( ) => {
138+ setModify ( ! modify ) ;
139+ } , 200 ) ;
140+ } catch ( error ) {
141+ console . error ( "Failed to delete folder:" , error ) ;
142+ messageInstance . error ( "Failed to delete folder" ) ;
143+ }
141144 } ,
142145 confirmBtnType : "delete" ,
143146 okText : trans ( "delete" ) ,
0 commit comments