Skip to content
Snippets Groups Projects
Commit c644652e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

adjust types to response after changing backend

parent 84f195bb
No related branches found
No related tags found
1 merge request!247Resolve "Adjust processing of overview images to the new backend"
Pipeline #95395 passed
......@@ -51,8 +51,8 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
const handleSetMapPosition = (link: OverviewImageLinkModel, model: MapModel): void => {
const zoom = link.zoomLevel + model.minZoom;
const { x } = link.modelPoint;
const { y } = link.modelPoint;
const x = link.xCoord;
const y = link.yCoord;
dispatch(
setMapPosition({
......@@ -64,7 +64,7 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
};
const onSubmapClick: OverviewImageLinkModelHandler = link => {
const modelId = link.modelLinkId;
const modelId = link.linkedModel;
const model = getModelById(modelId);
if (!model) {
return;
......@@ -76,17 +76,17 @@ export const useOverviewImageLinkActions = (): UseOverviewImageLinkActionsResult
};
const onImageClick: OverviewImageLinkImageHandler = link => {
const isImageAvailable = checkIfImageIsAvailable(link.imageLinkId);
const isImageAvailable = checkIfImageIsAvailable(link.linkedOverviewImage);
if (!isImageAvailable) {
return;
}
dispatch(setOverviewImageId(link.imageLinkId));
dispatch(setOverviewImageId(link.linkedOverviewImage));
};
const handleLinkClick: UseOverviewImageLinkActionsResult['handleLinkClick'] = link => {
const isImageLink = 'imageLinkId' in link;
const isModelLink = 'modelLinkId' in link;
const isImageLink = 'linkedOverviewImage' in link;
const isModelLink = 'linkedModel' in link;
if (isImageLink) {
return onImageClick(link);
......
......@@ -18,7 +18,7 @@ export const useOverviewImageLinkConfigs = ({
if (!currentImage || sizeFactor === ZERO) return [];
return currentImage.links.map(link => ({
idObject: link.idObject,
idObject: link.id,
size: getOverviewImageLinkSize(link, { sizeFactor }),
onClick: () => handleLinkClick(link),
}));
......
......@@ -2,20 +2,18 @@ import { PROJECT_OVERVIEW_IMAGE_MOCK } from '@/redux/project/project.mock';
import { OverviewImageLinkImage, OverviewImageLinkModel } from '@/types/models';
export const OVERVIEW_LINK_IMAGE_MOCK: OverviewImageLinkImage = {
idObject: 1,
id: 1,
polygon: [],
imageLinkId: PROJECT_OVERVIEW_IMAGE_MOCK.id,
type: 'OverviewImageLink',
linkedOverviewImage: PROJECT_OVERVIEW_IMAGE_MOCK.id,
// type: 'OverviewImageLink',
};
export const OVERVIEW_LINK_MODEL_MOCK: OverviewImageLinkModel = {
idObject: 1,
id: 1,
polygon: [],
zoomLevel: 5,
modelPoint: {
x: 15570.0,
y: 3016.0,
},
modelLinkId: 5053,
type: 'OverviewImageLink',
xCoord: 15570.0,
yCoord: 3016.0,
linkedModel: 5053,
// type: 'OverviewImageLink',
};
......@@ -2,19 +2,20 @@ import { z } from 'zod';
import { positionSchema } from './positionSchema';
export const overviewImageLinkImage = z.object({
idObject: z.number(),
id: z.number(),
polygon: z.array(positionSchema),
imageLinkId: z.number(),
type: z.string(),
linkedOverviewImage: z.number(),
// type: z.string(),
});
export const overviewImageLinkModel = z.object({
idObject: z.number(),
id: z.number(),
polygon: z.array(positionSchema),
zoomLevel: z.number(),
modelPoint: positionSchema,
modelLinkId: z.number(),
type: z.string(),
xCoord: z.number(),
yCoord: z.number(),
linkedModel: z.number(),
// type: z.string(),
});
export const overviewImageLink = z.union([overviewImageLinkImage, overviewImageLinkModel]);
......@@ -16,7 +16,7 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
height: 4040,
links: [
{
idObject: 2062,
id: 2062,
polygon: [
{
x: 515,
......@@ -36,15 +36,13 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
},
],
zoomLevel: 4,
modelPoint: {
x: 3473,
y: 5871,
},
modelLinkId: 5053,
type: 'OverviewModelLink',
xCoord: 3473,
yCoord: 5871,
linkedModel: 5053,
// type: 'OverviewModelLink',
},
{
idObject: 2063,
id: 2063,
polygon: [
{
x: 2410,
......@@ -63,11 +61,11 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
y: 1570,
},
],
imageLinkId: 435,
type: 'OverviewImageLink',
linkedOverviewImage: 435,
// type: 'OverviewImageLink',
},
{
idObject: 2064,
id: 2064,
polygon: [
{
x: 2830,
......@@ -87,15 +85,13 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
},
],
zoomLevel: 5,
modelPoint: {
x: 8081,
y: 1240,
},
modelLinkId: 5053,
type: 'OverviewModelLink',
xCoord: 8081,
yCoord: 1240,
linkedModel: 5053,
// type: 'OverviewModelLink',
},
{
idObject: 2065,
id: 2065,
polygon: [
{
x: 3232,
......@@ -114,11 +110,11 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
y: 2456,
},
],
imageLinkId: 433,
type: 'OverviewImageLink',
linkedOverviewImage: 433,
// type: 'OverviewImageLink',
},
{
idObject: 2066,
id: 2066,
polygon: [
{
x: 4205,
......@@ -138,15 +134,13 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
},
],
zoomLevel: 5,
modelPoint: {
x: 7488,
y: 11986,
},
modelLinkId: 5053,
type: 'OverviewModelLink',
xCoord: 7488,
yCoord: 11986,
linkedModel: 5053,
// type: 'OverviewModelLink',
},
{
idObject: 2067,
id: 2067,
polygon: [
{
x: 4960,
......@@ -165,8 +159,8 @@ export const PROJECT_OVERVIEW_IMAGE_MOCK: NonNullable<OverviewImageView> = {
y: 2163,
},
],
imageLinkId: 434,
type: 'OverviewImageLink',
linkedOverviewImage: 434,
// type: 'OverviewImageLink',
},
],
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment