From c6c5cfc7714b197eb16cc69d6073f0a51fb3eb08 Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Mon, 6 May 2024 17:11:11 +0400 Subject: [PATCH 1/5] Edit Delete App --- .../components/AppsTable/app-actions.cell.tsx | 50 ++++++++++--------- .../components/AppsTable/cells.module.scss | 4 ++ .../Dialogs/UpdateAppDialog/index.tsx | 14 +++--- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/features/dashboard/components/AppsTable/app-actions.cell.tsx b/src/features/dashboard/components/AppsTable/app-actions.cell.tsx index cefe5a156..8b1371216 100644 --- a/src/features/dashboard/components/AppsTable/app-actions.cell.tsx +++ b/src/features/dashboard/components/AppsTable/app-actions.cell.tsx @@ -1,36 +1,40 @@ -import React from 'react'; +import React, { useState } from 'react'; +import styles from './cells.module.scss'; import { LabelPairedPenSmRegularIcon, LabelPairedTrashSmRegularIcon } from '@deriv/quill-icons'; +import DeleteAppDialog from '../Dialogs/DeleteAppDialog'; +import UpdateAppDialog from '../Dialogs/UpdateAppDialog'; import CustomTooltip from '@site/src/components/CustomTooltip'; -import clsx from 'clsx'; -import styles from './cells.module.scss'; -type TAppActionsCellProps = { - openDeleteDialog: () => void; - openEditDialog: () => void; - flex_end?: boolean; -}; +const AppActionsCell = () => { + const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false); + const [isUpdateDialogOpen, setUpdateDialogOpen] = useState(false); + + const handleDeleteClick = () => { + setDeleteDialogOpen(true); + }; + + const handleUpdateClick = () => { + setUpdateDialogOpen(true); + }; -const AppActionsCell = ({ - openDeleteDialog, - openEditDialog, - flex_end = false, -}: TAppActionsCellProps) => { return ( -
- +
+
- - - - +
+
+ - +
+ {isDeleteDialogOpen && ( + setDeleteDialogOpen(false)} appId={0} /> + )} + {isUpdateDialogOpen && ( + setUpdateDialogOpen(false)} app={undefined} /> + )}
); }; diff --git a/src/features/dashboard/components/AppsTable/cells.module.scss b/src/features/dashboard/components/AppsTable/cells.module.scss index 4e068e391..6a2468ebe 100644 --- a/src/features/dashboard/components/AppsTable/cells.module.scss +++ b/src/features/dashboard/components/AppsTable/cells.module.scss @@ -10,6 +10,10 @@ } } +.actionContainer { + margin-right: 10px; +} + .flex_end { justify-content: flex-end; } diff --git a/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx b/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx index 7f8e8297e..1a67eecfb 100644 --- a/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx +++ b/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx @@ -18,12 +18,14 @@ const UpdateAppDialog = ({ app, onClose }: IUpdateAppDialog) => { const { send: updateApp, data, error, clear } = useWS('app_update'); const { getApps } = useAppManager(); - const scopes = scopesArrayToObject(app.scopes); - const initialValues: Partial = { - ...app, - ...scopes, - app_markup_percentage: String(app.app_markup_percentage), - }; + const scopes = app ? scopesArrayToObject(app.scopes) : {}; + const initialValues: Partial = app + ? { + ...app, + ...scopes, + app_markup_percentage: String(app.app_markup_percentage), + } + : {}; const onOpenChange = useCallback( (open: boolean) => { From ab7c2e5459912ce3b9abc8b1450f59f2e347cb27 Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Tue, 7 May 2024 15:21:53 +0400 Subject: [PATCH 2/5] delete popup --- .../components/AppsTable/app-actions.cell.tsx | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/features/dashboard/components/AppsTable/app-actions.cell.tsx b/src/features/dashboard/components/AppsTable/app-actions.cell.tsx index 8b1371216..46738b3cd 100644 --- a/src/features/dashboard/components/AppsTable/app-actions.cell.tsx +++ b/src/features/dashboard/components/AppsTable/app-actions.cell.tsx @@ -1,29 +1,18 @@ import React, { useState } from 'react'; import styles from './cells.module.scss'; -import { LabelPairedPenSmRegularIcon, LabelPairedTrashSmRegularIcon } from '@deriv/quill-icons'; +import { LabelPairedTrashSmRegularIcon } from '@deriv/quill-icons'; import DeleteAppDialog from '../Dialogs/DeleteAppDialog'; -import UpdateAppDialog from '../Dialogs/UpdateAppDialog'; import CustomTooltip from '@site/src/components/CustomTooltip'; const AppActionsCell = () => { const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false); - const [isUpdateDialogOpen, setUpdateDialogOpen] = useState(false); const handleDeleteClick = () => { setDeleteDialogOpen(true); }; - const handleUpdateClick = () => { - setUpdateDialogOpen(true); - }; - return (
-
- - - -
@@ -32,9 +21,6 @@ const AppActionsCell = () => { {isDeleteDialogOpen && ( setDeleteDialogOpen(false)} appId={0} /> )} - {isUpdateDialogOpen && ( - setUpdateDialogOpen(false)} app={undefined} /> - )}
); }; From 887d616c43fe731df4424d76cad87d36f822168e Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Wed, 8 May 2024 11:47:39 +0400 Subject: [PATCH 3/5] fix delete functionality --- .../components/AppsTable/app-actions.cell.tsx | 44 ++++++++++++------- .../components/AppsTable/cells.module.scss | 4 -- .../dashboard/components/AppsTable/index.tsx | 2 +- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/features/dashboard/components/AppsTable/app-actions.cell.tsx b/src/features/dashboard/components/AppsTable/app-actions.cell.tsx index 46738b3cd..cefe5a156 100644 --- a/src/features/dashboard/components/AppsTable/app-actions.cell.tsx +++ b/src/features/dashboard/components/AppsTable/app-actions.cell.tsx @@ -1,26 +1,36 @@ -import React, { useState } from 'react'; -import styles from './cells.module.scss'; -import { LabelPairedTrashSmRegularIcon } from '@deriv/quill-icons'; -import DeleteAppDialog from '../Dialogs/DeleteAppDialog'; +import React from 'react'; +import { LabelPairedPenSmRegularIcon, LabelPairedTrashSmRegularIcon } from '@deriv/quill-icons'; import CustomTooltip from '@site/src/components/CustomTooltip'; +import clsx from 'clsx'; +import styles from './cells.module.scss'; -const AppActionsCell = () => { - const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false); - - const handleDeleteClick = () => { - setDeleteDialogOpen(true); - }; +type TAppActionsCellProps = { + openDeleteDialog: () => void; + openEditDialog: () => void; + flex_end?: boolean; +}; +const AppActionsCell = ({ + openDeleteDialog, + openEditDialog, + flex_end = false, +}: TAppActionsCellProps) => { return ( -
-
- +
+ + + + + + + + -
- {isDeleteDialogOpen && ( - setDeleteDialogOpen(false)} appId={0} /> - )} +
); }; diff --git a/src/features/dashboard/components/AppsTable/cells.module.scss b/src/features/dashboard/components/AppsTable/cells.module.scss index 6a2468ebe..4e068e391 100644 --- a/src/features/dashboard/components/AppsTable/cells.module.scss +++ b/src/features/dashboard/components/AppsTable/cells.module.scss @@ -10,10 +10,6 @@ } } -.actionContainer { - margin-right: 10px; -} - .flex_end { justify-content: flex-end; } diff --git a/src/features/dashboard/components/AppsTable/index.tsx b/src/features/dashboard/components/AppsTable/index.tsx index 8ba091907..d137c5d40 100644 --- a/src/features/dashboard/components/AppsTable/index.tsx +++ b/src/features/dashboard/components/AppsTable/index.tsx @@ -101,7 +101,7 @@ const AppsTable = ({ apps }: AppsTableProps) => { return { openDeleteDialog: () => { setActionRow(item); - // setIsDeleteOpen(true); + setIsDeleteOpen(true); }, openEditDialog: () => { From ea46619a3736bf9c4d5d22ba2d4962d1085a711e Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Wed, 8 May 2024 11:49:35 +0400 Subject: [PATCH 4/5] fix delete functionality --- .../components/Dialogs/UpdateAppDialog/index.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx b/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx index 1a67eecfb..7f8e8297e 100644 --- a/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx +++ b/src/features/dashboard/components/Dialogs/UpdateAppDialog/index.tsx @@ -18,14 +18,12 @@ const UpdateAppDialog = ({ app, onClose }: IUpdateAppDialog) => { const { send: updateApp, data, error, clear } = useWS('app_update'); const { getApps } = useAppManager(); - const scopes = app ? scopesArrayToObject(app.scopes) : {}; - const initialValues: Partial = app - ? { - ...app, - ...scopes, - app_markup_percentage: String(app.app_markup_percentage), - } - : {}; + const scopes = scopesArrayToObject(app.scopes); + const initialValues: Partial = { + ...app, + ...scopes, + app_markup_percentage: String(app.app_markup_percentage), + }; const onOpenChange = useCallback( (open: boolean) => { From d13f31ef87a1cb0d49341725809912a4e5081e75 Mon Sep 17 00:00:00 2001 From: Agrim Jain Date: Tue, 14 May 2024 10:00:28 +0400 Subject: [PATCH 5/5] empty commit