import { createAsyncThunk } from '@reduxjs/toolkit';
import axios from 'axios';
import { Token, LoginParams } from './types';
import pickBy from 'lodash/pickBy';
import identity from 'lodash/identity';

export const fetchPizzas = createAsyncThunk<Token[], LoginParams>(
  'token/fetchTokenStatus',
  async (params) => {
    const { login, password } = params;
    console.log(params, 4444);
    const { data } = await axios.post<Token[]>(`https://626d16545267c14d5677d9c2.mockapi.io/items`, {
      params: pickBy(
        {
          login: currentPage,
          password: 4,
        },
        identity,
      ),
    });

    return data;
  },
);
