Use `name` as `plant.name` instead of `openfarm_slug`
parent
be854a047b
commit
0518f7e40e
|
@ -65,7 +65,8 @@ export class RawAddPlant extends React.Component<AddPlantProps, {}> {
|
|||
<PlantGrid
|
||||
xy_swap={this.props.xy_swap}
|
||||
dispatch={this.props.dispatch}
|
||||
openfarm_slug={result.crop.slug} />
|
||||
openfarm_slug={result.crop.slug}
|
||||
cropName={result.crop.name} />
|
||||
</AddPlantDescription>;
|
||||
return <DesignerPanel panelName={panelName} panel={Panel.Plants}>
|
||||
<DesignerPanelHeader
|
||||
|
|
|
@ -12,6 +12,7 @@ export interface PlantGridState {
|
|||
export interface PlantGridProps {
|
||||
xy_swap: boolean;
|
||||
openfarm_slug: string;
|
||||
cropName: string;
|
||||
dispatch: Function;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ export function vectorGrid(params: PlantGridData): [number, number][] {
|
|||
return results;
|
||||
}
|
||||
|
||||
const createPlant = (openfarm_slug: string, gridId: string) =>
|
||||
const createPlant = (openfarm_slug: string, name: string, gridId: string) =>
|
||||
(vec: [number, number]): PlantPointer => {
|
||||
const [x, y] = vec;
|
||||
return {
|
||||
name: openfarm_slug,
|
||||
name: name,
|
||||
radius: 25,
|
||||
z: 0,
|
||||
x,
|
||||
|
@ -37,11 +37,11 @@ const createPlant = (openfarm_slug: string, gridId: string) =>
|
|||
interface PlantGridInitOption {
|
||||
grid: PlantGridData;
|
||||
openfarm_slug: string;
|
||||
cropName: string;
|
||||
gridId: string;
|
||||
}
|
||||
|
||||
export const initPlantGrid =
|
||||
({ grid, openfarm_slug, gridId }: PlantGridInitOption): PlantPointer[] => {
|
||||
const mapper = createPlant(openfarm_slug, gridId);
|
||||
return vectorGrid(grid).map(mapper);
|
||||
};
|
||||
export const initPlantGrid = (p: PlantGridInitOption): PlantPointer[] => {
|
||||
const mapper = createPlant(p.openfarm_slug, p.cropName, p.gridId);
|
||||
return vectorGrid(p.grid).map(mapper);
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ export class PlantGrid extends React.Component<PlantGridProps, PlantGridState> {
|
|||
const plants = initPlantGrid({
|
||||
grid: this.state.grid,
|
||||
openfarm_slug: this.props.openfarm_slug,
|
||||
cropName: this.props.cropName,
|
||||
gridId: this.state.gridId
|
||||
});
|
||||
plants.map(p => this.props.dispatch(init("Point", p)));
|
||||
|
|
Loading…
Reference in New Issue