mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-24 05:39:45 +08:00
* [APP-934] add submit logic * [APP-934] add submit logic * [APP-934] add submit logic * [APP-934] add submit logic * Added replace remediation action * Add submit logic * Add submit alt text logic, generate AI alt text * Add AI generate request, add convert from SVG to png base64, added manual fix block * Add AI generate request, add convert from SVG to png base64, added manual fix block * Add texts, add remediation submit, fix logic to store remediation * Add texts, add remediation submit, fix logic to store remediation * Add texts, add remediation submit, fix logic to store remediation * Add texts, add remediation submit, fix logic to store remediation * Add texts, add remediation submit, fix logic to store remediation * Add texts, add remediation submit, fix logic to store remediation --------- Co-authored-by: Raz Ohad <admin@bainternet.info>
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import { useState, createContext, useContext } from '@wordpress/element';
|
|
|
|
const NotificationsContext = createContext(undefined);
|
|
|
|
export function useNotificationSettings() {
|
|
return useContext(NotificationsContext);
|
|
}
|
|
|
|
export const NotificationsProvider = ({ children }) => {
|
|
const [showNotification, setShowNotification] = useState(false);
|
|
const [notificationMessage, setNotificationMessage] = useState('');
|
|
const [notificationType, setNotificationType] = useState('');
|
|
|
|
return (
|
|
<NotificationsContext.Provider
|
|
value={{
|
|
showNotification,
|
|
setShowNotification,
|
|
notificationMessage,
|
|
setNotificationMessage,
|
|
notificationType,
|
|
setNotificationType,
|
|
}}
|
|
>
|
|
{children}
|
|
</NotificationsContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useToastNotification = () => {
|
|
const { setNotificationMessage, setNotificationType, setShowNotification } =
|
|
useContext(NotificationsContext);
|
|
|
|
const error = (message) => {
|
|
setNotificationMessage(message);
|
|
setNotificationType('error');
|
|
setShowNotification(true);
|
|
};
|
|
|
|
const success = (message) => {
|
|
setNotificationMessage(message);
|
|
setNotificationType('success');
|
|
setShowNotification(true);
|
|
};
|
|
|
|
return {
|
|
success,
|
|
error,
|
|
};
|
|
};
|