-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1624]: refactor existing components in preparation for notificat…
…ions (#1697)
- Loading branch information
1 parent
0c39a29
commit a816fda
Showing
10 changed files
with
139 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,39 @@ | ||
'use client'; | ||
import { useEffect } from 'react'; | ||
import { useConfig } from '@/hooks'; | ||
import { ROUTES, CONFIG } from '@/utils'; | ||
import { useRouter } from 'next/navigation'; | ||
import { addNotification, store } from '@/store'; | ||
import { useConfig, useNotify } from '@/hooks'; | ||
import { Loader } from '@keyval-dev/design-system'; | ||
|
||
export default function App() { | ||
const router = useRouter(); | ||
const notify = useNotify(); | ||
const { data, error } = useConfig(); | ||
|
||
useEffect(() => { | ||
data && renderCurrentPage(); | ||
}, [data, error]); | ||
|
||
useEffect(() => { | ||
if (!error) return; | ||
store.dispatch( | ||
addNotification({ | ||
id: '1', | ||
if (error) { | ||
notify({ | ||
message: 'An error occurred', | ||
title: 'Error', | ||
type: 'error', | ||
target: 'notification', | ||
crdType: 'notification', | ||
}) | ||
); | ||
router.push(ROUTES.OVERVIEW); | ||
}, [error]); | ||
}); | ||
|
||
function renderCurrentPage() { | ||
const { installation } = data; | ||
router.push(ROUTES.OVERVIEW); | ||
} else if (data) { | ||
const { installation } = data; | ||
|
||
switch (installation) { | ||
case CONFIG.NEW: | ||
case CONFIG.APPS_SELECTED: | ||
router.push(ROUTES.CHOOSE_SOURCES); | ||
break; | ||
case CONFIG.FINISHED: | ||
router.push(ROUTES.OVERVIEW); | ||
switch (installation) { | ||
case CONFIG.NEW: | ||
case CONFIG.APPS_SELECTED: | ||
router.push(ROUTES.CHOOSE_SOURCES); | ||
break; | ||
case CONFIG.FINISHED: | ||
router.push(ROUTES.OVERVIEW); | ||
} | ||
} | ||
} | ||
}, [data, error]); | ||
|
||
return <Loader />; | ||
} |
15 changes: 3 additions & 12 deletions
15
...n/destinations/add-destination/connect-destination-modal-body/connection-notification.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.