11'use client'
22
3- import { useState } from 'react'
4- import { Chip , ChipConfirmModal , ChipLink , ChipModalError , ChipTag } from '@sim/emcn'
3+ import { useEffect , useRef , useState } from 'react'
4+ import { Chip , ChipConfirmModal , ChipLink , ChipModalError , ChipTag , useToast } from '@sim/emcn'
55import { useQueryState } from 'nuqs'
66import { SlackIcon } from '@/components/icons'
77import { SlackSearchSetupWizard } from '@/components/integrations/slack-search-setup-wizard'
@@ -26,6 +26,8 @@ import {
2626
2727/** Organization-owned Search bots are installed through the dedicated OAuth wizard. */
2828export function OrganizationSearchSlack ( ) {
29+ const setupToastShown = useRef ( false )
30+ const { toast } = useToast ( )
2931 const { organization, viewer } = useOrganizationContext ( )
3032 const installations = useSlackSearchInstallations ( viewer . isAdmin ? organization . id : undefined )
3133 const configure = useConfigureSlackSearch ( )
@@ -41,6 +43,14 @@ export function OrganizationSearchSlack() {
4143 initialName ?: string
4244 } | null > ( null )
4345 const [ removeTarget , setRemoveTarget ] = useState < { id : string ; name : string } | null > ( null )
46+
47+ useEffect ( ( ) => {
48+ if ( ! viewer . isAdmin || setupResult !== 'complete' || setupToastShown . current ) return
49+ setupToastShown . current = true
50+ toast . success ( 'Slack connected' )
51+ void setSetupResult ( null )
52+ } , [ viewer . isAdmin , setupResult , setSetupResult , toast ] )
53+
4454 if ( ! viewer . isAdmin ) return null
4555 const busy = configure . isPending || remove . isPending
4656 const bots = installations . data ?. bots ?? [ ]
@@ -54,12 +64,6 @@ export function OrganizationSearchSlack() {
5464 return (
5565 < SettingsPanel >
5666 < div className = 'flex max-w-xl flex-col gap-4' >
57- { setupResult === 'complete' && (
58- < div role = 'status' className = 'flex items-center justify-between gap-2' >
59- < p className = 'text-[var(--text-body)] text-sm' > Slack is connected and ready to use.</ p >
60- < Chip onClick = { ( ) => void setSetupResult ( null ) } > Dismiss</ Chip >
61- </ div >
62- ) }
6367 < SettingsSection label = 'Connection' >
6468 { installations . error ? (
6569 < SettingsQueryErrorState
0 commit comments