1import api from '@/store/api';
2import i18n from '@/i18n';
3
4const KeyClearStore = {
5  namespaced: true,
6  actions: {
7    async clearEncryptionKeys(_, selectedKey) {
8      const selectedKeyForClearing = {
9        Attributes: { hb_key_clear_request: selectedKey },
10      };
11      return await api
12        .patch(
13          `${await this.dispatch('global/getSystemPath')}/Bios/Settings`,
14          selectedKeyForClearing,
15        )
16        .then(() =>
17          i18n.global.t('pageKeyClear.toast.selectedKeyClearedSuccess'),
18        )
19        .catch((error) => {
20          console.log('Key clear', error);
21          throw new Error(
22            i18n.global.t('pageKeyClear.toast.selectedKeyClearedError'),
23          );
24        });
25    },
26  },
27};
28
29export default KeyClearStore;
30