Skip to content

Commit

Permalink
prettier lint
Browse files Browse the repository at this point in the history
  • Loading branch information
engelhartrueben committed Oct 1, 2024
1 parent 57ed8ea commit 4bc59a3
Showing 1 changed file with 28 additions and 46 deletions.
74 changes: 28 additions & 46 deletions src/containers/AdminCampaignList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import LoadingIndicator from "../components/LoadingIndicator";
import { dataTest } from "../lib/attributes";
import loadData from "./hoc/load-data";
import theme from "../styles/theme";
import SortBy, {
ID_DESC_SORT
} from "../components/AdminCampaignList/SortBy";
import SortBy, { ID_DESC_SORT } from "../components/AdminCampaignList/SortBy";
import Search from "../components/Search";
import CampaignTable from "../components/AdminCampaignList/CampaignTable";

Expand All @@ -36,13 +34,7 @@ const styles = StyleSheet.create({
const INITIAL_SORT_BY = ID_DESC_SORT.value;

// Exported for testing
export const AdminCampaignList = ({
params,
mutations,
router,
data
}) => {

export const AdminCampaignList = ({ params, mutations, router, data }) => {
const [state, setState] = useState({
pageSize: 50,
page: 0,
Expand All @@ -60,9 +52,9 @@ export const AdminCampaignList = ({

const handleClickNewButton = async () => {
const { organizationId } = params;
setState({
setState({
...state,
isLoading: true
isLoading: true
});
const newCampaign = await mutations.createCampaign({
title: "New Campaign",
Expand All @@ -87,9 +79,9 @@ export const AdminCampaignList = ({

const handleClickArchiveMultipleButton = async keys => {
if (keys.length) {
setState({
setState({
...state,
isLoading: true
isLoading: true
});
await mutations.archiveCampaigns(keys);
await data.refetch();
Expand Down Expand Up @@ -173,16 +165,16 @@ export const AdminCampaignList = ({

const handleMenuClick = event => {
console.log("event.target", event.target);
setState({
setState({
...state,
menuAnchorEl: event.target
menuAnchorEl: event.target
});
};

const handleMenuClose = () => {
setState({
setState({
...state,
menuAnchorEl: null
menuAnchorEl: null
});
};

Expand All @@ -208,10 +200,7 @@ export const AdminCampaignList = ({
return (
<React.Fragment>
{iconButton}
<Menu
open={state.archiveMultipleMenu}
anchorEl={state.menuAnchorEl}
>
<Menu open={state.archiveMultipleMenu} anchorEl={state.menuAnchorEl}>
{state.archiveMultiple ? (
<MenuItem
onClick={() => {
Expand Down Expand Up @@ -240,14 +229,10 @@ export const AdminCampaignList = ({
</Menu>
</React.Fragment>
);
}
};

const changePage = (pageDelta, pageSize) => {
const {
limit,
offset,
total
} = data.organization.campaigns.pageInfo;
const { limit, offset, total } = data.organization.campaigns.pageInfo;
const currentPage = Math.floor(offset / limit);
const pageSizeAdjustedCurrentPage = Math.floor(
(currentPage * limit) / pageSize
Expand Down Expand Up @@ -279,10 +264,10 @@ export const AdminCampaignList = ({
await data.refetch({
campaignsFilter: newFilter
});
setState({
setState({
...state,
campaignsFilter: newFilter,
isLoading: false
isLoading: false
});
};

Expand All @@ -295,7 +280,7 @@ export const AdminCampaignList = ({
await data.refetch({
sortBy: newSort
});
setState({
setState({
...state,
isLoading: false,
sortBy: newSort
Expand All @@ -322,9 +307,9 @@ export const AdminCampaignList = ({
const changeCampaignStatus = async (campaignId, changeFn) => {
setState({
...state,
campaignsWithChangingStatus: state.campaignsWithChangingStatus.concat(
[campaignId]
)
campaignsWithChangingStatus: state.campaignsWithChangingStatus.concat([
campaignId
])
});
await changeFn(campaignId);
await data.refetch();
Expand All @@ -343,10 +328,7 @@ export const AdminCampaignList = ({
};

const handleUnarchiveCampaign = async campaignId => {
await changeCampaignStatus(
campaignId,
mutations.unarchiveCampaign
);
await changeCampaignStatus(campaignId, mutations.unarchiveCampaign);
};

const renderActionButton = () => {
Expand Down Expand Up @@ -374,7 +356,7 @@ export const AdminCampaignList = ({
<AddIcon />
</Fab>
);
}
};
// don't think this is right
return (
<div>
Expand Down Expand Up @@ -402,7 +384,7 @@ export const AdminCampaignList = ({
{params.adminPerms && renderActionButton()}
</div>
);
}
};

const campaignInfoFragment = `
id
Expand Down Expand Up @@ -543,13 +525,13 @@ const mutations = {

AdminCampaignList.propTypes = {
params: PropTypes.object,
mutations: PropTypes.exact({
createCampaign: PropTypes.func,
archiveCampaigns: PropTypes.func,
unarchiveCampaign: PropTypes.func
}),
mutations: PropTypes.exact({
createCampaign: PropTypes.func,
archiveCampaigns: PropTypes.func,
unarchiveCampaign: PropTypes.func
}),
data: PropTypes.object,
router: PropTypes.object
}
};

export default loadData({ queries, mutations })(withRouter(AdminCampaignList));

0 comments on commit 4bc59a3

Please sign in to comment.