import { FullOrganizationInfoDTO , useOrganizationControllerSetSelfOwnershipFlag , } from '@energyweb/origin-backend-react-query-client' ; import { NotificationTypeEnum , showNotification , } from '@energyweb/origin-ui-core' ; import { useTranslation } from 'react-i18next' ; export const useChangeSelfOwnershipHandler = ( organizationId , setOwnership ) => { const { t } = useTranslation ( ) ; const { mutate , isLoading } = useOrganizationControllerSetSelfOwnershipFlag ( ) ; const changeHandler = ( selfOwnership ) => { mutate ( { id : organizationId , data : { selfOwnership } } , { onSuccess : ( ) => { showNotification ( t ( 'user.profile.notifications.selfOwnershipChangeSuccess' ) , NotificationTypeEnum . Success ) ; setOwnership ( selfOwnership ) ; } , onError : ( error ) => { showNotification ( `${ t ( 'user.profile.notifications.selfOwnershipChangeError' ) }:
        ${ error ?. response ?. data ?. message || '' }
        ` , NotificationTypeEnum . Error ) ; } , } ) ; } ; return { changeHandler , isMutating : isLoading } ; } ;