Skip to content

Commit

Permalink
chore: Add navigate button to each row in model. Removed hardcoded bu…
Browse files Browse the repository at this point in the history
…tton in browse file.
  • Loading branch information
mheggelund committed Oct 19, 2023
1 parent c0260f2 commit cf21801
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
25 changes: 23 additions & 2 deletions src/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { Chip } from '@equinor/eds-core-react';
/* eslint-disable max-lines-per-function */
import { Button, Chip } from '@equinor/eds-core-react';
import { EdsDataGrid } from '@equinor/eds-data-grid-react';
import * as Styled from './Table.styled';
import { useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
import { AnalogueModelsService } from '../api/generated';
import * as Styled from './Table.styled';

export const Table = () => {
const { isLoading, data } = useQuery({
queryKey: ['analogue-models'],
queryFn: () => AnalogueModelsService.getApiAnalogueModels(),
});

const navigate = useNavigate();

if (isLoading || !data?.success) return <p>Loading...</p>;

return (
<Styled.StyledDiv>
<EdsDataGrid
Expand Down Expand Up @@ -60,6 +66,21 @@ export const Table = () => {
header: 'Status',
id: 'isProcessed',
},

{
accessorKey: 'navigate',
cell: ({ row }) => (
<Button
onClick={() => {
navigate(`/model/${row.original.analogueModelId}/details`);
}}
>
Go to model
</Button>
),
header: '',
id: 'navigate',
},
]}
/>
</Styled.StyledDiv>
Expand Down
3 changes: 0 additions & 3 deletions src/pages/Browse/Browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ export const Browse = () => {
<Typography variant="h1">Browse all models</Typography>
<div className="btn-div">
<Button onClick={toggleDialog}>Add new model</Button>
<Button href="/model/4e999a96-34a3-4121-998d-08dbb2a7609c/details">
Model view - Hardkodet
</Button>
</div>
<Table />
</Styled.BrowseWrapper>
Expand Down

0 comments on commit cf21801

Please sign in to comment.