Skip to content

Commit

Permalink
142/handle-add-product-admin: toastify when admin added a new product
Browse files Browse the repository at this point in the history
  • Loading branch information
hxfsa committed Dec 12, 2024
1 parent 84e8ce8 commit 76e6587
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
23 changes: 22 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-responsive": "^10.0.0",
"react-router-dom": "^6.24.0"
"react-router-dom": "^6.24.0",
"react-toastify": "^10.0.6"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.2",
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/pages/NewProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import ListProductsTable from "../components/ListProductsTable";
import { NewProductFormValues } from "../interface/types";
import { useState } from "react";
import axios from "axios";
import { toast, ToastContainer } from "react-toastify";
import 'react-toastify/dist/ReactToastify.css';

const { Title } = Typography;

Expand Down Expand Up @@ -79,6 +81,7 @@ const NewProduct = () => {
variables: { data: formJson },
});
form.resetFields();
toast("Produit ajouté avec succès !");
} catch (error) {
console.error("Erreur lors de la création du produit", error);
}
Expand Down Expand Up @@ -164,8 +167,13 @@ const NewProduct = () => {
</Form>
</Card>
</div>

<ListProductsTable />
<ToastContainer
position="top-right"
autoClose={5000}
theme="light"

/>
</>
);
};
Expand Down

0 comments on commit 76e6587

Please sign in to comment.