Introduce a loading state to SaveButton and SaveAndCancelButtons components to enhance user feedback during save operations. Update SettingsNewObject to manage the loading state while submitting the form. Fix https://github.com/twentyhq/core-team-issues/issues/572 --------- Co-authored-by: Charles Bochet <charles@twenty.com>
38 lines
818 B
TypeScript
38 lines
818 B
TypeScript
import styled from '@emotion/styled';
|
|
|
|
import { CancelButton } from './CancelButton';
|
|
import { SaveButton } from './SaveButton';
|
|
|
|
const StyledContainer = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
`;
|
|
|
|
type SaveAndCancelButtonsProps = {
|
|
onSave?: () => void;
|
|
isLoading?: boolean;
|
|
onCancel?: () => void;
|
|
isSaveDisabled?: boolean;
|
|
isCancelDisabled?: boolean;
|
|
};
|
|
|
|
export const SaveAndCancelButtons = ({
|
|
onSave,
|
|
isLoading,
|
|
onCancel,
|
|
isSaveDisabled,
|
|
isCancelDisabled,
|
|
}: SaveAndCancelButtonsProps) => {
|
|
return (
|
|
<StyledContainer>
|
|
<CancelButton onCancel={onCancel} disabled={isCancelDisabled} />
|
|
<SaveButton
|
|
onSave={onSave}
|
|
disabled={isSaveDisabled}
|
|
isLoading={isLoading}
|
|
/>
|
|
</StyledContainer>
|
|
);
|
|
};
|