Skip to content

Commit

Permalink
fix: Wrong unit conversion after conalco import (#336)
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Groß <mail@gross-johannes.de>
  • Loading branch information
jo-gross authored Jul 18, 2024
1 parent 3c7913b commit d9a44f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/ingredients/IngredientForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ export function IngredientForm(props: IngredientFormProps) {
if (data.volume != 0) {
setFieldValue('volume', data.volume);
}
setFieldValue('selectedUnit', allUnits.find((unit) => unit.name == 'CL')?.id ?? '');
});
} else {
alertService.warn('Es konnten keine Daten über die URL geladen werden.');
Expand Down
2 changes: 1 addition & 1 deletion pages/api/scraper/ingredient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async function handle(req: NextApiRequest, res: NextApiResponse)
const image = imageResponse != undefined ? 'data:image/jpg;base64,' + Buffer.from(await imageResponse.arrayBuffer()).toString('base64') : undefined;
const name = soup.find('h1', 'product--title')?.text?.replace('\n', '')?.trim() ?? '';
const price = soup.find('meta', { itemprop: 'price' })?.attrs?.content ?? 0;
const volume = (soup.find('div', ['product--price', 'price--unit'])?.contents?.[1]?.['_text']?.split(' ')?.[0] ?? 0) * 1000;
const volume = (soup.find('div', ['product--price', 'price--unit'])?.contents?.[1]?.['_text']?.split(' ')?.[0] ?? 0) * 100;

const result: ResponseBody = {
name: name,
Expand Down

0 comments on commit d9a44f2

Please sign in to comment.