import {useCallback} from 'react' import {useHandleAction} from '../../internal/useHandleAction' import {useShopActions} from '../../internal/useShopActions' export interface UseCloseMiniReturns { /** * Closes the Mini viewer. */ closeMini: () => void } export const useCloseMini = (): UseCloseMiniReturns => { const {closeMini} = useShopActions() const handleClose = useHandleAction(closeMini) return { // Wrapper prevents React SyntheticEvent args from leaking through // when used directly as an event handler (e.g. onClick={closeMini}) closeMini: useCallback(() => handleClose(), [handleClose]), } } /** * Closes the Mini and returns the user to the Shop app. The Mini's WebView is destroyed and all state is lost. Use this for explicit exit flows (order completed, user cancellation) or when navigation should leave the Mini context entirely. Unlike `useShopNavigation`, which navigates to other Shop screens while keeping the Mini in the navigation stack, this removes the Mini from the stack. * @publicDocs */ export type UseCloseMiniGeneratedType = () => UseCloseMiniReturns