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
8 changes: 4 additions & 4 deletions src/actions/sponsor-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ const normalizeEntity = (entity) => {

export const getBadgeScans =
(
sponsorId = null,
sponsor = null,
page = 1,
perPage = DEFAULT_PER_PAGE,
order = "attendee_last_name",
Expand All @@ -1296,8 +1296,8 @@ export const getBadgeScans =

dispatch(startLoading());

if (sponsorId) {
filter.push(`sponsor_id==${sponsorId}`);
if (sponsor) {
filter.push(`sponsor_id==${sponsor.id}`);
}

const params = {
Expand Down Expand Up @@ -1327,7 +1327,7 @@ export const getBadgeScans =
createAction(RECEIVE_BADGE_SCANS),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/badge-scans`,
authErrorHandler,
{ page, perPage, order, orderDir, sponsorId, summitTZ }
{ page, perPage, order, orderDir, sponsor, summitTZ }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down
19 changes: 9 additions & 10 deletions src/pages/sponsors/badge-scans-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Member from "../../models/member";
const BadgeScansListPage = ({
currentSummit,
history,
sponsorId,
sponsor,
allSponsors,
badgeScans,
order,
Expand All @@ -40,27 +40,26 @@ const BadgeScansListPage = ({
...props
}) => {
useEffect(() => {
if (sponsorId) {
props.getBadgeScans(sponsorId);
if (sponsor) {
props.getBadgeScans(sponsor);
}
}, []);

const handlePageChange = (page) => {
props.getBadgeScans(sponsorId, page, perPage, order, orderDir);
props.getBadgeScans(sponsor, page, perPage, order, orderDir);
};

const handleSort = (index, key, dir) => {
props.getBadgeScans(sponsorId, currentPage, perPage, key, dir);
props.getBadgeScans(sponsor, currentPage, perPage, key, dir);
};

const handleSponsorChange = (ev) => {
const { value } = ev.target;
props.getBadgeScans(value.id, currentPage, perPage, order, orderDir);
props.getBadgeScans(value, currentPage, perPage, order, orderDir);
};

const handleExport = (ev) => {
ev.preventDefault();
const sponsor = allSponsors.find((s) => s.id === sponsorId);
props.exportBadgeScans(sponsor, order, orderDir);
};

Expand Down Expand Up @@ -135,14 +134,14 @@ const BadgeScansListPage = ({
<button
className="btn btn-default right-space pull-right"
onClick={handleExport}
disabled={!sponsorId}
disabled={!sponsor}
>
{T.translate("general.export")}
</button>
<div className="col-md-6 pull-right">
<SponsorInput
id="sponsor"
value={sponsorId}
value={sponsor}
onChange={handleSponsorChange}
summitId={currentSummit?.id}
placeholder={T.translate(
Expand All @@ -155,7 +154,7 @@ const BadgeScansListPage = ({
</div>
</div>

{!sponsorId ? (
{!sponsor ? (
<div>{T.translate("badge_scan_list.select_sponsor")}</div>
) : (
<>
Expand Down
6 changes: 3 additions & 3 deletions src/reducers/sponsors/badge-scans-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { SET_CURRENT_SUMMIT } from "../../actions/summit-actions";

const DEFAULT_STATE = {
badgeScans: [],
sponsorId: null,
sponsor: null,
order: "attendee_last_name",
orderDir: 1,
currentPage: 1,
Expand All @@ -42,8 +42,8 @@ const badgeScansListReducer = (state = DEFAULT_STATE, action = {}) => {
return DEFAULT_STATE;
}
case REQUEST_BADGE_SCANS: {
const { order, orderDir, sponsorId, summitTZ } = payload;
return { ...state, order, orderDir, sponsorId, summitTZ };
const { order, orderDir, sponsor, summitTZ } = payload;
return { ...state, order, orderDir, sponsor, summitTZ };
}
case RECEIVE_BADGE_SCANS: {
const {
Expand Down