-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check and warning if model area has linked results.
- Loading branch information
1 parent
a974d8a
commit f54d9e9
Showing
8 changed files
with
206 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/components/AreaCoordinates/CoordinatesDialog/CoordinatesDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* eslint-disable max-lines */ | ||
/* eslint-disable max-lines-per-function */ | ||
|
||
import { Button, Dialog, Snackbar } from '@equinor/eds-core-react'; | ||
import { useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { CoordinateDto } from '../../../api/generated'; | ||
import { useFetchModel } from '../../../hooks/useFetchModel'; | ||
import { useFetchModelAreas } from '../../../hooks/useFetchModelAreas'; | ||
import { AreaCoordinates } from '../AreaCoordinates'; | ||
import * as Styled from '../AreaCoordinates.styled'; | ||
|
||
export type AreaCoordinateType = { | ||
modelAreaId: string; | ||
coordinates: CoordinateDto[]; | ||
}; | ||
|
||
export const CoordinatesDialog = ({ | ||
open, | ||
toggleOpen, | ||
}: { | ||
open: boolean; | ||
toggleOpen: () => void; | ||
}) => { | ||
const [showSaveAlert, setSaveAlert] = useState(false); | ||
|
||
const { modelId } = useParams(); | ||
|
||
const { data, isLoading } = useFetchModel(modelId); | ||
const modelAreas = useFetchModelAreas(); | ||
|
||
function clearStatus() { | ||
setSaveAlert(false); | ||
} | ||
|
||
const handleCloseDialog = () => { | ||
toggleOpen(); | ||
}; | ||
|
||
if (modelAreas.isLoading || modelAreas.data === undefined || isLoading) | ||
return <p>Loading.....</p>; | ||
|
||
return ( | ||
<> | ||
<Styled.Dialog open={open}> | ||
<Dialog.Header> | ||
<Dialog.Title>Manage model areas for {data?.data.name}</Dialog.Title> | ||
</Dialog.Header> | ||
<Styled.Content> | ||
<AreaCoordinates setSaveAlert={setSaveAlert}></AreaCoordinates> | ||
</Styled.Content> | ||
|
||
<Dialog.Actions> | ||
<Button variant="outlined" onClick={handleCloseDialog}> | ||
Close | ||
</Button> | ||
</Dialog.Actions> | ||
</Styled.Dialog> | ||
<Snackbar | ||
open={!!showSaveAlert} | ||
autoHideDuration={3000} | ||
onClose={clearStatus} | ||
> | ||
{'Area coordinate saved'} | ||
</Snackbar> | ||
</> | ||
); | ||
}; |
4 changes: 2 additions & 2 deletions
4
.../AreaCoordinates/AreaCoordinates.hooks.ts → ...oordinates/hooks/AreaCoordinates.hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.