| Server IP : 85.214.239.14  /  Your IP : 216.73.216.181 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/wordpress/wp-content/plugins/really-simple-ssl/settings/src/LetsEncrypt/ | 
| Upload File : | 
import {create} from 'zustand';
import produce from 'immer';
import * as rsssl_api from "../utils/api";
import {__} from "@wordpress/i18n";
import sleeper from "../utils/sleeper";
import {dispatch} from '@wordpress/data';
const useLetsEncryptData = create(( set, get ) => ({
    actionIndex:-1,
    progress:0,
    attemptCount:0,
    refreshTests:false,
    actionsList:[],
    updateVerificationType: async (verificationType) => {
        await rsssl_api.runLetsEncryptTest('update_verification_type', verificationType).then((response) => {
            let msg = verificationType==='dir' ? __('Switched to Directory', 'really-simple-ssl') : __('Switched to DNS', 'really-simple-ssl');
            const notice = dispatch('core/notices').createNotice(
                'success',
                msg,
                {
                    __unstableHTML: true,
                    id: 'rsssl_switched_to_dns',
                    type: 'snackbar',
                    isDismissible: true,
                }
            ).then(sleeper(3000)).then((response) => {
                dispatch('core/notices').removeNotice('rsssl_switched_to_dns');
            });
        });
    },
    setAttemptCount: (attemptCount) => {set(state => ({ attemptCount }))},
    setProgress: (progress) => {set(state => ({ progress }))},
    setActionsList: (actionsList) => {set(state => ({ actionsList }))},
    setActionsListItem: (index, action) => {
        set(
            produce((state) => {
                state.actionsList[index] = action;
            })
        )
    },
    setActionsListProperty: (index, property, value) => {
        set(
            produce((state) => {
                //first, check if the actionsList has index and property
                if (typeof state.actionsList[index] === 'undefined' || typeof state.actionsList[index][property]) {
                    return;
                }
                state.actionsList[index][property] = value;
            })
        )
    },
    setRefreshTests: (refreshTests) => {set(state => ({ refreshTests }))},
    setActionIndex: (actionIndex) => {set(state => ({ actionIndex }))},
    switchButtonDisabled:false,
    setSwitchButtonDisabled: (switchButtonDisabled) => {set(state => ({ switchButtonDisabled }))},
}));
export default useLetsEncryptData;