Skip to content

Commit

Permalink
Merge pull request #99 from WildCodeSchool/feat/no-ticket/standardize…
Browse files Browse the repository at this point in the history
…-the-linter

Strandardize linter and fixed all files with new config
  • Loading branch information
AntoniSDev authored Oct 10, 2024
2 parents 32258bd + a11b89e commit 8803d24
Show file tree
Hide file tree
Showing 16 changed files with 1,185 additions and 618 deletions.
20 changes: 11 additions & 9 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
quotes: ["error", "double"],
"@typescript-eslint/quotes": ["error", "double"],
},
}
};
15 changes: 2 additions & 13 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,13 @@ import Profile from "./pages/Profile";
import { Cart } from "./pages/Cart";

const App = () => {

return (
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<HomePage />} />
<Route path="register" element={<Register />} />
<Route
path="admin"
element={
<Admin />
}
/>
<Route
path="profile"
element={
<Profile />
}
/>
<Route path="admin" element={<Admin />} />
<Route path="profile" element={<Profile />} />
<Route path="login" element={<Login />} />
<Route path="/product/:productId" element={<ProductDescription />} />
<Route path="search/:keyword" element={<SearchPage />} />
Expand Down
36 changes: 20 additions & 16 deletions frontend/src/components/CurrentReservation.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { ReservationData} from "../interface/types"

export const CurrentReservation = ({ reservationData }: { reservationData: ReservationData }) => {

import { ReservationData } from "../interface/types";

export const CurrentReservation = ({
reservationData,
}: {
reservationData: ReservationData;
}) => {
return (
<div>
<div>id de la réservation : {reservationData.reservation.id} </div>
<div>date de début : {reservationData.reservation.startDate} </div>
<div>date de fin : {reservationData.reservation.endDate} </div>
<div>articles :
<div>id de la réservation : {reservationData.reservation.id} </div>
<div>date de début : {reservationData.reservation.startDate} </div>
<div>date de fin : {reservationData.reservation.endDate} </div>
<div>
articles :
<div>
{reservationData.reservation.articles && reservationData.reservation.articles.length > 0 ? (
reservationData.reservation.articles.map((article, index) => (
{reservationData.reservation.articles &&
reservationData.reservation.articles.length > 0 ? (
reservationData.reservation.articles.map((article, index) =>
article.product ? (
<div className="flex gap-2" key={index}>
<div>nom: {article.product.name}</div>
Expand All @@ -20,15 +24,15 @@ export const CurrentReservation = ({ reservationData }: { reservationData: Reser
) : (
<div key={index}>Article has no product details.</div>
)
))
)
) : (
<div>No articles found.</div>
)}
</div>
</div>
<div>total: {reservationData.totalPrice}</div>
</div>
<div>total: {reservationData.totalPrice}</div>
</div>
)
}
);
};

export default CurrentReservation
export default CurrentReservation;
40 changes: 23 additions & 17 deletions frontend/src/components/DeleteArticleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { GetAllArticlesDocument, useDeleteArticleMutation} from '../generated/graphql-types';
import { Button, message, Popconfirm } from 'antd';

function DeleteProductButton( {articleId} : {articleId: string}) {
import {
GetAllArticlesDocument,
useDeleteArticleMutation,
} from "../generated/graphql-types";
import { Button, message, Popconfirm } from "antd";

function DeleteProductButton({ articleId }: { articleId: string }) {
const [deleteArticle] = useDeleteArticleMutation({
onCompleted(){
message.success('article supprimé avec succès')
}
})
onCompleted() {
message.success("article supprimé avec succès");
},
});

return (
<Popconfirm
title="Supprimer cet article ? "
description="Toutes les données le concernant seront perdues."
okText="Oui"
cancelText="Non"
onConfirm={() => deleteArticle({variables: {deleteArticleId: articleId.toString()}, refetchQueries: [GetAllArticlesDocument]})}
<Popconfirm
title="Supprimer cet article ? "
description="Toutes les données le concernant seront perdues."
okText="Oui"
cancelText="Non"
onConfirm={() =>
deleteArticle({
variables: { deleteArticleId: articleId.toString() },
refetchQueries: [GetAllArticlesDocument],
})
}
>
<Button>Supprimer</Button>
</Popconfirm>
)

);
}

export default DeleteProductButton
export default DeleteProductButton;
41 changes: 24 additions & 17 deletions frontend/src/components/DeleteProductButton.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import { GetAllArticlesDocument, GetAllProductsDocument, useDeleteProductMutation } from '../generated/graphql-types';
import { Button, message, Popconfirm } from 'antd';

function DeleteProductButton( {productId} : {productId: string}) {
import {
GetAllArticlesDocument,
GetAllProductsDocument,
useDeleteProductMutation,
} from "../generated/graphql-types";
import { Button, message, Popconfirm } from "antd";

function DeleteProductButton({ productId }: { productId: string }) {
const [deleteProduct] = useDeleteProductMutation({
onCompleted(){
message.success('produit supprimé avec succès')
}
})
onCompleted() {
message.success("produit supprimé avec succès");
},
});

return (
<Popconfirm
title="Supprimer ce produit ?"
description="Tous les articles associés seront également supprimés."
okText="Oui"
cancelText="Non"
onConfirm={() => deleteProduct({variables: {deleteProductId : productId.toString()}, refetchQueries: [GetAllProductsDocument, GetAllArticlesDocument]})}
<Popconfirm
title="Supprimer ce produit ?"
description="Tous les articles associés seront également supprimés."
okText="Oui"
cancelText="Non"
onConfirm={() =>
deleteProduct({
variables: { deleteProductId: productId.toString() },
refetchQueries: [GetAllProductsDocument, GetAllArticlesDocument],
})
}
>
<Button>Supprimer</Button>
</Popconfirm>
)

);
}

