import { createAction, createAsyncThunk } from '@reduxjs/toolkit'; import { updateProfileApi, getStaffDetailsApi } from '@api'; import { UpdateProfilePayload, UpdateProfileResponse, UserData } from '@interfaces'; export const resetEditProfileState = createAction('editProfile/resetState'); export const updateProfile = createAsyncThunk( 'editProfile/updateProfile', async (payload, { rejectWithValue }) => { console.log('payload', payload) try { return await updateProfileApi(payload); } catch (error: any) { const serverMessage = error?.response?.data?.message || error.message || 'Failed to update profile'; return rejectWithValue(serverMessage); } }, ); export const getStaffDetails = createAsyncThunk( 'editProfile/getStaffDetails', async (id, { rejectWithValue }) => { try { return await getStaffDetailsApi(id); } catch (error: any) { return rejectWithValue(error.message || 'Failed to fetch staff details'); } }, );