@nyris/nyris-webapp 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/build/asset-manifest.json +8 -8
  2. package/build/index.html +1 -1
  3. package/build/{precache-manifest.01ce682577e62add75aa397b2a944b75.js → precache-manifest.9800bdc87f5a2c5d6d8a5d1a5287598f.js} +9 -9
  4. package/build/service-worker.js +1 -1
  5. package/build/static/js/2.29ddd567.chunk.js +3 -0
  6. package/build/static/js/{2.d1562c08.chunk.js.LICENSE.txt → 2.29ddd567.chunk.js.LICENSE.txt} +0 -9
  7. package/build/static/js/2.29ddd567.chunk.js.map +1 -0
  8. package/build/static/js/main.c35ded37.chunk.js +2 -0
  9. package/build/static/js/main.c35ded37.chunk.js.map +1 -0
  10. package/package.json +3 -3
  11. package/src/App.tsx +3 -6
  12. package/src/Store/Nyris.ts +7 -7
  13. package/src/Store/Search.ts +11 -10
  14. package/src/Store/Store.ts +12 -5
  15. package/src/components/DragDropFile.tsx +9 -9
  16. package/src/components/Feedback.tsx +2 -2
  17. package/src/components/Footer.tsx +1 -1
  18. package/src/components/HeaderMd.tsx +4 -5
  19. package/src/index.tsx +2 -1
  20. package/src/modules/LandingPage/{indexApp.tsx → App.tsx} +53 -227
  21. package/src/modules/LandingPage/{indexAppMD.tsx → AppMD.tsx} +49 -151
  22. package/src/modules/LandingPage/index.tsx +193 -0
  23. package/src/modules/LandingPage/indexNewVersion.tsx +7 -14
  24. package/src/modules/LandingPage/propsType.ts +43 -0
  25. package/src/page/result/index.tsx +11 -16
  26. package/src/services/findRegionsCustom.ts +0 -197
  27. package/src/services/image.ts +11 -14
  28. package/src/services/session.ts +6 -6
  29. package/src/services/types.ts +1 -15
  30. package/src/types.ts +0 -1
  31. package/build/static/js/2.d1562c08.chunk.js +0 -3
  32. package/build/static/js/2.d1562c08.chunk.js.map +0 -1
  33. package/build/static/js/main.5c08aba4.chunk.js +0 -2
  34. package/build/static/js/main.5c08aba4.chunk.js.map +0 -1
  35. package/src/App.test.tsx +0 -49
  36. package/src/Store/epics/feedback.ts +0 -59
  37. package/src/Store/epics/types.ts +0 -12
  38. package/src/components/preview/preview.tsx +0 -433
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyris/nyris-webapp",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "homepage": "./",
5
5
  "dependencies": {
6
6
  "@babel/runtime": "^7.17.2",
@@ -8,8 +8,8 @@
8
8
  "@material-ui/data-grid": "^4.0.0-alpha.37",
9
9
  "@material-ui/icons": "^4.4.1",
10
10
  "@material-ui/lab": "^4.0.0-alpha.60",
11
- "@nyris/nyris-api": "^0.3.3",
12
- "@nyris/nyris-react-components": "^0.3.3",
11
+ "@nyris/nyris-api": "^0.3.4",
12
+ "@nyris/nyris-react-components": "^0.3.4",
13
13
  "@reduxjs/toolkit": "^1.6.1",
14
14
  "@types/blueimp-load-image": "^2.23.4",
15
15
  "@types/classnames": "^2.2.9",
package/src/App.tsx CHANGED
@@ -4,17 +4,14 @@ import React from "react";
4
4
  import "typeface-roboto";
5
5
  import "index.css";
6
6
  import { useAppSelector } from "Store/Store";
7
- import LandingPageApp from "modules/LandingPage/indexApp";
8
- import LandingPageAppMD from "modules/LandingPage/indexAppMD";
7
+ import LandingPageApp from "modules/LandingPage/index";
9
8
  import AppNewVersion from "modules/LandingPage/indexNewVersion";
10
9
  import {AppState} from "./types";
11
10
 
12
11
  function App(): JSX.Element {
13
12
  const { settings } = useAppSelector<AppState>((state: any) => state);
14
- const { themePage }: any = settings;
15
- let SelectedApp =
16
- themePage.default?.active ? LandingPageApp : (
17
- themePage.mdWhiteLabel?.active ? LandingPageAppMD : AppNewVersion);
13
+ const { themePage } = settings;
14
+ let SelectedApp = themePage.searchSuite?.active ? AppNewVersion : LandingPageApp;
18
15
 
19
16
  return <SelectedApp />;
20
17
  }
@@ -1,4 +1,4 @@
1
- import { createSlice, PayloadAction } from "@reduxjs/toolkit";
1
+ import { createSlice } from "@reduxjs/toolkit";
2
2
 
3
3
  export type NyrisAppPart = "start" | "camera" | "results";
4
4
  export type NyrisFeedbackState =
@@ -20,7 +20,7 @@ export const nyrisSlice = createSlice({
20
20
  name: "nyris",
21
21
  initialState,
22
22
  reducers: {
23
- showStart: (state, _data: PayloadAction<any>) => {
23
+ showStart: (state) => {
24
24
  return {
25
25
  ...state,
26
26
  showPart: "start",
@@ -32,31 +32,31 @@ export const nyrisSlice = createSlice({
32
32
  showPart: "camera",
33
33
  };
34
34
  },
35
- showResults: (state, _data: PayloadAction<any>) => {
35
+ showResults: (state) => {
36
36
  return {
37
37
  ...state,
38
38
  showPart: "results",
39
39
  };
40
40
  },
41
- showFeedback: (state, _data: PayloadAction<any>) => {
41
+ showFeedback: (state) => {
42
42
  return {
43
43
  ...state,
44
44
  feedbackState: "question",
45
45
  };
46
46
  },
47
- hideFeedback: (state, _data: PayloadAction<any>) => {
47
+ hideFeedback: (state) => {
48
48
  return {
49
49
  ...state,
50
50
  feedbackState: "hidden",
51
51
  };
52
52
  },
53
- feedbackSubmitPositive: (state, _data: PayloadAction<any>) => {
53
+ feedbackSubmitPositive: (state) => {
54
54
  return {
55
55
  ...state,
56
56
  feedbackState: "positive",
57
57
  };
58
58
  },
59
- feedbackNegative: (state, _data: PayloadAction<any>) => {
59
+ feedbackNegative: (state) => {
60
60
  return {
61
61
  ...state,
62
62
  feedbackState: "negative",
@@ -80,11 +80,12 @@ const initialState: SearchState = {
80
80
  loadingSearchAlgolia: false,
81
81
  };
82
82
 
83
- export const searchSlice = createSlice({
84
- name: "search",
85
- initialState,
86
- reducers: {
87
- loadFile: (state, data: PayloadAction<any>) => {
83
+
84
+ export const searchSlice = createSlice({
85
+ name: "search",
86
+ initialState,
87
+ reducers: {
88
+ setSearchResults: (state, data) => {
88
89
  const { payload } = data;
89
90
  const {
90
91
  requestImage,
@@ -144,19 +145,19 @@ export const searchSlice = createSlice({
144
145
  fetchingRegions: false,
145
146
  };
146
147
  },
147
- submitPositiveFeedback: (state, data: PayloadAction<RectCoords>) => {
148
+ submitPositiveFeedback: () => {
148
149
  return;
149
150
  },
150
- submitNegativeFeedback: (state, data: PayloadAction<RectCoords>) => {
151
+ submitNegativeFeedback: () => {
151
152
  return;
152
153
  },
153
- loadingActionResults: (state, _data: PayloadAction<any>) => {
154
+ loadingActionResults: (state) => {
154
155
  return {
155
156
  ...state,
156
157
  fetchingResults: true,
157
158
  };
158
159
  },
159
- loadingActionRegions: (state, _data: PayloadAction<any>) => {
160
+ loadingActionRegions: (state) => {
160
161
  return {
161
162
  ...state,
162
163
  fetchingRegions: true,
@@ -249,7 +250,7 @@ export const searchSlice = createSlice({
249
250
  });
250
251
 
251
252
  export const {
252
- loadFile,
253
+ setSearchResults,
253
254
  selectionChanged,
254
255
  submitPositiveFeedback,
255
256
  submitNegativeFeedback,
@@ -1,21 +1,29 @@
1
1
  import { configureStore } from "@reduxjs/toolkit";
2
2
  import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
3
3
  import { combineReducers } from "redux";
4
- import thunk from "redux-thunk";
5
4
  import Auth from "Store/Auth";
6
- import { AppSettings } from "types";
7
- import { defaultSettings } from "defaults";
5
+ import {AppSettings, MDSettings} from "types";
8
6
  import { getUrlParam } from "utils";
9
7
  import Search from "Store/Search";
10
8
  import Nyris from "Store/Nyris";
9
+ import {defaultMdSettings, defaultSettings} from "../defaults";
11
10
 
12
11
  declare var settings: AppSettings;
13
12
 
13
+
14
+
14
15
  let normalizedSettings: AppSettings = {
15
16
  ...defaultSettings,
16
17
  ...settings,
17
18
  };
18
19
 
20
+ // spread default settings for material design
21
+ let mdSettings : MDSettings = {
22
+ ...defaultMdSettings,
23
+ ...settings.themePage.materialDesign
24
+ }
25
+ normalizedSettings.themePage.materialDesign = mdSettings;
26
+
19
27
  normalizedSettings = {
20
28
  ...normalizedSettings,
21
29
  apiKey: (getUrlParam("apiKey") as string) || normalizedSettings.apiKey,
@@ -28,7 +36,7 @@ normalizedSettings = {
28
36
 
29
37
  const reducers = combineReducers({
30
38
  auth: Auth,
31
- settings: () => normalizedSettings as AppSettings,
39
+ settings: () => normalizedSettings,
32
40
  search: Search,
33
41
  nyris: Nyris,
34
42
  });
@@ -36,7 +44,6 @@ const reducers = combineReducers({
36
44
  export const store = configureStore({
37
45
  reducer: reducers,
38
46
  devTools: process.env.NODE_ENV !== "production",
39
- middleware: [thunk],
40
47
  });
41
48
 
42
49
  export type RootState = ReturnType<typeof store.getState>;
@@ -6,7 +6,7 @@ import { makeFileHandler } from "@nyris/nyris-react-components";
6
6
  import { useAppDispatch, useAppSelector } from "Store/Store";
7
7
  import { serviceImage, serviceImageNonRegion } from "services/image";
8
8
  import {
9
- loadFile,
9
+ setSearchResults,
10
10
  loadingActionResults,
11
11
  searchFileImageNonRegion,
12
12
  } from "Store/Search";
@@ -40,7 +40,7 @@ function DragDropFile(props: Props) {
40
40
  setLoadingLoadFile(true);
41
41
  console.log("fs", fs);
42
42
 
43
- return serviceImage(fs[0], searchState).then((res: any) => {
43
+ return serviceImage(fs[0], searchState.settings).then((res: any) => {
44
44
  console.log("res?.results", res);
45
45
 
46
46
  res?.results.map((item: any) => {
@@ -56,29 +56,29 @@ function DragDropFile(props: Props) {
56
56
  };
57
57
  console.log("payload", payload);
58
58
 
59
- dispatch(loadFile(payload));
59
+ dispatch(setSearchResults(payload));
60
60
  setLoadingLoadFile(false);
61
61
  onChangeLoading(false);
62
62
  history.push("/result");
63
- return dispatch(showFeedback(""));
63
+ return dispatch(showFeedback());
64
64
  });
65
65
  },
66
66
  });
67
67
 
68
68
  const getUrlToCanvasFile = (url: string, position?: number) => {
69
69
  onChangeLoading(true);
70
- dispatch(showResults(""));
71
- dispatch(loadingActionResults(""));
70
+ dispatch(showResults());
71
+ dispatch(loadingActionResults());
72
72
  if (position) {
73
73
  feedbackClickEpic(searchState, position);
74
74
  }
75
75
 
76
76
  if (settings.regions) {
77
- serviceImage(url, searchState).then((res) => {
78
- dispatch(loadFile(res));
77
+ serviceImage(url, searchState.settings).then((res) => {
78
+ dispatch(setSearchResults(res));
79
79
  onChangeLoading(false);
80
80
  history.push("/result");
81
- return dispatch(showFeedback(""));
81
+ return dispatch(showFeedback());
82
82
  });
83
83
  } else {
84
84
  serviceImageNonRegion(url, searchState, rectCoords).then((res) => {
@@ -19,9 +19,9 @@ const Feedback: React.FC<FeedbackProps> = ({ feedbackState, onClose }) => {
19
19
  const onPositiveFeedback = (data: boolean) => {
20
20
  feedbackSuccessEpic(state, data);
21
21
  if (data) {
22
- dispatch(feedbackSubmitPositive(""));
22
+ dispatch(feedbackSubmitPositive());
23
23
  } else {
24
- dispatch(feedbackNegative(""));
24
+ dispatch(feedbackNegative());
25
25
  }
26
26
  };
27
27
 
@@ -19,7 +19,7 @@ function FooterComponent(): JSX.Element {
19
19
  <Feedback
20
20
  feedbackState={feedbackState}
21
21
  onClose={() => {
22
- return dispatch(hideFeedback(""));
22
+ return dispatch(hideFeedback());
23
23
  }}
24
24
  />
25
25
  </>
@@ -1,17 +1,16 @@
1
1
  import React from "react";
2
2
  import { Container, Toolbar, Typography, AppBar } from "@material-ui/core";
3
- import { defaultMdSettings } from "defaults";
4
3
  import { useAppSelector } from "Store/Store";
4
+ import {MDSettings} from "../types";
5
5
  interface Props {
6
6
  settings: any;
7
7
  }
8
8
 
9
9
  function HeaderMdComponent(): JSX.Element {
10
- const { settings } = useAppSelector((state: any) => state);
10
+ const { settings } = useAppSelector((state) => state);
11
11
  const { themePage } = settings;
12
- const mdSettings: any = themePage.materialDesign.active
13
- ? themePage.materialDesign.materialDesign
14
- : defaultMdSettings;
12
+ const mdSettings = themePage.materialDesign as MDSettings;
13
+
15
14
  return (
16
15
  <AppBar
17
16
  position={"relative"}
package/src/index.tsx CHANGED
@@ -20,9 +20,10 @@ document.title = window.location.host;
20
20
 
21
21
  let md: MDSettings = {
22
22
  ...defaultMdSettings,
23
- ...settings.materialDesign,
23
+ ...settings.themePage.materialDesign,
24
24
  };
25
25
 
26
+
26
27
  let theme = createTheme({
27
28
  typography: {
28
29
  fontFamily: md.customFontFamily,
@@ -1,230 +1,86 @@
1
1
  import "App.css";
2
- import React, { useCallback, useEffect, useState } from "react";
2
+ import React, { useEffect, useState } from "react";
3
3
  import Result from "components/Result";
4
4
  import ExampleImages from "components/ExampleImages";
5
5
  import CategoryFilter from "components/CategoryFilter";
6
6
  import PredictedCategories from "components/PredictedCategories";
7
7
  import Codes from "components/Codes";
8
- import {
9
- Code,
10
- CategoryPrediction,
11
- RectCoords,
12
- Region,
13
- cadExtensions,
14
- isCadFile,
15
- isImageFile,
16
- ImageSearchOptions,
17
- } from "@nyris/nyris-api";
18
8
  import { useDropzone } from "react-dropzone";
19
9
  import classNames from "classnames";
20
10
  import { Animate, NodeGroup } from "react-move";
21
- import { AppSettings, MDSettings, CanvasWithId } from "types";
22
11
  import {
23
12
  makeFileHandler,
24
- Capture,
13
+ Capture, Preview,
25
14
  } from "@nyris/nyris-react-components";
26
15
  import { Snackbar } from "@material-ui/core";
27
16
  import MuiAlert, { AlertProps } from "@material-ui/lab/Alert";
28
17
 
29
- import { useAppDispatch, useAppSelector } from "Store/Store";
30
- import {
31
- loadCadFileLoad,
32
- loadFile,
33
- loadFileSelectRegion,
34
- loadingActionRegions,
35
- loadingActionResults,
36
- searchFileImageNonRegion,
37
- } from "Store/Search";
38
- import {
39
- NyrisAppPart,
40
- NyrisFeedbackState,
41
- showCamera,
42
- showFeedback,
43
- showResults,
44
- showStart,
45
- } from "Store/Nyris";
46
- import { serviceImage, serviceImageNonRegion } from "services/image";
47
- import { findByImage } from "services/findByImage";
48
- import { debounce, isEmpty } from "lodash";
49
- import { feedbackClickEpic } from "services/Feedback";
50
- import Preview from "components/preview/preview";
51
- export interface AppHandlers {
52
- onExampleImageClick: (url: string) => void;
53
- onImageClick: (position: number, url: string) => void;
54
- onLinkClick: (position: number, url: string) => void;
55
- onFileDropped: (file: File) => void;
56
- onCaptureComplete: (image: HTMLCanvasElement) => void;
57
- onCaptureCanceled: () => void;
58
- onSelectFile: (f: File) => void;
59
- onCameraClick: () => void;
60
- onShowStart: () => void;
61
- onSelectionChange: (r: RectCoords) => void;
62
- onPositiveFeedback: () => void;
63
- onNegativeFeedback: () => void;
64
- onCloseFeedback: () => void;
65
- }
66
-
67
- export interface AppProps {
68
- search: {
69
- results: any[];
70
- requestId?: string;
71
- duration?: number;
72
- categoryPredictions: CategoryPrediction[];
73
- codes: Code[];
74
- filterOptions: string[];
75
- errorMessage?: string;
76
- regions: Region[];
77
- previewSelection: RectCoords;
78
- toastErrorMessage?: string;
79
- };
80
- previewImage?: CanvasWithId;
81
- settings: AppSettings;
82
- loading: boolean;
83
- showPart: NyrisAppPart;
84
- feedbackState: NyrisFeedbackState;
85
- handlers: AppHandlers;
86
- mdSettings: MDSettings;
87
- }
18
+ import {AppProps} from "./propsType";
88
19
 
89
20
  function Alert(props: AlertProps) {
90
21
  return <MuiAlert elevation={6} variant="filled" {...props} />;
91
22
  }
92
23
 
93
- const LandingPageApp = () => {
94
- const dispatch = useAppDispatch();
95
- const searchState = useAppSelector((state) => state);
96
- const [toastOpen, setToastOpen] = useState(false);
97
- const [rectCoords, setRectCoords] = useState<any>(undefined);
98
- const { settings, search, nyris } = searchState;
24
+ const LandingPageApp = (props: AppProps) => {
25
+ const {
26
+ handlers,
27
+ showPart,
28
+ acceptTypes,
29
+ settings,
30
+ search,
31
+ loading,
32
+ previewImage
33
+ } = props;
34
+
99
35
  const {
100
- errorMessage,
101
36
  results,
102
37
  requestId,
103
- fetchingRegions,
104
- fetchingResults,
105
- requestImage,
106
- regions,
107
- selectedRegion,
38
+ duration,
108
39
  categoryPredictions,
109
40
  codes,
110
41
  filterOptions,
111
- duration,
42
+ errorMessage,
43
+ regions,
44
+ previewSelection
112
45
  } = search;
113
- const { showPart } = nyris;
46
+
47
+ const {
48
+ onExampleImageClick,
49
+ onImageClick,
50
+ onLinkClick,
51
+ onFileDropped,
52
+ onCaptureComplete,
53
+ onCaptureCanceled,
54
+ onSelectFile,
55
+ onCameraClick,
56
+ onShowStart,
57
+ onSelectionChange,
58
+ } = handlers;
114
59
 
115
60
  const { getRootProps, getInputProps, isDragActive } = useDropzone({
116
61
  onDrop: (fs: File[]) => {
117
- // console.log("fsssssssss", fs);
118
- serviceImage(fs[0], searchState).then((res) => {
119
- dispatch(loadFile(res));
120
- return dispatch(showFeedback(""));
121
- });
122
- // return dispatch(loadFile(fs[0]));
62
+ onFileDropped(fs[0]);
123
63
  },
124
64
  });
125
- // const minPreviewHeight = 400;
126
- // const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
127
- // const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
128
65
 
129
- useEffect(() => {
130
- if (isEmpty(rectCoords)) {
131
- return;
132
- }
133
- onSearchOffersForImage(rectCoords);
134
- // eslint-disable-next-line react-hooks/exhaustive-deps
135
- }, [rectCoords]);
136
-
137
- const acceptTypes = ["image/*"]
138
- .concat(settings.cadSearch ? cadExtensions : [])
139
- .join(",");
140
66
 
67
+ const [toastOpen, setToastOpen] = useState(false);
141
68
  useEffect(() => {
142
69
  if (errorMessage !== "") {
143
70
  setToastOpen(true);
144
71
  }
145
72
  }, [errorMessage]);
146
73
 
147
- function scrollTop() {
148
- // TODO might require polyfill for ios and edge
149
- window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
150
- }
151
-
152
- const onShowStart = () => {
153
- dispatch(showStart(""));
154
- scrollTop();
155
- };
156
-
157
- const onLinkClick = (_position: number, url: string) => {
158
- feedbackClickEpic(searchState, _position);
159
- if (url) {
160
- window.open(url);
161
- }
162
- };
163
- // TODO: search image file home page
164
- const isCheckImageFile = (file: any) => {
165
- dispatch(showResults(""));
166
- dispatch(loadingActionResults(""));
167
- dispatch(showFeedback(""));
168
- if (isImageFile(file) || typeof file === "string") {
169
- return serviceImage(file, searchState).then((res) => {
170
- return dispatch(loadFile(res));
171
- });
172
- }
173
- if (isCadFile(file)) {
174
- return dispatch(loadCadFileLoad(file));
175
- }
176
- };
177
- //
178
-
179
- const getUrlToCanvasFile = (url: string, position?: number) => {
180
- dispatch(showResults(""));
181
- dispatch(loadingActionResults(""));
182
- if (position) {
183
- feedbackClickEpic(searchState, position);
184
- }
185
-
186
- if (settings.regions) {
187
- serviceImage(url, searchState).then((res) => {
188
- dispatch(loadFile(res));
189
- return dispatch(showFeedback(""));
190
- });
191
- } else {
192
- serviceImageNonRegion(url, searchState, rectCoords).then((res) => {
193
- dispatch(searchFileImageNonRegion(res));
194
- });
195
- }
196
- };
197
-
198
- const handlerRectCoords = debounce((value) => {
199
- return setRectCoords(value);
200
- }, 1200);
201
-
202
- const debounceRectCoords = useCallback(
203
- (value) => handlerRectCoords(value),
204
- // eslint-disable-next-line react-hooks/exhaustive-deps
205
- []
206
- );
207
-
208
- const onSearchOffersForImage = (r: RectCoords) => {
209
- const { canvas }: any = requestImage;
210
- let options: ImageSearchOptions = {
211
- cropRect: r,
212
- };
213
- dispatch(loadingActionRegions(""));
214
- return findByImage(canvas, options, settings).then((res) => {
215
- dispatch(loadFileSelectRegion(res));
216
- return dispatch(showFeedback(""));
217
- });
218
- };
74
+ const minPreviewHeight = 400;
75
+ const halfOfTheScreenHeight = Math.floor(window.innerHeight * 0.45);
76
+ const maxPreviewHeight = Math.max(minPreviewHeight, halfOfTheScreenHeight);
219
77
 
220
78
  return (
221
- <div>
222
- {showPart === "camera" && (
79
+ <div>
80
+ {showPart === "camera" && (
223
81
  <Capture
224
- onCaptureComplete={(image: HTMLCanvasElement) => {
225
- return isCheckImageFile(image);
226
- }}
227
- onCaptureCanceled={() => dispatch(showStart)}
82
+ onCaptureComplete={ onCaptureComplete }
83
+ onCaptureCanceled={ onCaptureCanceled }
228
84
  useAppText="Use default camera app"
229
85
  />
230
86
  )}
@@ -253,7 +109,7 @@ const LandingPageApp = () => {
253
109
  className="inputfile"
254
110
  accept="image/*"
255
111
  capture="environment"
256
- onClick={() => dispatch(showCamera)}
112
+ onClick={() => onCameraClick()}
257
113
  />
258
114
  <input
259
115
  type="file"
@@ -270,9 +126,7 @@ const LandingPageApp = () => {
270
126
  id="select_file"
271
127
  className="inputfile"
272
128
  accept={acceptTypes}
273
- onChange={makeFileHandler((e) => {
274
- return isCheckImageFile(e);
275
- })}
129
+ onChange={makeFileHandler(onSelectFile)}
276
130
  />
277
131
  <div className="onDesktop">
278
132
  Drop an image
@@ -303,9 +157,7 @@ const LandingPageApp = () => {
303
157
  </section>
304
158
  <ExampleImages
305
159
  images={settings.exampleImages}
306
- onExampleImageClicked={(url: string) => {
307
- return getUrlToCanvasFile(url);
308
- }}
160
+ onExampleImageClicked={onExampleImageClick}
309
161
  />
310
162
  </div>
311
163
  </div>
@@ -348,7 +200,7 @@ const LandingPageApp = () => {
348
200
  </div>
349
201
  )}
350
202
  <Animate
351
- show={fetchingRegions || fetchingResults}
203
+ show={loading}
352
204
  start={{ opacity: 0.0 }}
353
205
  enter={{ opacity: [1.0], timing: { duration: 300 } }}
354
206
  leave={{ opacity: [0.0], timing: { duration: 300 } }}
@@ -359,40 +211,17 @@ const LandingPageApp = () => {
359
211
  </div>
360
212
  )}
361
213
  </Animate>
362
- {/* // TODO:Box Preview image. */}
363
- {settings.preview && requestImage && (
214
+ {settings.preview && previewImage && (
364
215
  <div className="preview">
365
- {/* <Preview
366
- key={requestImage?.id}
216
+ <Preview
217
+ key={previewImage?.id}
218
+ onSelectionChange={ onSelectionChange }
219
+ image={previewImage?.canvas}
220
+ selection={previewSelection}
221
+ regions={regions}
367
222
  maxWidth={document.body.clientWidth}
368
223
  maxHeight={maxPreviewHeight}
369
224
  dotColor="#4C8F9F"
370
- onSelectionChange={(r: RectCoords) => {
371
- dispatch(selectionChanged(r));
372
- return debounceRectCoords(r);
373
- }}
374
- regions={regions}
375
- selection={selectedRegion}
376
- image={requestImage.canvas}
377
- /> */}
378
- <Preview
379
- key={requestImage?.id}
380
- onSelectionChange={(r: RectCoords) => {
381
- debounceRectCoords(r);
382
- return;
383
- }}
384
- image={requestImage?.canvas}
385
- initialRegion={
386
- !selectedRegion
387
- ? regions[0]
388
- ? regions[0]
389
- : { x1: 0, x2: 1, y1: 0, y2: 1 }
390
- : selectedRegion
391
- }
392
- regions={regions}
393
- maxWidth={400}
394
- maxHeight={500}
395
- dotColor="#FBD914"
396
225
  />
397
226
  </div>
398
227
  )}
@@ -421,9 +250,7 @@ const LandingPageApp = () => {
421
250
  key={key}
422
251
  noImageUrl={settings.noImageUrl}
423
252
  template={settings.resultTemplate}
424
- onImageClick={(_pos, url) => {
425
- return getUrlToCanvasFile(url, _pos);
426
- }}
253
+ onImageClick={onImageClick}
427
254
  onLinkClick={onLinkClick}
428
255
  result={data}
429
256
  style={{
@@ -438,8 +265,7 @@ const LandingPageApp = () => {
438
265
 
439
266
  {(results.length === 0 &&
440
267
  showPart === "results" &&
441
- fetchingRegions) ||
442
- (fetchingResults && (
268
+ !loading && (
443
269
  <div className="noResults">
444
270
  We did not find anything{" "}
445
271
  <span role="img" aria-label="sad face">