export default DeleteProductButton
export default DeleteProductButton;
78 changes: 43 additions & 35 deletions frontend/src/components/EditArticleDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
import { message, Select } from 'antd'
import { GetAllArticlesDocument, GetAllProductsDocument, useEditArticleMutation } from '../generated/graphql-types'
import { message, Select } from "antd";
import {
GetAllArticlesDocument,
GetAllProductsDocument,
useEditArticleMutation,
} from "../generated/graphql-types";

function EditArticleDropdown( {availability, id} : {availability: boolean, id: number}) {
function EditArticleDropdown({
availability,
id,
}: {
availability: boolean;
id: number;
}) {
const [editArticle] = useEditArticleMutation({
onCompleted(data) {
console.log("mutation completed data", data);
message.success("La disponibilité de l'article a bien été modifiée");
},
onError(error) {
console.log("error after executing mutation", error);
},
refetchQueries: [GetAllProductsDocument, GetAllArticlesDocument],
});

const [editArticle] = useEditArticleMutation({
onCompleted(data) {
console.log("mutation completed data", data)
message.success("La disponibilité de l'article a bien été modifiée");

},
onError(error) {
console.log("error after executing mutation", error);
},
refetchQueries: [GetAllProductsDocument, GetAllArticlesDocument]
})

const onChange = async (value: boolean) => {
await editArticle({
variables: {
article: id.toString(),
data: {availability: value},
}
})
}
const onChange = async (value: boolean) => {
await editArticle({
variables: {
article: id.toString(),
data: { availability: value },
},
});
};

return (
<Select
defaultValue={availability}
style={{ width: 120 }}
options={[
{ value: false, label: "unavailable" },
{ value: true, label: "available" }
]}
onChange={onChange}
/>
)
return (
<Select
defaultValue={availability}
style={{ width: 120 }}
options={[
{ value: false, label: "unavailable" },
{ value: true, label: "available" },
]}
onChange={onChange}
/>
);
}

export default EditArticleDropdown
export default EditArticleDropdown;
22 changes: 11 additions & 11 deletions frontend/src/components/ReservationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Reservation } from "../interface/types";

export const ReservationCard = ( {reservation}: Reservation) => {
export const ReservationCard = ({ reservation }: Reservation) => {
return (
<div>
<div>id de la réservation : {reservation.id} </div>
<div>date de début : {reservation.startDate} </div>
<div>date de fin : {reservation.endDate} </div>
<div>nombre d'articles : {reservation.articles.length}</div>
<div>prix : </div>
<div>status: {reservation.status}</div>
<div>détails</div>
<div>-------</div>
<div>id de la réservation : {reservation.id} </div>
<div>date de début : {reservation.startDate} </div>
<div>date de fin : {reservation.endDate} </div>
<div>nombre d'articles : {reservation.articles.length}</div>
<div>prix : </div>
<div>status: {reservation.status}</div>
<div>détails</div>
<div>-------</div>
</div>
)
}
);
};
Loading

0 comments on commit 8803d24

Please sign in to comment.