dont read updated review
This commit is contained in:
parent
208dedeeb6
commit
ca30027b0c
|
@ -191,38 +191,27 @@ func (e *EMDB) GetNextUnratedReview() (moviestore.Review, error) {
|
||||||
return review, nil
|
return review, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EMDB) UpdateReview(review moviestore.Review) (moviestore.Review, error) {
|
func (e *EMDB) UpdateReview(review moviestore.Review) error {
|
||||||
body, err := json.Marshal(review)
|
body, err := json.Marshal(review)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return moviestore.Review{}, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/review/%s", e.baseURL, review.ID)
|
url := fmt.Sprintf("%s/review/%s", e.baseURL, review.ID)
|
||||||
req, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(body))
|
req, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return moviestore.Review{}, err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Add("Authorization", e.apiKey)
|
req.Header.Add("Authorization", e.apiKey)
|
||||||
|
|
||||||
resp, err := e.c.Do(req)
|
resp, err := e.c.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return moviestore.Review{}, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
||||||
return moviestore.Review{}, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
newBody, err := io.ReadAll(resp.Body)
|
return nil
|
||||||
if err != nil {
|
|
||||||
return moviestore.Review{}, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
var newReview moviestore.Review
|
|
||||||
if err := json.Unmarshal(newBody, &newReview); err != nil {
|
|
||||||
return moviestore.Review{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return newReview, nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,12 +108,13 @@ func (m *tabReview) View() string {
|
||||||
|
|
||||||
colReview := lipgloss.NewStyle().
|
colReview := lipgloss.NewStyle().
|
||||||
Width(colReviewWidth - 2).
|
Width(colReviewWidth - 2).
|
||||||
Height(m.height - 2).
|
Height(m.height).
|
||||||
Padding(1).
|
Padding(1).
|
||||||
|
MaxHeight(m.height).
|
||||||
Render(m.ViewReview())
|
Render(m.ViewReview())
|
||||||
colRate := lipgloss.NewStyle().
|
colRate := lipgloss.NewStyle().
|
||||||
Width(colRateWidth - 2).
|
Width(colRateWidth - 2).
|
||||||
Height(m.height - 2).
|
Height(m.height).
|
||||||
Padding(1).
|
Padding(1).
|
||||||
Render(m.ViewForm())
|
Render(m.ViewForm())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue