added keys and types to the note api for adding and loading notes and chats
This commit is contained in:
parent
a2ac900f3e
commit
63bba4f74e
11 changed files with 49 additions and 31 deletions
|
|
@ -6,7 +6,7 @@ import { createContext, PropsWithChildren, useContext } from "react";
|
|||
import { pondURL } from "./pond";
|
||||
|
||||
export interface INoteAPIContext {
|
||||
addNote: (note: pond.NoteSettings, attachments?: string[]) => Promise<any>;
|
||||
addNote: (note: pond.NoteSettings, attachments?: string[], keys?: string[], types?: string[]) => Promise<any>;
|
||||
getNote: (noteID: string) => Promise<AxiosResponse<pond.Note>>;
|
||||
updateNote: (note: pond.NoteSettings) => Promise<any>;
|
||||
listNotes: (
|
||||
|
|
@ -16,7 +16,8 @@ export interface INoteAPIContext {
|
|||
orderBy?: string,
|
||||
search?: string,
|
||||
asRoot?: boolean,
|
||||
otherTeam?: string
|
||||
// otherTeam?: string,
|
||||
keys?: string[], types?: string[]
|
||||
) => Promise<AxiosResponse<pond.ListNotesResponse>>;
|
||||
listChats: (
|
||||
limit: number,
|
||||
|
|
@ -24,8 +25,9 @@ export interface INoteAPIContext {
|
|||
order?: "asc" | "desc",
|
||||
orderBy?: string,
|
||||
search?: string,
|
||||
asRoot?: boolean,
|
||||
otherTeam?: string
|
||||
// asRoot?: boolean,
|
||||
// otherTeam?: string
|
||||
keys?: string[], types?: string[]
|
||||
) => Promise<AxiosResponse<pond.ListChatsResponse>>;
|
||||
removeNote: (noteID: string) => Promise<AxiosResponse<pond.RemoveBinResponse>>;
|
||||
}
|
||||
|
|
@ -39,8 +41,13 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
|
|||
const { get, del, post, put } = useHTTP();
|
||||
// const [{as}] = useGlobalState()
|
||||
|
||||
const addNote = (note: pond.NoteSettings, attachments?: string[]) => {
|
||||
let url = pondURL("/notes" + (attachments ? "?attachments=" + attachments.toString() : ""))
|
||||
const addNote = (note: pond.NoteSettings, attachments?: string[], keys?: string[], types?: string[]) => {
|
||||
let url = pondURL(
|
||||
"/notes" +
|
||||
// (attachments ? "?attachments=" + attachments.toString() : "") +
|
||||
(keys ? "?keys=" + keys.join(",") : "") +
|
||||
(types ? "&types=" + types.join(",") : "")
|
||||
)
|
||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||
post(url, note).then(resp => {
|
||||
return resolve(resp)
|
||||
|
|
@ -89,6 +96,8 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
|
|||
search?: string,
|
||||
asRoot?: boolean,
|
||||
// otherTeam?: string
|
||||
keys?: string[],
|
||||
types?: string[]
|
||||
) => {
|
||||
// const view = otherTeam ? otherTeam : as
|
||||
let url = pondURL(
|
||||
|
|
@ -100,7 +109,9 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
|
|||
("&order=" + (order ? order : "asc")) +
|
||||
("&by=" + (orderBy ? orderBy : "key")) +
|
||||
(search ? "&search=" + search : "") +
|
||||
(asRoot ? "&asRoot=" + asRoot.toString() : ""),
|
||||
(asRoot ? "&asRoot=" + asRoot.toString() : "") +
|
||||
(keys ? "&keys=" + keys.join(",") : "") +
|
||||
(types ? "&types=" + types.join(",") : "")
|
||||
// (view ? "&as=" + "" : "")
|
||||
)
|
||||
// console.log(url)
|
||||
|
|
@ -122,6 +133,8 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
|
|||
search?: string,
|
||||
// asRoot?: boolean,
|
||||
// otherTeam?: string
|
||||
keys?: string[],
|
||||
types?: string[]
|
||||
) => {
|
||||
// const view = otherTeam ? otherTeam : as
|
||||
let url = pondURL(
|
||||
|
|
@ -132,7 +145,9 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
|
|||
offset +
|
||||
("&order=" + (order ? order : "asc")) +
|
||||
("&by=" + (orderBy ? orderBy : "key")) +
|
||||
(search ? "&search=" + search : ""),
|
||||
(search ? "&search=" + search : "") +
|
||||
(keys ? "&keys=" + keys.join(",") : "") +
|
||||
(types ? "&types=" + types.join(",") : "")
|
||||
// (asRoot ? "&asRoot=" + asRoot.toString() : ""),
|
||||
// (view ? "&as=" + view : "")
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue