15 lines
429 B
TypeScript
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');
|
|
}
|
|
},
|
|
);
|