✔️ Ready for UI implementation

pull/802/head
Rick Carlino 2018-04-20 11:26:18 -05:00
parent d952c61fcb
commit 1b316cbde6
6 changed files with 30 additions and 5 deletions

View File

@ -133,8 +133,11 @@ export class API {
get pinBindingPath() { return `${this.baseUrl}/api/pin_bindings/`; }
/** /api/saved_gardens/:id */
get savedGardensPath() { return `${this.baseUrl}/api/saved_gardens`; }
/** /api/saved_gardens/:id */
/** /api/saved_gardens/snapshot */
get snapshotPath() { return this.savedGardensPath + "/snapshot"; }
/** /api/saved_gardens/:id/apply */
applyGardenPath =
(gardenId: number) => `${this.savedGardensPath}/${gardenId}/apply`;
/** /api/plant_templates/:id */
get plantTemplatePath() { return `${this.baseUrl}/api/plant_templates`; }
/** /api/farmware_installations/:id */

View File

@ -6,7 +6,7 @@ import { history } from "../../history";
import { atMaxZoom, atMinZoom } from "./zoom";
import { ImageFilterMenu } from "./image_filter_menu";
import { showBugResetButton, resetBugs } from "./easter_eggs/bugs";
// import { snapShotGarden } from "../../saved_gardens/snapshot";
// import { snapshotGarden } from "../../saved_gardens/snapshot";
export function GardenMapLegend(props: GardenMapLegendProps) {

View File

@ -40,6 +40,7 @@ export interface GardenMapLegendProps {
tzOffset: number;
getConfigValue: GetWebAppConfigValue;
imageAgeInfo: { newestDate: string, toOldest: number };
gardenId?: number;
}
export type MapTransformProps = {

View File

@ -0,0 +1,15 @@
jest.mock("axios", () => {
return { default: { patch: jest.fn(() => Promise.resolve()) } };
});
import { applyGarden } from "../apply_garden";
import { API } from "../../api";
import axios from "axios";
describe("applyGarden", () => {
it("calls the API and lets auto-sync do the rest", () => {
API.setBaseUrl("example.io");
applyGarden(4);
expect(axios.patch).toHaveBeenCalledWith(API.current.applyGardenPath(4));
});
});

View File

@ -0,0 +1,6 @@
import axios from "axios";
import { API } from "../api";
export const applyGarden = (gardenId: number) => axios
.patch<void>(API.current.applyGardenPath(gardenId))
.then(() => { });

View File

@ -1,6 +1,6 @@
import axios from "axios";
import { API } from "../api";
export function snapshotGarden() {
return axios.post<void>(API.current.snapshotPath).then(() => { });
}
export const snapshotGarden = () => axios
.post<void>(API.current.snapshotPath)
.then(() => { });