-
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.
* feat: Delete model functionallity * chore: Populate outcrop in model table correct. Refactor model table component. Bump eds components to eliminate warnings. * chore: Remove console.logs.
- Loading branch information
1 parent
4a172c0
commit 2610add
Showing
8 changed files
with
117 additions
and
116 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import styled from 'styled-components'; | ||
import { spacings } from '../../../tokens/spacings'; | ||
|
||
export const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: ${spacings.MEDIUM}; | ||
> button { | ||
width: fit-content; | ||
} | ||
`; |
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,59 @@ | ||
import { Button, Dialog, Typography } from '@equinor/eds-core-react'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { useState } from 'react'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import { AnalogueModelsService } from '../../../api/generated'; | ||
import { queryClient } from '../../../auth/queryClient'; | ||
import * as Styled from './DeleteModel.styled'; | ||
|
||
export const DeleteModel = () => { | ||
const [open, setOpen] = useState<boolean>(false); | ||
const { modelId } = useParams(); | ||
const navigate = useNavigate(); | ||
|
||
const deleteModel = useMutation({ | ||
mutationFn: ({ id }: { id: string }) => { | ||
return AnalogueModelsService.deleteApiAnalogueModels(id); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['analogue-model'] }); | ||
navigate('/'); | ||
}, | ||
}); | ||
|
||
const HandleModelDelete = async () => { | ||
if (modelId) { | ||
const res = await deleteModel.mutateAsync({ | ||
id: modelId, | ||
}); | ||
return res; | ||
} | ||
}; | ||
|
||
return ( | ||
<Styled.Wrapper> | ||
<Typography variant="h3">Delete model</Typography> | ||
<Typography variant="body_long"> | ||
This will delete the model along with all related cases and results. | ||
</Typography> | ||
<Button onClick={() => setOpen(!open)} color="danger"> | ||
Delete | ||
</Button> | ||
|
||
<Dialog open={open}> | ||
<Dialog.Header>DELETE</Dialog.Header> | ||
<Dialog.Content> | ||
<Typography>Are you sure you want to delete the model?</Typography> | ||
</Dialog.Content> | ||
<Dialog.Actions> | ||
<Button variant="outlined" onClick={() => setOpen(!open)}> | ||
Cancel | ||
</Button> | ||
<Button color="danger" onClick={HandleModelDelete}> | ||
Delete | ||
</Button> | ||
</Dialog.Actions> | ||
</Dialog> | ||
</Styled.Wrapper> | ||
); | ||
}; |
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
Oops, something went wrong.