Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 89x 89x 89x 88x 88x 88x 88x | import { StringValue } from "google-protobuf/google/protobuf/wrappers_pb";
import {
Coordinate,
CreateGuideReq,
CreatePlaceReq,
GetPageReq,
UpdatePageReq,
} from "proto/pages_pb";
import client from "./client";
export async function createPlace(
title: string,
content: string,
address: string,
lat: number,
lng: number,
photoKey?: string,
) {
const req = new CreatePlaceReq();
req.setTitle(title);
req.setContent(content);
req.setAddress(address);
const coordinate = new Coordinate();
coordinate.setLat(lat);
coordinate.setLng(lng);
req.setLocation(coordinate);
Iif (photoKey) req.setPhotoKey(photoKey);
const response = await client.pages.createPlace(req);
return response.toObject();
}
export async function createGuide(
title: string,
content: string,
parentCommunityId: number,
address: string,
lat?: number,
lng?: number,
) {
const req = new CreateGuideReq();
req.setTitle(title);
req.setContent(content);
req.setAddress(address);
Iif (lat && lng) {
const coordinate = new Coordinate();
coordinate.setLat(lat);
coordinate.setLng(lng);
req.setLocation(coordinate);
}
req.setParentCommunityId(parentCommunityId);
const response = await client.pages.createGuide(req);
return response.toObject();
}
export async function getPage(pageId: number) {
const req = new GetPageReq();
req.setPageId(pageId);
const response = await client.pages.getPage(req);
return response.toObject();
}
interface UpdatePageInput {
content?: string;
pageId: number;
title?: string;
photoKey?: string;
}
export async function updatePage({
content,
pageId,
title,
photoKey,
}: UpdatePageInput) {
const req = new UpdatePageReq();
Iif (photoKey) {
req.setPhotoKey(new StringValue().setValue(photoKey));
}
req.setPageId(pageId);
Iif (content) {
req.setContent(new StringValue().setValue(content));
}
Iif (title) {
req.setTitle(new StringValue().setValue(title));
}
const response = await client.pages.updatePage(req);
return response.toObject();
}
|