96 switch from azure table storage to sqlite (#97)
* adding typeorm to api * switching to sqlite * switching to sqlite * switching to sqlite * migrating to sqlite * updating terraform * updating infrastructure
This commit was merged in pull request #97.
This commit is contained in:
70
client/src/components/logbook/reducer.ts
Normal file
70
client/src/components/logbook/reducer.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { ColumnDef } from '@noahspan/noahspan-components';
|
||||
import { FormMode } from '../../enums/formMode';
|
||||
import { Alert } from '../../interfaces/Alert.interface';
|
||||
import { LogbookEntry } from './LogbookEntry.interface';
|
||||
import { LogbookState } from './LogbookState.interface';
|
||||
|
||||
type Action =
|
||||
| { type: 'SET_COLUMNS'; payload: ColumnDef<LogbookEntry>[] }
|
||||
| { type: 'SET_IS_CONFIRMATION_DIALOG_OPEN'; payload: boolean }
|
||||
| { type: 'SET_ENTRIES'; payload: LogbookEntry[] }
|
||||
| { type: 'SET_ALERT'; payload: Alert | undefined }
|
||||
| { type: 'SET_IS_CONFIRMATION_DIALOG_LOADING'; payload: boolean }
|
||||
| { type: 'SET_IS_LOADING'; payload: boolean };
|
||||
|
||||
|
||||
export const initialState: LogbookState = {
|
||||
alert: undefined,
|
||||
columns: [],
|
||||
entries: [],
|
||||
isConfirmDialogLoading: false,
|
||||
isConfirmDialogOpen: false,
|
||||
isLoading: false
|
||||
};
|
||||
|
||||
export const reducer = (
|
||||
state: LogbookState,
|
||||
action: Action
|
||||
): LogbookState => {
|
||||
switch (action.type) {
|
||||
case 'SET_COLUMNS': {
|
||||
return {
|
||||
...state,
|
||||
columns: action.payload
|
||||
}
|
||||
}
|
||||
case 'SET_IS_CONFIRMATION_DIALOG_OPEN': {
|
||||
return {
|
||||
...state,
|
||||
isConfirmDialogOpen: action.payload,
|
||||
};
|
||||
}
|
||||
case 'SET_ENTRIES': {
|
||||
return {
|
||||
...state,
|
||||
entries: action.payload
|
||||
};
|
||||
}
|
||||
case 'SET_ALERT': {
|
||||
return {
|
||||
...state,
|
||||
alert: action.payload
|
||||
};
|
||||
}
|
||||
case 'SET_IS_CONFIRMATION_DIALOG_LOADING': {
|
||||
return {
|
||||
...state,
|
||||
isConfirmDialogLoading: action.payload
|
||||
};
|
||||
}
|
||||
case 'SET_IS_LOADING': {
|
||||
return {
|
||||
...state,
|
||||
isLoading: action.payload
|
||||
};
|
||||
}
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user