recipe author and stars and a bit of cleanup
This commit is contained in:
parent
c47dac9986
commit
6f43d17ddd
21 changed files with 361 additions and 207 deletions
|
@ -1,5 +1,9 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { type Step } from "../types/Recipe";
|
||||
|
||||
interface Step {
|
||||
step_number: number;
|
||||
instruction: string;
|
||||
}
|
||||
|
||||
interface AddBulkStepsProps {
|
||||
steps: Step[];
|
||||
|
@ -11,7 +15,7 @@ const AddBulkSteps: React.FC<AddBulkStepsProps> = ({ steps, onChange }) => {
|
|||
|
||||
useEffect(() => {
|
||||
const textRepresentation = steps.map(step =>
|
||||
`${step.instructions}`
|
||||
`${step.instruction}`
|
||||
).join('\n');
|
||||
setTextValue(textRepresentation);
|
||||
}, [steps]);
|
||||
|
@ -24,8 +28,8 @@ const AddBulkSteps: React.FC<AddBulkStepsProps> = ({ steps, onChange }) => {
|
|||
const parseAndUpdate = (value: string) => {
|
||||
const lines = value.split('\n').filter(line => line.trim() !== '');
|
||||
|
||||
const parsedSteps = lines.map((line, idx) => {
|
||||
return { idx: idx + 1, instructions: line }
|
||||
const parsedSteps: Step[] = lines.map((line, idx) => {
|
||||
return { step_number: idx + 1, instruction: line }
|
||||
})
|
||||
|
||||
if (onChange) onChange(parsedSteps);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue