Skip to content

Commit

Permalink
Calcule des prix dynamique
Browse files Browse the repository at this point in the history
Signed-off-by: Florian BOUILLON <[email protected]>
  • Loading branch information
Aviortheking committed Sep 27, 2024
1 parent 56ea7a6 commit 6a1b683
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 71 deletions.
4 changes: 2 additions & 2 deletions src/components/global/Cards.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { Eye } from 'lucide-astro';
<div class="bg-white flex flex-col justify-center items-center w-96 p-6 rounded-3xl shadow-lg card slide">
<div class="flex justify-between items-center w-full">
<p class="font-bold text-3xl">{title}</p>
<img class="w-1/4" src={logo}>
<img class="w-1/4" src={logo} loading="lazy">
</div>
<div class="w-full">
<p class="text-gray-400">{description}</p>
</div>
<div class="cards rounded-full w-60 h-60 flex items-center justify-center mt-6">
<img class="max-w-80" alt="" src={imageSrc}/>
<img class="max-w-80" alt="" src={imageSrc} loading="lazy"/>
</div>
<div class="flex justify-between items-center w-full mt-4">
<p class="font-bold text-3xl">{price}€</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/global/TemplateConfig.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-astro';
<div class="lg:w-3/5 flex items-center justify-center">
<div class="cards rounded-full flex items-center justify-center fondCyl">
<div class="lg:w-screen">
<img class="-ml-8 lg:-ml-16" src={imageSrc} />
<img class="-ml-8 lg:-ml-16" src={imageSrc} loading="lazy"/>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/libs/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const commonGeneralPieces = {
potMost: `Pot MOST 50-70 : ${general[0].pot}`,
potVoca: `Pot VOCA 70-80 : ${general[0].potVoca}`,
lamelleFibre: `Lamelle fibre DOPPLER ER2 : ${general[0].lamelleFibre}`,
clapetVl6: `Boite à clapets MALOSSI VL6 : ${general[0]?.clapetVl6}`
};

// Fonction pour créer les pièces spécifiques en combinant les pièces communes et spécifiques
Expand Down Expand Up @@ -87,7 +88,7 @@ const configurations = {
createSpecificPieces(
[`Kit cylindre 75cc Top performance rose : ${all75TopRose[0].cylindre}`,
`Vilebrequin Jasil high tech : ${all75TopRose[0].vilo}`],
['roulement', 'embrayageMost', 'lamelleFibre', 'pipe', 'carbu26', 'potVoca']
['roulement', 'embrayageMost', 'clapetVl6', 'pipe', 'carbu26', 'potVoca']
)
),
};
Expand Down
142 changes: 98 additions & 44 deletions src/libs/donner.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,106 @@
export const config = [
export const general = [
{
allMk: "560",
allTop:"682",
allAirsal:"596",
allAirsalAlu:"736",
allTopRose:"926",
}
];
export const general =[
roulement: 14,
embrayage: 44,
pipe: 14,
carbu: 105,
pot: 212,
embrayageMost: 50,
lamelleFibre: 10,
carbu24: 110,
potVoca: 279,
clapetVl6: 33,
},
];

export const all50Mk = [
{
roulement:"14",
embrayage:"44",
pipe:"14",
carbu:"105",
pot:"212",
embrayageMost:"50",
lamelleFibre:"10",
carbu24:"110",
potVoca:"279",
}
]
export const all50Mk =[
cylindre: 230,
carbu: 118,
},
];

export const all70top = [
{
cylindre:"230",
carbu:"118",
}
]
export const all70top =[
cylindre: 188,
vilo: 105,
},
];

export const all70airsal = [
{
cylindre:"188",
vilo:"105",
}
]
export const all70airsal =[
cylindre: 131,
vilo: 77,
},
];

export const all70airsalAlu = [
{
cylindre:"131",
vilo:"77",
}
]
export const all70airsalAlu =[
cylindre: 132,
vilo: 128,
},
];

export const all75TopRose = [
{
cylindre:"132",
vilo:"128",
cylindre: 289,
vilo: 129,
},
];

const calculateTotalPrice = (specificParts: any, generalParts: any, additionalParts: string[] = []) => {
let total = 0;
// Additionner les valeurs spécifiques
for (const part of Object.values(specificParts)) {
total += part;
}
]
export const all75TopRose =[
{
cylindre:"289",
vilo:"129",
// Additionner les valeurs générales
for (const part of additionalParts) {
total += generalParts[part];
}
]
return total;
};

const PrixAllMk = () => {
const specific = all50Mk[0];
const generalParts = general[0];

return calculateTotalPrice(specific, generalParts, ['pot']);
};

