fix: campaign slice setup (#85)#96
Merged
ayshadogo merged 2 commits intoJun 24, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;formStepis 1-indexed (initial 1, maxCAMPAIGN_STEPS.length);currentCampaignis promoted on create/update/fetchById successsrc/features/campaigns/campaignsThunks.js— API-backed thunks with inlinedtry/catch + toast + rejectWithValuematching theauthThunks.jsstyle;submitCampaignaccepts either an id or a full draftsrc/features/campaigns/campaignsSelectors.js— reads new state shape; addsselectCurrentCampaignsrc/pages/campaigns/CreateCampaignPage.jsx— 1-indexed formStep math (STEP_META[formStep - 1],Step Nindicator matches the index); Submit button dispatchessubmitCampaign(draft); Discard-draft button surfaces whenever the form is dirtysrc/components/campaigns/steps/{BasicInfoStep,MediaStep,FundingStep,DetailsStep}.jsx—updateDraftCampaign→updateDraftsrc/components/common/GlobalLoadingWrapper.jsx(+.test.jsx) —state.campaigns.loading→isLoadingsrc/components/dashboard/RecentCampaigns.jsx— fixed a pre-existing duplicateimport {parse errorsrc/features/campaigns/campaignsSlice.test.js(new) — comprehensive sync + dispatched-thunk tests via realconfigureStoreTesting
npm test→ 48/48 vitest tests passing across 11 filesnpm run lint→ passes (only an unrelated, pre-existing React-Compiler warning inBasicInfoStep.jsxremains)Closes #85