diff --git a/package-lock.json b/package-lock.json index dfbde6f..2cd53e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "openweathermap-ts": "^1.2.10", - "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", @@ -11205,7 +11205,7 @@ }, "node_modules/protobuf-ts": { "version": "1.0.0", - "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#40e15b5ed18b10c97125260a2d53a81d1eec398e", + "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#9c0f668d4a56b8216dd71a44c3110a818aaf3541", "dependencies": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index 7f5044c..90ac71b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "openweathermap-ts": "^1.2.10", - "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#master", + "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging", "query-string": "^9.2.1", "react": "^18.3.1", "react-beautiful-dnd": "^13.1.1", diff --git a/src/chat/Chat.tsx b/src/chat/Chat.tsx index 0bfeea5..c9b263b 100644 --- a/src/chat/Chat.tsx +++ b/src/chat/Chat.tsx @@ -21,13 +21,14 @@ const useStyles = makeStyles((_theme: Theme) => { }) interface Props { - objectKey: string; + parent: string; + parentType: string; type?: pond.NoteType; } export default function Chat(props: Props) { const [chats, setChats] = useState([]); - const { objectKey, type } = props; + const { parent, parentType, type } = props; const noteAPI = useNoteAPI(); const [loaded, setLoaded] = useState(false); const [loading, setLoading] = useState(false); @@ -38,7 +39,7 @@ export default function Chat(props: Props) { const loadChats = () => { setLoading(true) // console.log("listing chats?") - noteAPI.listChats(10, chats.length, "desc", "timestamp", objectKey).then(resp => { + noteAPI.listChats(10, chats.length, "desc", "timestamp", parent, [parent], [parentType]).then(resp => { setChats(resp.data.chats ? resp.data.chats.reverse().concat(chats) : []) setTotalMessages(resp.data.total) }).finally(() => { @@ -81,13 +82,13 @@ export default function Chat(props: Props) { setLoaded(false); setLoading(false); setTotalMessages(0); - }, [objectKey]); + }, [parent]); useEffect(() => { if (chats.length === 0 && !loaded) { loadChats(); } - }, [objectKey, chats, loaded]); + }, [parent, chats, loaded]); const loadMore = () => { loadChats(); @@ -111,7 +112,7 @@ export default function Chat(props: Props) { - + ); diff --git a/src/chat/ChatDrawer.tsx b/src/chat/ChatDrawer.tsx index 8394d69..fa4ae4e 100644 --- a/src/chat/ChatDrawer.tsx +++ b/src/chat/ChatDrawer.tsx @@ -143,7 +143,7 @@ export function ChatDrawer(props: Props) { {selectedTeam.name()} Chat - + diff --git a/src/chat/ChatInput.tsx b/src/chat/ChatInput.tsx index a3753b8..db70fde 100644 --- a/src/chat/ChatInput.tsx +++ b/src/chat/ChatInput.tsx @@ -40,8 +40,9 @@ const useStyles = makeStyles((theme: Theme) => ({ })) interface Props { - objectKey: string; + parent: string; newNoteMethod: (note: Note) => void; + parentType: string; // the object type the note is for ie "bin", "team" etc. type?: pond.NoteType; } @@ -52,13 +53,13 @@ interface Props { export default function ChatInput(props: Props) { const [message, setMessage] = useState(""); const classes = useStyles(); - const { objectKey, type } = props; + const { parent, type, parentType } = props; const [{ user }] = useGlobalState(); const noteAPI = useNoteAPI(); const { openSnack } = useSnackbar(); const [shift, setShift] = useState(false); const theme = useTheme(); - const [uploadedFiles, setUploadedFiles] = useState>(new Map()); + // const [uploadedFiles, setUploadedFiles] = useState>(new Map()); const clearEntry = () => { setMessage(""); @@ -93,13 +94,13 @@ export default function ChatInput(props: Props) { } valid ? submit() : openSnack("Invalid Message"); clearEntry(); - setUploadedFiles(new Map()); + // setUploadedFiles(new Map()); }; const submit = () => { if (message !== "" && message !== "\n") { let newNote = Note.create(); - newNote.settings.objectKey = objectKey; + newNote.settings.objectKey = parent; newNote.settings.userId = user.id(); if (type) { newNote.settings.objectType = type; @@ -107,13 +108,14 @@ export default function ChatInput(props: Props) { newNote.settings.timestamp = Date.now(); newNote.settings.content = message; noteAPI - .addNote(newNote.settings, Array.from(uploadedFiles.keys())) + .addNote(newNote.settings, undefined, [parent], [parentType]) .then(resp => { newNote.settings.key = resp.data.note props.newNoteMethod(newNote); openSnack("Message Sent"); }) .catch(_err => { + console.error(_err) openSnack("Message Failed to send"); }); } @@ -162,7 +164,7 @@ export default function ChatInput(props: Props) { - {Array.from(uploadedFiles.values()).toString()} + {/* {Array.from(uploadedFiles.values()).toString()} */} ); } diff --git a/src/harvestPlan/HarvestPlanDisplay.tsx b/src/harvestPlan/HarvestPlanDisplay.tsx index 6917332..5f9721b 100644 --- a/src/harvestPlan/HarvestPlanDisplay.tsx +++ b/src/harvestPlan/HarvestPlanDisplay.tsx @@ -151,7 +151,7 @@ export default function HarvestPlanDisplay(props: Props) { onClose={() => setOpenNote(false)}> Notes - + ); diff --git a/src/maps/mapDrawers/FieldDrawer.tsx b/src/maps/mapDrawers/FieldDrawer.tsx index 724cf5d..ae7a794 100644 --- a/src/maps/mapDrawers/FieldDrawer.tsx +++ b/src/maps/mapDrawers/FieldDrawer.tsx @@ -287,7 +287,7 @@ export default function FieldDrawer(props: Props) { onClose={() => setOpenNote(false)}> Notes - + ); diff --git a/src/pages/Bin.tsx b/src/pages/Bin.tsx index 076dc37..48bba18 100644 --- a/src/pages/Bin.tsx +++ b/src/pages/Bin.tsx @@ -496,7 +496,7 @@ export default function Bin(props: Props) { - + diff --git a/src/pages/Contract.tsx b/src/pages/Contract.tsx index c91f9ea..b14796b 100644 --- a/src/pages/Contract.tsx +++ b/src/pages/Contract.tsx @@ -281,7 +281,7 @@ export default function Contract() { {contract.name()} - Notes - + @@ -316,7 +316,7 @@ export default function Contract() { Notes - + diff --git a/src/pages/Gate.tsx b/src/pages/Gate.tsx index db876e4..c0de27f 100644 --- a/src/pages/Gate.tsx +++ b/src/pages/Gate.tsx @@ -400,7 +400,7 @@ export default function Gate(props: Props) { Notes - + @@ -465,7 +465,7 @@ export default function Gate(props: Props) { {/* tab for notes on mobile and the map drawer */} - + {/* drawer is for displaying notes on desktop */} diff --git a/src/pages/Team.tsx b/src/pages/Team.tsx index 1fa32ba..593b152 100644 --- a/src/pages/Team.tsx +++ b/src/pages/Team.tsx @@ -251,7 +251,7 @@ export default function TeamPage() { - + diff --git a/src/providers/pond/noteAPI.tsx b/src/providers/pond/noteAPI.tsx index 3cd4f91..a53bd52 100644 --- a/src/providers/pond/noteAPI.tsx +++ b/src/providers/pond/noteAPI.tsx @@ -6,7 +6,7 @@ import { createContext, PropsWithChildren, useContext } from "react"; import { pondURL } from "./pond"; export interface INoteAPIContext { - addNote: (note: pond.NoteSettings, attachments?: string[]) => Promise; + addNote: (note: pond.NoteSettings, attachments?: string[], keys?: string[], types?: string[]) => Promise; getNote: (noteID: string) => Promise>; updateNote: (note: pond.NoteSettings) => Promise; listNotes: ( @@ -16,7 +16,8 @@ export interface INoteAPIContext { orderBy?: string, search?: string, asRoot?: boolean, - otherTeam?: string + // otherTeam?: string, + keys?: string[], types?: string[] ) => Promise>; 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>; removeNote: (noteID: string) => Promise>; } @@ -39,8 +41,13 @@ export default function NoteProvider(props: PropsWithChildren) { 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((resolve, reject) => { post(url, note).then(resp => { return resolve(resp) @@ -89,6 +96,8 @@ export default function NoteProvider(props: PropsWithChildren) { 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) { ("&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) { 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) { 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 : "") ) diff --git a/src/tasks/TaskDrawer.tsx b/src/tasks/TaskDrawer.tsx index 46ffd3a..956a36a 100644 --- a/src/tasks/TaskDrawer.tsx +++ b/src/tasks/TaskDrawer.tsx @@ -194,7 +194,7 @@ export default function TaskDrawer(props: Props) { onClose={() => setOpenNote(false)}> Notes - + );