Skip to content

Commit 38e6d3f

Browse files
committed
refactor based on comments, remove unused vars
1 parent b541a9e commit 38e6d3f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/frontend/src/components/AppConnectionRow/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useToast } from '@opengovsg/design-system-react'
1515
import { DateTime } from 'luxon'
1616

1717
import ConnectionContextMenu from '@/components/AppConnectionContextMenu'
18-
import MenuAlertDialog, { AlertDialogType } from '@/components/MenuAlertDialog'
18+
import MenuAlertDialog from '@/components/MenuAlertDialog'
1919
import { DELETE_CONNECTION } from '@/graphql/mutations/delete-connection'
2020
import { TEST_CONNECTION } from '@/graphql/queries/test-connection'
2121
import useFormatMessage from '@/hooks/useFormatMessage'
@@ -35,7 +35,6 @@ const countTranslation = (value: React.ReactNode) => (
3535

3636
function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
3737
const toast = useToast()
38-
const [dialogType, setDialogType] = useState<AlertDialogType>('delete') // delete by default
3938
const [verificationVisible, setVerificationVisible] = useState(false)
4039
const [isVerified, setIsVerified] = useState(false)
4140
const [testConnection, { called: testCalled, loading: testLoading }] =
@@ -99,7 +98,6 @@ function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
9998
action: { [key: string]: string },
10099
) => {
101100
if (action.type === 'delete') {
102-
setDialogType('delete')
103101
onDialogOpen()
104102
} else if (action.type === 'test') {
105103
setVerificationVisible(true)
@@ -215,7 +213,7 @@ function AppConnectionRow(props: AppConnectionRowProps): React.ReactElement {
215213
cancelRef={cancelRef}
216214
onDialogClose={onDialogClose}
217215
dialogHeader="Connection"
218-
dialogType={dialogType}
216+
dialogType="delete"
219217
onClick={onConnectionDelete}
220218
isLoading={isDeletingConnection}
221219
/>

packages/frontend/src/components/MenuAlertDialog/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import {
99
import { Button } from '@opengovsg/design-system-react'
1010

1111
export type AlertDialogType = 'delete' | 'duplicate'
12-
export type AlertHeaderType = 'App' | 'Connection' | 'Pipe' | 'Tile'
12+
export type AlertHeaderType = 'Connection' | 'Pipe' | 'Tile'
1313

1414
interface MenuAlertDialogProps {
1515
isDialogOpen: boolean
1616
cancelRef: React.RefObject<HTMLButtonElement>
1717
onDialogClose: () => void
1818
dialogType: AlertDialogType
19-
dialogHeader: string
19+
dialogHeader: AlertHeaderType
2020
onClick: () => void
2121
isLoading: boolean
2222
}
@@ -28,7 +28,7 @@ interface AlertDialogContent {
2828
}
2929

3030
function getAlertDialogContent(
31-
dialogHeader: string,
31+
dialogHeader: AlertHeaderType,
3232
dialogType: AlertDialogType,
3333
): AlertDialogContent {
3434
switch (dialogType) {
@@ -40,8 +40,8 @@ function getAlertDialogContent(
4040
}
4141
case 'duplicate':
4242
return {
43-
header: `Duplicate ${dialogHeader}`,
44-
body: `You'll need to replace the data in every step and test each step in your duplicated ${dialogHeader?.toLowerCase()} before publishing it.`,
43+
header: 'Duplicate Pipe',
44+
body: `You'll need to replace the data in every step and test each step in your duplicated pipe before publishing it.`,
4545
buttonText: 'Duplicate',
4646
}
4747
}

0 commit comments

Comments
 (0)