const PrixAllTop = () => {
const specific = all70top[0];
const generalParts = general[0];

return calculateTotalPrice(specific, generalParts, ['pot', 'roulement', 'embrayage', 'pipe', 'carbu']);
};

const PrixAllAirsal = () => {
const specific = all70airsal[0];
const generalParts = general[0];

return calculateTotalPrice(specific, generalParts, ['pot', 'roulement', 'embrayage', 'pipe', 'carbu']);
};

const PrixAllAirsalAlu = () => {
const specific = all70airsalAlu[0];
const generalParts = general[0];

return calculateTotalPrice(specific, generalParts, ['potVoca', 'roulement', 'embrayageMost', 'lamelleFibre', 'pipe', 'carbu24']);
};

const PrixAllTopRose = () => {
const specific = all75TopRose[0];
const generalParts = general[0];

return calculateTotalPrice(specific, generalParts, ['potVoca', 'roulement', 'embrayageMost', 'clapetVl6', 'pipe', 'carbu24']);
};
export const config = [
{
allMk: PrixAllMk(),
allTop: PrixAllTop(),
allAirsal: PrixAllAirsal(),
allAirsalAlu: PrixAllAirsalAlu(),
allTopRose: PrixAllTopRose(),
},
];
44 changes: 22 additions & 22 deletions src/pages/allDays.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@ import { categories } from 'libs/configurations';
<div class="gradientConfig w-full h-2 rounded-b-3xl"></div>
</div>

<div class="bg-white rounded-full items-center h-fit justify-center shadow-lg flex mt-4 py-2 lg:py-0 w-64 lg:w-fit mx-auto flex-col lg:flex-row">
{categories.map(category => (
<a class="pl-4 mx-2 pr-0 text-orange-600 gap-3 flex" href={`#${category.id}`}>
<category.icon /> {category.label}
</a>
))}
</div>
<div class="bg-white rounded-full relative z-30 items-center h-fit justify-center shadow-lg flex mt-4 py-2 lg:py-0 w-64 lg:w-fit mx-auto flex-col lg:flex-row">
{categories.map(category => (
<a class="pl-4 mx-2 pr-0 text-orange-600 gap-3 flex" href={`#${category.id}`}>
<category.icon /> {category.label}
</a>
))}
</div>

{categories.map(category => (
<div id={category.id} class="pt-14">
<div class="flex justify-center my-8 gap-4 flex-wrap">
{category.products.map(product => (
<ProductCard
title={product.title}
logo={`/images/${product.logo}`}
description={product.description}
price={product.price}
imageSrc={`/images/${product.image}`}
lien={`/product/config?config=${product.configKey}#item-1`}
/>
))}
</div>
</div>
))}
<div id={category.id} class="pt-14">
<div class="flex justify-center my-8 gap-4 flex-wrap">
{category.products.map(product => (
<ProductCard
title={product.title}
logo={`/images/${product.logo}`}
description={product.description}
price={product.price}
imageSrc={`/images/${product.image}`}
lien={`/product/config?config=${product.configKey}#item-1`}
/>
))}
</div>
</div>
))}

<a class="bg-amber-400 z-30 fixed right-14 h-12 p-4 -bottom-1 w-16 m-0 flex items-center" href="#top">
<MoveUp class="h-10 w-10" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import Picture from 'components/global/Picture.astro';
</div>
<div class="w-full flex justify-center py-8">
<div class="w-11/12 lg:w-4/5 rounded-2xl bg flex gap-2 items-center py-4 justify-center lg:p-20 flex-col lg:flex-row">
<Picture class="w-3/6" src={moi}></Picture>
<Picture class="w-3/6" src={moi} loading="lazy"></Picture>
<p class="w-9/12 lg:w-2/3 flex text-white gap-3 mx-4">
<Quote class="w-96"/>Moi c’est Lucas, motard de 22 ans, passionné de moto depuis tout petit. Cette passion s'est rapidement étendue à la mécanique. J'ai commencé par construire mes propres moteurs de 50cc, participant à des rassemblements informels qui se sont rapidement transformés en compétitions. J'ai eu l'opportunité de courir pour l'équipe WRP Racing dans plusieurs compétitions, notamment à Salbris et Bordeaux, où j'ai toujours obtenu d'excellents résultats. Au fil des ans, j'ai construit et préparé un grand nombre de moteurs, que ce soit pour moi-même ou pour des clients. J'ai réalisé de nombreuses préparations de configurations, certaines plus extravagantes que d'autres. Grâce à cela, j'ai acquis une solide connaissance et expérience dans le domaine.
C'est cette expertise que j'ai décidé de partager en créant ce site. Mon objectif est d'aider les novices à comprendre plus facilement le monde de la moto, mais aussi de référencer des pièces parfois rares.
Expand Down

0 comments on commit 6a1b683

Please sign in to comment.