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
|
||||
}
|
||||
|
||||
func (e *EMDB) UpdateReview(review moviestore.Review) (moviestore.Review, error) {
|
||||
func (e *EMDB) UpdateReview(review moviestore.Review) error {
|
||||
body, err := json.Marshal(review)
|
||||
if err != nil {
|
||||
return moviestore.Review{}, err
|
||||
return err
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/review/%s", e.baseURL, review.ID)
|
||||
req, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return moviestore.Review{}, err
|
||||
return err
|
||||
}
|
||||
req.Header.Add("Authorization", e.apiKey)
|
||||
|
||||
resp, err := e.c.Do(req)
|
||||
if err != nil {
|
||||
return moviestore.Review{}, err
|
||||
return err
|
||||
}
|
||||
|
||||
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)
|
||||
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
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -108,12 +108,13 @@ func (m *tabReview) View() string {
|
|||
|
||||
colReview := lipgloss.NewStyle().
|
||||
Width(colReviewWidth - 2).
|
||||
Height(m.height - 2).
|
||||
Height(m.height).
|
||||
Padding(1).
|
||||
MaxHeight(m.height).
|
||||
Render(m.ViewReview())
|
||||
colRate := lipgloss.NewStyle().
|
||||
Width(colRateWidth - 2).
|
||||
Height(m.height - 2).
|
||||
Height(m.height).
|
||||
Padding(1).
|
||||
Render(m.ViewForm())
|
||||
|
||||
|
|
Loading…
Reference in New Issue