Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/actions/lbdashboard/bidOverviewActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import axios from 'axios';
import { ENDPOINTS } from '~/utils/URL';
import {
FETCH_UNIT_DETAILS_REQUEST,
FETCH_UNIT_DETAILS_SUCCESS,
FETCH_UNIT_DETAILS_FAILURE,
SUBMIT_BID_REQUEST,
SUBMIT_BID_SUCCESS,
SUBMIT_BID_FAILURE,
NOTIFICATION_SUCCESS,
NOTIFICATION_FAILURE,
} from '../../constants/lbdashboard/bidOverviewConstants';

export const fetchUnitDetails = listingId => async (dispatch) => {
try {
dispatch({ type: FETCH_UNIT_DETAILS_REQUEST });
const url = ENDPOINTS.LB_BID_OVERVIEW(listingId);
const { data } = await axios.get(url);
dispatch({
type: FETCH_UNIT_DETAILS_SUCCESS,
payload: data.listingDetail,
});
return data;
} catch (error) {
dispatch({
type: FETCH_UNIT_DETAILS_FAILURE,
payload: error.response?.data?.message || error.message,
});
return null;
}
};

export const submitBid = (listingId, bidData) => async (dispatch) => {
try {
dispatch({ type: SUBMIT_BID_REQUEST });
const url = ENDPOINTS.LB_SUBMIT_BID(listingId);
console.log('Submitting bid to:', url);

Check warning on line 37 in src/actions/lbdashboard/bidOverviewActions.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
console.log('Request body:', bidData);

Check warning on line 38 in src/actions/lbdashboard/bidOverviewActions.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
const { data } = await axios.post(url, bidData);
dispatch({
type: SUBMIT_BID_SUCCESS,
payload: data.bid,
});
if(data.notifications) {
dispatch({
type: NOTIFICATION_SUCCESS,
payload: data.notifications,
});
console.log('Notifications:', data.notifications);

Check warning on line 49 in src/actions/lbdashboard/bidOverviewActions.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
}
return data;
} catch (error) {
dispatch({
type: SUBMIT_BID_FAILURE,
payload: error.response?.data?.message || error.message,
});
dispatch({
type: NOTIFICATION_FAILURE,
payload: error.response?.data?.message || error.message,
});
}
};
Loading
Loading