open Rsc;
open Lwt.Syntax;
module NoteView = {
[@react.component]
let make = (~note: Note.t) => {
{React.string(note.title)}
{"Last updated on " ++ Date.format_date(note.updated_at)}
;
};
};
[@react.async.component]
let make = (~selectedId: option(int), ~isEditing: bool) => {
switch (selectedId) {
| None when isEditing =>
Lwt.return(
,
)
| None =>
Lwt.return(
"🥺"
"Click a note on the left to view something!"
,
)
| Some(id) =>
let+ note: result(Note.t, string) = DB.fetch_note(id);
switch (note) {
| Ok(note) when !isEditing =>
| Ok(note) =>
| Error(error) =>
"❌"
"There's an error while loading a single note"
error
};
};
};