Skip to content

Commit

Permalink
Fixed recognize note contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
pkirilin committed May 31, 2024
1 parent 0b42ca3 commit 19f8553
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/frontend/src/entities/note/api/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ export interface RecognizeNoteRequest {
files: FileItem[];
}

export interface RecognizeProductItem {
name: string;
caloriesCost: number;
}

export interface RecognizeNoteItem {
calories: number;
productName: string;
productQuantity: number;
productCaloriesCost: number;
product: RecognizeProductItem;
quantity: number;
}

export interface RecognizeNoteResponse {
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/pages/pages/ui/AddNoteByPhoto.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export const Component: FC = () => {
setProduct({
freeSolo: true,
editing: true,
name: note.productName,
caloriesCost: note.productCaloriesCost,
defaultQuantity: note.productQuantity,
name: note.product.name,
caloriesCost: note.product.caloriesCost,
defaultQuantity: note.quantity,
category,
});
}, [
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tests/mockApi/files/files.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DelayedHttpResponse } from '../DelayedHttpResponse';
const UPLOAD_FILE_FAKE_RESPONSE: UploadFilesResponse = {
files: [
{
url: 'https://storage.yandexcloud.net/food-diary-images/oranges.png',
url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Oranges_-_whole-halved-segment.jpg/2560px-Oranges_-_whole-halved-segment.jpg',
},
],
};
Expand Down
9 changes: 5 additions & 4 deletions src/frontend/tests/mockApi/notes/notes.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ export const handlers: HttpHandler[] = [
const { files } = await request.json();
return await DelayedHttpResponse.json<RecognizeNoteResponse>({
notes: files.map((file, index) => ({
calories: 100,
productName: `Product from file ${index + 1}`,
productQuantity: 120,
productCaloriesCost: 150,
product: {
name: `Product from file ${index + 1}`,
caloriesCost: 150,
},
quantity: 120,
})),
});
},
Expand Down

0 comments on commit 19f8553

Please sign in to comment.