Skip to content

Commit

Permalink
Added CaptureSelectionPage & DamageDisclosure in demo-app
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai committed Jan 10, 2025
1 parent 250b836 commit d68f662
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 1 deletion.
20 changes: 20 additions & 0 deletions apps/demo-app/src/components/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
VehicleTypeSelectionPage,
} from '../pages';
import { App } from './App';
import { CaptureSelectionPage } from '../pages/CaptureSelectionPage';
import { DamageDisclosurePage } from '../pages/DamageDisclosurePage';

export function AppRouter() {
return (
Expand All @@ -34,6 +36,15 @@ export function AppRouter() {
}
index
/>
<Route
path={Page.CAPTURE_SELECTION}
element={
<AuthGuard redirectTo={Page.LOG_IN}>
<CaptureSelectionPage />
</AuthGuard>
}
index
/>
<Route
path={Page.PHOTO_CAPTURE}
element={
Expand All @@ -43,6 +54,15 @@ export function AppRouter() {
}
index
/>
<Route
path={Page.DAMAGE_DISCLOSURE}
element={
<AuthGuard redirectTo={Page.LOG_IN}>
<DamageDisclosurePage />
</AuthGuard>
}
index
/>
<Route path='*' element={<Navigate to={Page.CREATE_INSPECTION} />} />
</Route>
</Routes>
Expand Down
1 change: 1 addition & 0 deletions apps/demo-app/src/local-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"apiDomain": "api.preview.monk.ai/v1",
"thumbnailDomain": "europe-west1-monk-preview-321715.cloudfunctions.net/image_resize",
"enableSightTutorial": false,
"enableTutorial": "first_time_only",
"startTasksOnComplete": true,
"showCloseButton": false,
"enforceOrientation": "landscape",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CaptureSelection } from '@monkvision/common-ui-web';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Page } from '../pages';

export function CaptureSelectionPage() {
const navigate = useNavigate();
const { i18n } = useTranslation();

return (
<CaptureSelection
lang={i18n.language}
onCapture={() => navigate(Page.PHOTO_CAPTURE)}
onAddDamage={() => navigate(Page.DAMAGE_DISCLOSURE)}
/>
);
}
1 change: 1 addition & 0 deletions apps/demo-app/src/pages/CaptureSelectionPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './CaptureSelectionPage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.container {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useTranslation } from 'react-i18next';
import { useMonkAppState } from '@monkvision/common';
import { DamageDisclosure } from '@monkvision/inspection-capture-web';
import { useNavigate } from 'react-router-dom';
import styles from './DamageDisclosurePage.module.css';
import { Page } from '../pages';

export function DamageDisclosurePage() {
const navigate = useNavigate();
const { i18n } = useTranslation();
const { config, authToken, inspectionId } = useMonkAppState({
requireInspection: true,
});

return (
<div className={styles['container']}>
<DamageDisclosure
{...config}
apiConfig={{
authToken,
apiDomain: config.apiDomain,
thumbnailDomain: config.thumbnailDomain,
}}
inspectionId={inspectionId}
onComplete={() => navigate(Page.PHOTO_CAPTURE)}
lang={i18n.language}
/>
</div>
);
}
1 change: 1 addition & 0 deletions apps/demo-app/src/pages/DamageDisclosurePage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DamageDisclosurePage';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function VehicleTypeSelectionPage() {
const { i18n } = useTranslation();

if (vehicleType || !config.allowVehicleTypeSelection) {
return <Navigate to={Page.PHOTO_CAPTURE} replace />;
return <Navigate to={Page.CAPTURE_SELECTION} replace />;
}

return (
Expand Down
2 changes: 2 additions & 0 deletions apps/demo-app/src/pages/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ export enum Page {
LOG_IN = '/log-in',
CREATE_INSPECTION = '/create-inspection',
PHOTO_CAPTURE = '/photo-capture',
DAMAGE_DISCLOSURE = '/damage-disclosure',
VEHICLE_TYPE_SELECTION = '/vehicle-type-selection',
CAPTURE_SELECTION = '/capture-selection',
}

0 comments on commit d68f662

Please sign in to comment.