1 import { createAsyncThunk } from '@reduxjs/toolkit';
2 import { c } from 'ttag';
4 import { cancelImport, getImportsList } from '@proton/activation/src/api';
5 import type { ApiImportListResponse } from '@proton/activation/src/api/api.interface';
7 import type { EasySwitchThunkExtra } from '../store';
8 import type { ActiveImportID } from './importers.interface';
10 export const loadImporters = createAsyncThunk<ApiImportListResponse, undefined, EasySwitchThunkExtra>(
12 async (_, thunkApi) => {
13 const importers = await thunkApi.extra.api<ApiImportListResponse>(getImportsList());
18 export const cancelImporter = createAsyncThunk<void, { activeImporterID: ActiveImportID }, EasySwitchThunkExtra>(
20 async ({ activeImporterID }, thunkApi) => {
21 const state = thunkApi.getState();
22 const activeImporter = state.importers.activeImporters[activeImporterID];
24 await thunkApi.extra.api(
26 ImporterID: activeImporter.importerID,
27 Products: [activeImporter.product],
30 await thunkApi.extra.eventManager.call();
32 thunkApi.extra.notificationManager.createNotification({ text: c('Success').t`Canceling import` });