mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-07 03:35:18 +02:00
Split BookmarksTable into separate components. Minor changes to reducers
This commit is contained in:
parent
e15c2a2f07
commit
a02814aa02
10 changed files with 422 additions and 302 deletions
|
@ -22,77 +22,86 @@ export const appsReducer = (
|
|||
action: Action
|
||||
): AppsState => {
|
||||
switch (action.type) {
|
||||
case ActionType.getApps:
|
||||
case ActionType.getApps: {
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
errors: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.getAppsSuccess:
|
||||
case ActionType.getAppsSuccess: {
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
apps: action.payload || [],
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.pinApp:
|
||||
const pinnedAppIdx = state.apps.findIndex(
|
||||
case ActionType.pinApp: {
|
||||
const appIdx = state.apps.findIndex(
|
||||
(app) => app.id === action.payload.id
|
||||
);
|
||||
|
||||
return {
|
||||
...state,
|
||||
apps: [
|
||||
...state.apps.slice(0, pinnedAppIdx),
|
||||
...state.apps.slice(0, appIdx),
|
||||
action.payload,
|
||||
...state.apps.slice(pinnedAppIdx + 1),
|
||||
...state.apps.slice(appIdx + 1),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.addAppSuccess:
|
||||
case ActionType.addAppSuccess: {
|
||||
return {
|
||||
...state,
|
||||
apps: [...state.apps, action.payload],
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.deleteApp:
|
||||
case ActionType.deleteApp: {
|
||||
return {
|
||||
...state,
|
||||
apps: [...state.apps].filter((app) => app.id !== action.payload),
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.updateApp:
|
||||
const updatedAppIdx = state.apps.findIndex(
|
||||
case ActionType.updateApp: {
|
||||
const appIdx = state.apps.findIndex(
|
||||
(app) => app.id === action.payload.id
|
||||
);
|
||||
|
||||
return {
|
||||
...state,
|
||||
apps: [
|
||||
...state.apps.slice(0, updatedAppIdx),
|
||||
...state.apps.slice(0, appIdx),
|
||||
action.payload,
|
||||
...state.apps.slice(updatedAppIdx + 1),
|
||||
...state.apps.slice(appIdx + 1),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.reorderApps:
|
||||
case ActionType.reorderApps: {
|
||||
return {
|
||||
...state,
|
||||
apps: action.payload,
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.sortApps:
|
||||
case ActionType.sortApps: {
|
||||
return {
|
||||
...state,
|
||||
apps: sortData<App>(state.apps, action.payload),
|
||||
};
|
||||
}
|
||||
|
||||
case ActionType.setEditApp:
|
||||
case ActionType.setEditApp: {
|
||||
return {
|
||||
...state,
|
||||
appInUpdate: action.payload,
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
|
|
|
@ -22,24 +22,28 @@ export const authReducer = (
|
|||
token: action.payload,
|
||||
isAuthenticated: true,
|
||||
};
|
||||
|
||||
case ActionType.logout:
|
||||
return {
|
||||
...state,
|
||||
token: null,
|
||||
isAuthenticated: false,
|
||||
};
|
||||
|
||||
case ActionType.autoLogin:
|
||||
return {
|
||||
...state,
|
||||
token: action.payload,
|
||||
isAuthenticated: true,
|
||||
};
|
||||
|
||||
case ActionType.authError:
|
||||
return {
|
||||
...state,
|
||||
token: null,
|
||||
isAuthenticated: false,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -26,26 +26,31 @@ export const configReducer = (
|
|||
loading: false,
|
||||
config: action.payload,
|
||||
};
|
||||
|
||||
case ActionType.updateConfig:
|
||||
return {
|
||||
...state,
|
||||
config: action.payload,
|
||||
};
|
||||
|
||||
case ActionType.fetchQueries:
|
||||
return {
|
||||
...state,
|
||||
customQueries: action.payload,
|
||||
};
|
||||
|
||||
case ActionType.addQuery:
|
||||
return {
|
||||
...state,
|
||||
customQueries: [...state.customQueries, action.payload],
|
||||
};
|
||||
|
||||
case ActionType.deleteQuery:
|
||||
return {
|
||||
...state,
|
||||
customQueries: action.payload,
|
||||
};
|
||||
|
||||
case ActionType.updateQuery:
|
||||
return {
|
||||
...state,
|
||||
|
|
|
@ -29,6 +29,7 @@ export const notificationReducer = (
|
|||
],
|
||||
idCounter: state.idCounter + 1,
|
||||
};
|
||||
|
||||
case ActionType.clearNotification:
|
||||
return {
|
||||
...state,
|
||||
|
|
|
@ -24,6 +24,7 @@ export const themeReducer = (
|
|||
switch (action.type) {
|
||||
case ActionType.setTheme:
|
||||
return { theme: action.payload };
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue