Skip to content

Commit

Permalink
[UPDATE] author alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanner Enrique De La Hoz Barraza committed Jun 20, 2023
1 parent fe52409 commit 50eb1b5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VITE_API_BACKEND = https://book-reserve-api.up.railway.app/api/v1/book-reserve
# VITE_API_BACKEND = https://book-reserve-api.up.railway.app/api/v1/book-reserve

# VITE_API_BACKEND = http://localhost:3000/api/v1/book-reserve
VITE_API_BACKEND = http://localhost:3000/api/v1/book-reserve
16 changes: 14 additions & 2 deletions src/components/Author/CreateAuthor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,20 @@ export default function CreateAuthor() {
navigate('/author');
})
.catch(({ response }) => {
const { data } = response;
Swal.fire({
const { data, status } = response;
console.log(response.status);
console.log(data.message);
if (status === 409) {
if (data.message === 'the author name is registered') {
return Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'El nombre del autor se encuentra registrado en el sistema',
confirmButtonColor: 'Gray',
});
}
}
return Swal.fire({
icon: 'error',
title: response.statusText,
text: data.message[0],
Expand Down
16 changes: 14 additions & 2 deletions src/components/Author/UpdateAuthor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ export default function UpdateAuthor() {
navigate('/author');
})
.catch(({ response }) => {
const { data } = response;
Swal.fire({
const { data, status } = response;
console.log(response.status);
console.log(data.message);
if (status === 409) {
if (data.message === 'the author name is registered') {
return Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'El nombre del autor se encuentra registrado en el sistema',
confirmButtonColor: 'Gray',
});
}
}
return Swal.fire({
icon: 'error',
title: response.statusText,
text: data.message[0],
Expand Down
2 changes: 1 addition & 1 deletion src/components/Book/Book.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function Book() {
</h5>
<p className="card-text">
<small>
Cantidad MAX establecida: {item.book_available_quantity}
Cantidad MAX: {item.book_available_quantity}
<br />
Cantidad disponible:{' '}
{item.book_available_quantity -
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/Home-Book.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function HomeBook() {
</h5>
<p className="card-text">
<small>
Cantidad MAX establecida: {item.book_available_quantity}
Cantidad MAX: {item.book_available_quantity}
<br />
Cantidad disponible:{' '}
{item.book_available_quantity -
Expand Down

0 comments on commit 50eb1b5

Please sign in to comment.