Skip to content

fix: campaign slice setup (#85)#96

Merged
ayshadogo merged 2 commits into
Dfunder:mainfrom
dzekojohn4:fix/issue-85-campaign-slice-setup
Jun 24, 2026
Merged

fix: campaign slice setup (#85)#96
ayshadogo merged 2 commits into
Dfunder:mainfrom
dzekojohn4:fix/issue-85-campaign-slice-setup

Conversation

@dzekojohn4

Copy link
Copy Markdown
Contributor

Summary

Implements the Redux slice for campaign management as specified in issue #85. Reshapes state to { campaigns, currentCampaign, draftCampaign, formStep, isLoading, error }, renames required actions (updateDraft, clearDraft, setFormStep), adds the six required thunks (createCampaign, updateCampaign, deleteCampaign, submitCampaign, fetchMyCampaigns, fetchCampaignById) with full pending/fulfilled/rejected handling, and wires the submit thunk into the Create Campaign wizard.

Changes

  • src/features/campaigns/campaignsSlice.js — spec state shape, sync actions, extraReducers for all six thunks; formStep is 1-indexed (initial 1, max CAMPAIGN_STEPS.length); currentCampaign is promoted on create/update/fetchById success
  • src/features/campaigns/campaignsThunks.js — API-backed thunks with inlined try/catch + toast + rejectWithValue matching the authThunks.js style; submitCampaign accepts either an id or a full draft
  • src/features/campaigns/campaignsSelectors.js — reads new state shape; adds selectCurrentCampaign
  • src/pages/campaigns/CreateCampaignPage.jsx — 1-indexed formStep math (STEP_META[formStep - 1], Step N indicator matches the index); Submit button dispatches submitCampaign(draft); Discard-draft button surfaces whenever the form is dirty
  • src/components/campaigns/steps/{BasicInfoStep,MediaStep,FundingStep,DetailsStep}.jsxupdateDraftCampaignupdateDraft
  • src/components/common/GlobalLoadingWrapper.jsx (+ .test.jsx) — state.campaigns.loadingisLoading
  • src/components/dashboard/RecentCampaigns.jsx — fixed a pre-existing duplicate import { parse error
  • src/features/campaigns/campaignsSlice.test.js (new) — comprehensive sync + dispatched-thunk tests via real configureStore

Testing

  • npm test → 48/48 vitest tests passing across 11 files
  • npm run lint → passes (only an unrelated, pre-existing React-Compiler warning in BasicInfoStep.jsx remains)

Closes #85

Reshapes campaignsSlice state to { campaigns, currentCampaign, draftCampaign, formStep, isLoading, error } per the issue spec. Renames actions to updateDraft and clearDraft and adds the six required thunks (createCampaign, updateCampaign, deleteCampaign, submitCampaign, fetchMyCampaigns, fetchCampaignById) with pending/fulfilled/rejected handling. Wires the submitCampaign thunk into the Create Campaign wizard and switches its formStep to a 1-indexed value.

Updates consumers (steps, CreateCampaignPage, GlobalLoadingWrapper + test) to the new state shape and action names, fixes a pre-existing parse error in RecentCampaigns.jsx, and adds comprehensive campaignsSlice.test.js (48 vitest tests passing, lint clean).
CI build flagged src/pages/campaigns/CreateCampaignPage.jsx (9:2): "submitCampaign" is not exported by src/features/campaigns/campaignsSlice.js — submitCampaign lives in campaignsThunks.js. Move it to its own import line so createAsyncThunk-named exports stay in campaignsThunks while sync actions and selectors remain imported from campaignsSlice.

@ayshadogo ayshadogo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LVGTM

@ayshadogo ayshadogo merged commit b4b0a83 into Dfunder:main Jun 24, 2026
2 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 24, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Campaign Slice Setup

2 participants