@@ -83,8 +83,8 @@ func (h *Handler) CreateNodeHandler(w http.ResponseWriter, r *http.Request) {
8383 response .WriteResponse (w , http .StatusAccepted , fmt .Sprintf ("%d" , noteID ))
8484}
8585
86- func (h * Handler ) ImportNotesHandler (w http.ResponseWriter , r * http.Request ) {
87- h .Logger .Debug ("ImportNotesHandler called" )
86+ func (db * Handler ) ImportNotesHandler (w http.ResponseWriter , r * http.Request ) {
87+ db .Logger .Debug ("ImportNotesHandler called" )
8888
8989 httperr := validator .ImportNotesValidator (r )
9090 if httperr != nil {
@@ -97,8 +97,18 @@ func (h *Handler) ImportNotesHandler(w http.ResponseWriter, r *http.Request) {
9797 http .Error (w , "unauthorized" , http .StatusUnauthorized )
9898 return
9999 }
100- fmt .Println (clerkID ,"yay" )
101- //response.WriteResponse(w, http.StatusAccepted, fmt.Sprintf("%d", noteID))
100+ noteID , err := db .Service .CreateNote (r .Context (), clerkID )
101+ if err != nil {
102+ http .Error (w , err .Error (), http .StatusInternalServerError )
103+ return
104+ }
105+
106+ note , err := request .UpdateNoteparser (r )
107+ check (err )
108+
109+ db .Service .UpdateNodeById (r .Context (), note , noteID )
110+
111+ response .WriteResponse (w , http .StatusAccepted , fmt .Sprintf ("%d" , noteID ))
102112}
103113
104114func (db * Handler ) UpdateNoteHandler (w http.ResponseWriter , r * http.Request ) {
@@ -114,6 +124,7 @@ func (db *Handler) UpdateNoteHandler(w http.ResponseWriter, r *http.Request) {
114124 check (err )
115125
116126 db .Service .UpdateNodeById (r .Context (), note , id )
127+
117128}
118129
119130func (db * Handler ) DelNoteHandler (w http.ResponseWriter , r * http.Request ) {
0 commit comments