Skip to content

Commit

Permalink
Update flash.js
Browse files Browse the repository at this point in the history
This gives a slice some new functionality based on the needs of
existing projects.
  • Loading branch information
jho406 committed Oct 16, 2024
1 parent b91c580 commit 903c2c6
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions superglue_rails/lib/install/templates/web/flash.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import { createSlice } from '@reduxjs/toolkit'
import { createSlice } from '@reduxjs/toolkit';
import { saveResponse, beforeVisit } from '@thoughtbot/superglue'

export const flashSlice = createSlice({
name: 'flash',
initialState: {},
reducers: {
clearFlash() {
return {};
},
flash(state, { payload }) {
return payload;
},
},
extraReducers: (builder) => {
builder.addCase(beforeVisit, (state, action) => {
return {}
})
return {};
});
builder.addCase(saveResponse, (state, action) => {
const { page } = action.payload;

return {
...state, ...page.slices.flash
}
})
}
})
...state,
...page.slices.flash,
};
});
},
});

export const { clearFlash, flash } = flashSlice.actions;


0 comments on commit 903c2c6

Please sign in to comment.