Skip to content

Commit

Permalink
following feedback -- removing reentry data modal from use. Component…
Browse files Browse the repository at this point in the history
… has been retained for application to other places in future.
  • Loading branch information
siddheshraze committed Sep 24, 2024
1 parent e11b782 commit 2decf65
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 8 deletions.
24 changes: 16 additions & 8 deletions frontend/components/datagrids/isolateddatagridcommons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ import DeleteIcon from '@mui/icons-material/DeleteOutlined';
import { redirect } from 'next/navigation';
import Box from '@mui/joy/Box';
import { StyledDataGrid } from '@/config/styleddatagrid';
import ReEnterDataModal from '@/components/datagrids/reentrydatamodal';
import ConfirmationDialog from '@/components/datagrids/confirmationdialog';
import { randomId } from '@mui/x-data-grid-generator';
import SkipReEnterDataModal from '@/components/datagrids/skipreentrydatamodal';

type EditToolbarProps = EditToolbarCustomProps & GridToolbarProps & ToolbarPropsOverrides;

Expand Down Expand Up @@ -873,17 +873,25 @@ export default function IsolatedDataGridCommons(props: Readonly<IsolatedDataGrid
<Alert {...snackbar} onClose={handleCloseSnackbar} />
</Snackbar>
)}
{/*{isDialogOpen && promiseArguments && (*/}
{/* <ReEnterDataModal*/}
{/* gridType={gridType}*/}
{/* row={promiseArguments.oldRow} // Pass oldRow*/}
{/* reEnterData={promiseArguments.newRow} // Pass newRow*/}
{/* handleClose={handleCancelAction}*/}
{/* handleSave={handleConfirmAction}*/}
{/* columns={gridColumns}*/}
{/* selectionOptions={selectionOptions}*/}
{/* clusters={clusters}*/}
{/* hiddenColumns={getColumnVisibilityModel(gridType)}*/}
{/* />*/}
{/*)}*/}
{isDialogOpen && promiseArguments && (
<ReEnterDataModal
<SkipReEnterDataModal
gridType={gridType}
row={promiseArguments.oldRow} // Pass oldRow
reEnterData={promiseArguments.newRow} // Pass newRow
row={promiseArguments.newRow} // Pass the newRow directly
handleClose={handleCancelAction}
handleSave={handleConfirmAction}
columns={gridColumns}
selectionOptions={selectionOptions}
clusters={clusters}
hiddenColumns={getColumnVisibilityModel(gridType)}
/>
)}
{isDeleteDialogOpen && (
Expand Down
64 changes: 64 additions & 0 deletions frontend/components/datagrids/skipreentrydatamodal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use client';
import React, { useState } from 'react';
import { GridRowModel } from '@mui/x-data-grid';
import { Box, Button, DialogActions, DialogContent, DialogTitle, Modal, ModalDialog, Typography } from '@mui/joy';

interface ReEnterDataModalProps {
gridType: string;
row: GridRowModel;
handleClose: () => void;
handleSave: (confirmedRow: GridRowModel) => void;
}

const SkipReEnterDataModal: React.FC<ReEnterDataModalProps> = ({ gridType, row, handleClose, handleSave }) => {
const [isConfirmStep, setIsConfirmStep] = useState(false);

const handleConfirm = () => {
setIsConfirmStep(true);
};

const handleFinalConfirm = () => {
handleSave(row); // Proceed to save the row directly without reentry
};

return (
<Modal open onClose={handleClose}>
<ModalDialog variant="outlined" sx={{ maxWidth: '90vw', overflow: 'auto' }}>
<DialogTitle>Confirm Changes</DialogTitle>
<DialogContent>
{!isConfirmStep ? (
<Typography level="body-md">You are about to save the following changes to the row. Please confirm to proceed.</Typography>
) : (
<Box className="mt-4" sx={{ display: 'flex', flexDirection: 'column' }}>
<Typography level="title-lg">Please confirm your changes:</Typography>
<Typography level="body-md">Are you sure you want to save these changes to the selected row?</Typography>
</Box>
)}
</DialogContent>
<DialogActions>
{!isConfirmStep ? (
<>
<Button onClick={handleConfirm} color="primary">
Confirm
</Button>
<Button onClick={handleClose} color="primary">
Cancel
</Button>
</>
) : (
<>
<Button onClick={handleFinalConfirm} color="primary">
Save Changes
</Button>
<Button onClick={handleClose} color="primary">
Cancel
</Button>
</>
)}
</DialogActions>
</ModalDialog>
</Modal>
);
};

export default SkipReEnterDataModal;

0 comments on commit 2decf65

Please sign in to comment.