Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pages/Review.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useLocation, useNavigate } from "react-router-dom";
import { useState, useEffect } from "react";
import { parseItems, type Item } from "../utils/parseReceipt";
import { parseItems } from "../utils/parseReceipt";
import type { Item } from "../types";

const Review = () => {
const ocrText = useLocation().state?.ocrText || "";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Split.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import { useLocation } from "react-router-dom";
import type { Item } from "../utils/parseReceipt";
import type { Item } from "../types";
import useIsMobile from "../hooks/useIsMobile";
import { usePeople, PeopleChips, AddPersonModal } from "../components/PeopleManager";

Expand Down
23 changes: 23 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Core types that the whole app will use
export type Item = {
id: string;
name: string;
price: number;
quantity: number;
assignedTo: string[];
splitType: 'equal' | 'custom';
};

export type Person = {
id: string;
name: string;
color: string;
total: number;
items: string[];
};

export type Assignment = {
itemId: string;
personIds: string[];
splitType: 'equal' | 'custom';
};
11 changes: 9 additions & 2 deletions src/utils/parseReceipt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Item = { name: string; price: number; quantity: number };
import type { Item } from '../types';

const BANNED = ["total", "subtotal", "admin", "tax", "change", "instagram"];

Expand Down Expand Up @@ -39,7 +39,14 @@ export function parseItems(ocrText: string): Item[] {
return null;
}

return { name, price, quantity } as Item;
return {
id: crypto.randomUUID(),
name,
price,
quantity,
assignedTo: [],
splitType: 'equal' as const
} as Item;
})
.filter(Boolean) as Item[];

Expand Down