2026-07-16 18:26:01 +05:30

15 lines
429 B
TypeScript

import { createAsyncThunk } from '@reduxjs/toolkit';
import { LoginRequest, LoginResponse } from '@interfaces';
import { loginApi } from '@api';
export const login = createAsyncThunk<LoginResponse, LoginRequest>(
'auth/login',
async (payload, { rejectWithValue }) => {
try {
return await loginApi(payload);
} catch (error: any) {
return rejectWithValue(error.message || 'Failed to login');
}
},
);