Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
34 lines
911 B
Plaintext
34 lines
911 B
Plaintext
'use client';
|
|
|
|
export const defaultLoadingOverlayState = {
|
|
isLoading: false,
|
|
loaders: [],
|
|
loadingText: '',
|
|
overlayType: null
|
|
};
|
|
export const reducer = (state, action) => {
|
|
const loadersCopy = [...state.loaders];
|
|
const {
|
|
type = 'fullscreen',
|
|
key = 'user',
|
|
loadingText
|
|
} = action.payload;
|
|
if (action.type === 'add') {
|
|
loadersCopy.push({
|
|
type,
|
|
key,
|
|
loadingText
|
|
});
|
|
} else if (action.type === 'remove') {
|
|
const index = loadersCopy.findIndex(item => item.key === key && item.type === type);
|
|
loadersCopy.splice(index, 1);
|
|
}
|
|
const nextLoader = loadersCopy?.length > 0 ? loadersCopy[loadersCopy.length - 1] : null;
|
|
return {
|
|
isLoading: Boolean(nextLoader),
|
|
loaders: loadersCopy,
|
|
loadingText: nextLoader?.loadingText || state?.loadingText,
|
|
overlayType: nextLoader?.type || state?.overlayType
|
|
};
|
|
};
|
|
//# sourceMappingURL=reducer.js.map |