feat: wip import csv [part 1] (#1033)
* feat: wip import csv * feat: start implementing twenty UI * feat: new radio button component * feat: use new radio button component and fix scroll issue * fix: max height modal * feat: wip try to customize react-data-grid to match design * feat: wip match columns * feat: wip match column selection * feat: match column * feat: clean heading component & try to fix scroll in last step * feat: validation step * fix: small cleaning and remove unused component * feat: clean folder architecture * feat: remove translations * feat: remove chackra theme * feat: remove unused libraries * feat: use option button to open spreadsheet & fix stories * Fix lint and fix imports --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
39
front/src/modules/ui/dialog/states/dialogState.ts
Normal file
39
front/src/modules/ui/dialog/states/dialogState.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { atom, selector } from 'recoil';
|
||||
|
||||
import { DialogProps } from '../components/Dialog';
|
||||
|
||||
export type DialogOptions = DialogProps & {
|
||||
id: string;
|
||||
};
|
||||
|
||||
export type DialogState = {
|
||||
maxQueue: number;
|
||||
queue: DialogOptions[];
|
||||
};
|
||||
|
||||
export const dialogInternalState = atom<DialogState>({
|
||||
key: 'dialog/internal-state',
|
||||
default: {
|
||||
maxQueue: 2,
|
||||
queue: [],
|
||||
},
|
||||
});
|
||||
|
||||
export const dialogSetQueueState = selector<DialogOptions | null>({
|
||||
key: 'dialog/queue-state',
|
||||
get: ({ get: _get }) => null, // We don't care about getting the value
|
||||
set: ({ set }, newValue) =>
|
||||
set(dialogInternalState, (prev) => {
|
||||
if (prev.queue.length >= prev.maxQueue) {
|
||||
return {
|
||||
...prev,
|
||||
queue: [...prev.queue.slice(1), newValue] as DialogOptions[],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...prev,
|
||||
queue: [...prev.queue, newValue] as DialogOptions[],
|
||||
};
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user