mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Upgrades biome to 1.6.1, and updates husky pre-commit hook. Most changes here are making type imports explicit.
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import {
 | 
						|
    type IFeedbackCategory,
 | 
						|
    useUserSubmittedFeedback,
 | 
						|
} from 'hooks/useSubmittedFeedback';
 | 
						|
import {
 | 
						|
    FeedbackContext,
 | 
						|
    type FeedbackMode,
 | 
						|
    type IFeedbackContext,
 | 
						|
} from './FeedbackContext';
 | 
						|
import { useContext } from 'react';
 | 
						|
 | 
						|
type OpenFeedbackParams = {
 | 
						|
    title: string;
 | 
						|
    positiveLabel: string;
 | 
						|
    areasForImprovementsLabel: string;
 | 
						|
};
 | 
						|
 | 
						|
export const useFeedbackContext = (): IFeedbackContext => {
 | 
						|
    const context = useContext(FeedbackContext);
 | 
						|
 | 
						|
    if (!context) {
 | 
						|
        throw new Error(
 | 
						|
            'useFeedbackContext must be used within a FeedbackProvider',
 | 
						|
        );
 | 
						|
    }
 | 
						|
 | 
						|
    return context;
 | 
						|
};
 | 
						|
 | 
						|
export const useFeedback = (
 | 
						|
    feedbackCategory: IFeedbackCategory,
 | 
						|
    mode: FeedbackMode,
 | 
						|
    variant: string = '',
 | 
						|
) => {
 | 
						|
    const context = useFeedbackContext();
 | 
						|
    const { hasSubmittedFeedback } = useUserSubmittedFeedback(feedbackCategory);
 | 
						|
 | 
						|
    return {
 | 
						|
        ...context,
 | 
						|
        hasSubmittedFeedback,
 | 
						|
        openFeedback: (parameters: OpenFeedbackParams) => {
 | 
						|
            context.openFeedback(
 | 
						|
                {
 | 
						|
                    ...parameters,
 | 
						|
                    category: feedbackCategory,
 | 
						|
                },
 | 
						|
                mode,
 | 
						|
                variant,
 | 
						|
            );
 | 
						|
        },
 | 
						|
    };
 | 
						|
};
 |