-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎁 Enable 3D in Pipetest sidesheet (#975)
* Added 3d to pipetest app
- Loading branch information
1 parent
5c44c45
commit b610445
Showing
9 changed files
with
539 additions
and
349 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
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
56 changes: 56 additions & 0 deletions
56
libs/pipingsidesheet/src/lib/utils-sidesheet/useGetEchoConfig.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,56 @@ | ||
import { useContextId } from '@cc-components/shared'; | ||
import { useHttpClient } from '@cc-components/shared'; | ||
import { TagOverlay } from '@cc-components/modelviewer'; | ||
|
||
import { useQuery } from '@tanstack/react-query'; | ||
import styled from 'styled-components'; | ||
|
||
const StyledIcon = styled.h3` | ||
overflow: hidden; | ||
`; | ||
|
||
export const useGetEchoConfig = (pipetestId: string) => { | ||
const client = useHttpClient(); | ||
const contextId = useContextId(); | ||
|
||
const { data, isFetching, error } = useQuery<EchoConfig>({ | ||
queryKey: ['model-tags', pipetestId], | ||
queryFn: async ({ signal }) => { | ||
const response = await client.fetch( | ||
`/api/contexts/${contextId}/pipetest/${pipetestId}/echo`, | ||
{ signal } | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error('Failed to get model tags', { cause: response }); | ||
} | ||
|
||
return response.json(); | ||
}, | ||
}); | ||
|
||
const tagsOverlay: TagOverlay[] | undefined = data?.tags?.map((tag) => ({ | ||
tagNo: tag.tagNo, | ||
description: tag.description, | ||
status: tag.status, | ||
icon: <StyledIcon>{tag.status}</StyledIcon>, | ||
})); | ||
|
||
return { | ||
data, | ||
tagsOverlay: tagsOverlay ?? [], | ||
isFetching, | ||
error, | ||
}; | ||
}; | ||
|
||
export type EchoConfig = { | ||
facilities: string[]; | ||
tags: EchoTag[]; | ||
}; | ||
|
||
export type EchoTag = { | ||
tagNo: string; | ||
description: string; | ||
status: string; | ||
}; |
Oops, something went wrong.