[Glitch] Allow editing status quote policy

Port 651e51a82e to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2025-08-14 17:04:32 +02:00
committed by Claire
parent 8a7324d114
commit 2a593bd89e
17 changed files with 576 additions and 15 deletions

View File

@@ -29,6 +29,7 @@ import {
STATUS_FETCH_REQUEST,
STATUS_FETCH_FAIL,
} from '../actions/statuses';
import { setStatusQuotePolicy } from '../actions/statuses_typed';
const importStatus = (state, status) => state.set(status.id, fromJS(status));
@@ -70,6 +71,22 @@ const initialState = ImmutableMap();
/** @type {import('@reduxjs/toolkit').Reducer<typeof initialState>} */
export default function statuses(state = initialState, action) {
if (setStatusQuotePolicy.pending.match(action)) {
const status = state.get(action.meta.arg.statusId);
if (status) {
return state.setIn([action.meta.arg.statusId, 'isSavingQuotePolicy'], true);
}
} else if (setStatusQuotePolicy.fulfilled.match(action)) {
const status = state.get(action.payload.id);
if (status) {
return state
.setIn([action.payload.id, 'quote_approval'], action.payload.quote_approval)
.deleteIn([action.payload.id, 'isSavingQuotePolicy']);
}
} else if (setStatusQuotePolicy.rejected.match(action)) {
return state.deleteIn([action.meta.arg.statusId, 'isSavingQuotePolicy']);
}
switch(action.type) {
case STATUS_FETCH_REQUEST:
return state.setIn([action.id, 'isLoading'], true);