@@ -3,8 +3,6 @@ import { HomeResTypeEnum } from "../../types/homeRes";
3
3
import { exportApplicationAsJSONFile } from "./components/AppImport" ;
4
4
import { CustomModal , EditPopover , EditPopoverItemType , PointIcon } from "lowcoder-design" ;
5
5
import { HomeResInfo } from "../../util/homeResUtils" ;
6
- import { recycleApplication } from "../../redux/reduxActions/applicationActions" ;
7
- import { deleteFolder } from "../../redux/reduxActions/folderActions" ;
8
6
import { useDispatch } from "react-redux" ;
9
7
import React , { useState } from "react" ;
10
8
import styled from "styled-components" ;
@@ -13,6 +11,9 @@ import { useParams } from "react-router-dom";
13
11
import { AppTypeEnum } from "constants/applicationConstants" ;
14
12
import { CopyModal } from "pages/common/copyModal" ;
15
13
import { 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" ;
16
17
17
18
const PopoverIcon = styled ( PointIcon ) `
18
19
cursor: pointer;
@@ -80,23 +81,20 @@ export const HomeResOptions = (props: {
80
81
type : HomeResInfo [ res . type ] . name ,
81
82
name : < b > { res . name } </ b > ,
82
83
} ) ,
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" ) ) ;
95
91
setTimeout ( ( ) => {
96
92
setModify ( ! modify ) ;
97
93
} , 200 ) ;
98
- } )
99
-
94
+ } catch ( error ) {
95
+ console . error ( "Failed to recycle application:" , error ) ;
96
+ messageInstance . error ( "Failed to delete application" ) ;
97
+ }
100
98
} ,
101
99
confirmBtnType : "delete" ,
102
100
okText : trans ( "home.moveToTrash" ) ,
@@ -122,22 +120,27 @@ export const HomeResOptions = (props: {
122
120
type : HomeResInfo [ res . type ] . name . toLowerCase ( ) ,
123
121
name : < b > { res . name } </ b > ,
124
122
} ) ,
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
+ }
141
144
} ,
142
145
confirmBtnType : "delete" ,
143
146
okText : trans ( "delete" ) ,
0 commit comments