Skip to content
Extraits de code Groupes Projets
Valider 266a4801 rédigé par Mohamed Lemine BAILLAHI's avatar Mohamed Lemine BAILLAHI
Parcourir les fichiers

Merge branch 'feature/MYD-105' into 'develop'

MYD-105/ Add some new interfaces and update the existing

See merge request !88
parents 90357af0 f75229a6
Branches
1 requête de fusion!88MYD-105/ Add some new interfaces and update the existing
Pipeline #660 réussi avec l'étape
in 5 minutes et 49 secondes
Affichage de
avec 531 ajouts et 471 suppressions
Ce diff est replié.
import MondialRelayMainView from "@/shared/sections/shipping/mondialRelay/mondialRelay-InPost/MondialRelayMainView";
import MondialRelayMainView from "@/shared/sections/shipping/mondialRelay-InPost/MondialRelayMainView";
export const metadata = {
title: 'Dashboard: Mondial Relay - InPost',
};
export default function MondialRelayPage() {
export default function MondialRelayInPostPage() {
return <MondialRelayMainView />;
}
import ExpeditionMondialRelayListView from "@/shared/sections/shipping/mondialRelay/expedition/expeditionMondialRelay-list-view";
export const metadata = {
title: 'Dashboard: Expéditions',
};
export default function ExpeditionMondialRelayPage() {
return <ExpeditionMondialRelayListView />;
}
import OrderMondialRelayListView from "@/shared/sections/shipping/mondialRelay/massCreation/MondialRelayOrderListView";
export const metadata = {
title: 'Dashboard: Création en masse',
};
export default function MassCreationPage() {
return <OrderMondialRelayListView />;
}
import MondialRelayMainView from "@/shared/sections/shipping/mondialRelay/mondialRelay-InPost/MondialRelayMainView";
export const metadata = {
title: 'Dashboard: Livraison-Colissimo',
};
export default function ListOrdersColissimoPage() {
return <MondialRelayMainView />;
}
......@@ -21,9 +21,9 @@ export type ShippingMethod =
| { id: string; name: string; active: boolean; type: ShippingMethodType.FreeShipping; description: string; data: FreeShipping }
| { id: string; name: string; active: boolean; type: ShippingMethodType.FlatRate; description: string; data: FlatRate }
| { id: string; name: string; active: boolean; type: ShippingMethodType.MondialRelay; description: string; data: MondialRelay }
| { id: string; name: string; active: boolean; type: ShippingMethodType.ColissimoWithSignature; description: string; data: null }
| { id: string; name: string; active: boolean; type: ShippingMethodType.ColissimoWithoutSignature; description: string; data: null }
| { id: string; name: string; active: boolean; type: ShippingMethodType.PointOfSale; description: string; data: null };
| { id: string; name: string; active: boolean; type: ShippingMethodType.ColissimoWithSignature; description: string; data: ColissimoWithoutSignature }
| { id: string; name: string; active: boolean; type: ShippingMethodType.ColissimoWithoutSignature; description: string; data: ColissimoWithSignature }
| { id: string; name: string; active: boolean; type: ShippingMethodType.PointOfSale; description: string; data: PointOfSale };
export type FreeShipping = {
requires: RequiresFreeShipping | String;
......@@ -39,13 +39,53 @@ export type FlatRate = {
calculationType: CalculationType;
};
export type ColissimoWithoutSignature = {
alwaysFree: boolean;
nameFreeShipping: string;
shippingClassExcluded: ShippingClass[];
FreeShippingClasses: ShippingClass[];
FreeIfOneProductHaveFreeShippingClass: boolean;
DeliveryCostList: DeliveryCostColissimo[];
DeliveryReductionList: DeliveryReductionColissimo[];
};
export type ColissimoWithSignature = {
alwaysFree: boolean;
nameFreeShipping: string;
shippingClassExcluded: ShippingClass[];
FreeShippingClasses: ShippingClass[];
FreeIfOneProductHaveFreeShippingClass: boolean;
DeliveryCostList: DeliveryCostColissimo[];
DeliveryReductionList: DeliveryReductionColissimo[];
};
export type DeliveryCostColissimo = {
fromWeight: number;
toWeight: number;
fromPrice: number;
toPrice: number;
shippingClass: ShippingClass;
cost: number;
}
export type DeliveryReductionColissimo = {
nbrProducts: number;
percentageReduction: number;
}
export type MondialRelay = {
amountFreeShipping: number;
nameFreeShipping: string;
modeMondialRelay: MondialRelayMode;
listCostDelivery: { weightCart: number; weightPackaging: number; cost: number }[];
listCostDelivery: DeliveryCostMondialRelay[];
};
export type DeliveryCostMondialRelay = {
weightCart: number;
weightPackaging: number;
cost: number;
}
export type PointOfSale = {
tvaStatut: boolean;
cost: number;
......
......@@ -83,9 +83,7 @@ export const paths = {
},
colissimo: `${ROOTS.DASHBOARD}/shipping/colissimo`,
mondialRelayInPost: {
root: `${ROOTS.DASHBOARD}/shipping/mondialRelay/mondialRelay-InPost`,
massCreation: `${ROOTS.DASHBOARD}/shipping/mondialRelay/massCreation`,
expedition: `${ROOTS.DASHBOARD}/shipping/mondialRelay/expedition`,
root: `${ROOTS.DASHBOARD}/shipping/mondialRelay-InPost`,
},
},
payment: {
......
......@@ -185,26 +185,7 @@ export function useNavData() {
children: [
{ title: "Général", path: paths.dashboard.shipping.general.root },
{ title: "Colissimo", path: paths.dashboard.shipping.colissimo },
{
title: "Mondial Relay - InPost",
path: paths.dashboard.shipping.mondialRelayInPost.root,
children: [
{
title: "Mondial Relay - InPost",
path: paths.dashboard.shipping.mondialRelayInPost.root,
},
{
title: "Création en masse",
path: paths.dashboard.shipping.mondialRelayInPost
.massCreation,
},
{
title: "Expéditions",
path: paths.dashboard.shipping.mondialRelayInPost
.expedition,
},
],
},
{ title: "Mondial Relay - InPost", path: paths.dashboard.shipping.mondialRelayInPost.root },
],
},
{
......
......@@ -13,16 +13,17 @@ import { extend } from 'lodash';
interface Props extends ButtonProps{
multiple?: boolean;
buttonStyle?: CSSProperties;
nameBtn?: string;
}
export default function AddMediaButton({multiple, buttonStyle, ...buttonProps}: Props) {
export default function AddMediaButton({multiple, buttonStyle, nameBtn="Ajouter une image", ...buttonProps}: Props) {
const OpenAddMedia = useBoolean();
return (
<>
<Button {...buttonProps} style={{ ...buttonStyle }} onClick={OpenAddMedia.onTrue}>Ajouter un média</Button>
<Button {...buttonProps} style={{ ...buttonStyle }} onClick={OpenAddMedia.onTrue}>{nameBtn}</Button>
{multiple ? (
<NewMultiMediaModal open={OpenAddMedia.value} onClose={OpenAddMedia.onFalse} />
) : (
......
......@@ -9,6 +9,7 @@ import { useSettingsContext } from '@/components/settings';
import OrderColissimoListView from './orders/OrderColissimoListView';
import ColisColissimoTableView from './colis/ColisColissimoTableView';
import HistoricBordereauColissimoTableView from './historicBordereau/HistoricBordereauColissimoTableView';
import ConfigVendorCOView from './vendor/ConfigVendorCOView';
// ----------------------------------------------------------------------
......@@ -16,14 +17,18 @@ import HistoricBordereauColissimoTableView from './historicBordereau/HistoricBor
const TABS = [
{
value: '1',
label: 'Commandes',
label: 'Vendeur',
},
{
value: '2',
label: "Création de bordereaux",
label: 'Commandes',
},
{
value: '3',
label: "Colis",
},
{
value: '4',
label: 'Historiques des bordereaux',
},
];
......@@ -58,11 +63,13 @@ export default function ColissimoMainView({ defaultValue }: ShippingMainViewProp
))}
</Tabs>
{currentTab === '1' && <OrderColissimoListView />}
{currentTab === '1' && <ConfigVendorCOView />}
{currentTab === '2' && <OrderColissimoListView />}
{currentTab === '2' && <ColisColissimoTableView />}
{currentTab === '3' && <ColisColissimoTableView />}
{currentTab === '3' && <HistoricBordereauColissimoTableView />}
{currentTab === '4' && <HistoricBordereauColissimoTableView />}
</Container>
);
......
......@@ -16,10 +16,22 @@ import FormProvider, {
} from '@/components/hook-form';
import LoadingButton from '@mui/lab/LoadingButton';
import { countries } from '@/shared/assets/data/countries'
import { Box, Typography } from '@mui/material';
import { Box, Checkbox, FormControl, IconButton, InputAdornment, InputLabel, MenuItem, OutlinedInput, Select, Typography } from '@mui/material';
import { Visibility, VisibilityOff } from '@mui/icons-material';
import { useState } from 'react';
export default function ConfigVendeurView() {
const languagesColissimo = [
{ value: "fr_FR", label: "Français" },
{ value: "de_DE", label: "Allemand" },
{ value: "en_GB", label: "Anglais" },
{ value: "es_ES", label: "Espagnol" },
{ value: "it_IT", label: "Italien" },
{ value: "nl_NL", label: "Néerlandais" }
];
export default function ConfigVendorCOView() {
const mdUp = useResponsive('up', 'md');
const { enqueueSnackbar } = useSnackbar();
......@@ -32,6 +44,8 @@ export default function ConfigVendeurView() {
country: Yup.string().required('Ce champ est requis'),
phone1: Yup.string().required('Ce champ est requis'),
phone2: Yup.string(),
contractNumber: Yup.string(),
accountPassword: Yup.string(),
mail: Yup.string().email('Veuillez saisir une adresse e-mail valide').required('Ce champ est requis'),
});
......@@ -57,44 +71,42 @@ export default function ConfigVendeurView() {
}
});
const renderDetails = (
const [showPassword, setShowPassword] = useState(false);
const handleClickShowPassword = () => setShowPassword((show) => !show);
const handleMouseDownPassword = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
};
const renderShipper = (
<>
{mdUp && (
<Grid xs={12} md={4}>
<Typography variant="h6" sx={{ mb: 0.5 }}>
Coordonnées du vendeur
</Typography>
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
Configuration des coordonnées du vendeur.
</Typography>
</Grid>
)}
<Grid xs={12} md={8}>
<Grid xs={12} md={12}>
<Card>
{!mdUp ? (<CardHeader title="Coordonnées du vendeur" />) : (<></>)}
<CardHeader title="Coordonnées d'expédition" />
<Stack spacing={3} sx={{ p: 3 }}>
<Box display="flex" flexDirection="column" alignItems="flex-start">
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="expediteur" label="Expéditeur" />
<RHFTextField name="mail" label="Adresse e-mail" type='email' sx={{ ml: 2 }} />
<RHFTextField name="companyName" label="Nom de l'entreprise" />
</Box>
<Box display="flex" width="100%" marginBottom={2} justifyContent="space-between">
<RHFTextField name="phone1" label="Téléphone" type='number' />
<RHFTextField name="phone2" label="Téléphone 2" type='number' sx={{ ml: 2 }} />
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="lastName" label="Nom de famille" />
<RHFTextField name="firstName" label="Prénom" sx={{ ml: 2 }} />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="line0" label="Ligne d'adresse 0" />
<RHFTextField name="line1" label="Ligne d'adresse 1" sx={{ ml: 2 }} />
</Box>
<Box display="flex" width="100%" marginBottom={2} justifyContent="space-between">
<RHFTextField name="rue" label="Rue" />
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="line2" label="Ligne d'adresse 2" />
<RHFTextField name="line3" label="Ligne d'adresse 3" sx={{ ml: 2 }} />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="codePostal" label="Code Postal" sx={{ width: "30vh" }} />
<RHFTextField name="ville" label="Ville" sx={{ ml: 2, width: "50vh" }} />
<RHFAutocomplete
name="country"
name="countryCode"
label="Pays"
placeholder="+ Pays"
sx={{ width: "70vh", ml: 2 }}
sx={{ width: "70vh" }}
freeSolo
disableCloseOnSelect
options={countries.map(country => country.label)}
......@@ -117,6 +129,63 @@ export default function ConfigVendeurView() {
))
}
/>
<RHFTextField name="city" label="Ville" sx={{ ml: 2, width: "50vh" }} />
<RHFTextField name="zipCode" label="Code Postal" sx={{ ml: 2, width: "30vh" }} />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="phoneNumber" label="Téléphone" type='number' />
<RHFTextField name="mobileNumber" label="Téléphone 2" type='number' sx={{ ml: 2 }} />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="doorCode1" label="Code de porte 1" />
<RHFTextField name="doorCode2" label="Code de porte 2" sx={{ ml: 2 }} />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="email" label="Adresse e-mail" type='email' />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="intercom" label="Interphone" />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<FormControl sx={{ width: "70vh" }}>
<InputLabel id="language-label">Langue</InputLabel>
<Select
labelId="language-label"
name="language"
label="Langue"
defaultValue="fr_FR"
>
{languagesColissimo.map((language) => (
<MenuItem key={language.value} value={language.value}>
{language.label}
</MenuItem>
))}
</Select>
</FormControl>
<RHFTextField name="stateOrProvinceCode" label="Code de l'état ou de la province" sx={{ ml: 2 }} />
</Box>
<Box display="flex" width="100%" marginBottom={2}>
<RHFTextField name="contractNumber" label="Numéro de contrat" sx={{ width: "50%" }} />
<FormControl variant="outlined" sx={{width: '50%', ml: 2}}>
<InputLabel htmlFor="outlined-adornment-password">Password</InputLabel>
<OutlinedInput
id="outlined-adornment-password"
type={showPassword ? 'text' : 'password'}
endAdornment={
<InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
</InputAdornment>
}
label="Password"
/>
</FormControl>
</Box>
</Box>
</Stack>
......@@ -125,6 +194,7 @@ export default function ConfigVendeurView() {
</>
);
const renderActions = (
<>
{mdUp && <Grid md={4} />}
......@@ -145,7 +215,7 @@ export default function ConfigVendeurView() {
return (
<FormProvider methods={methods} onSubmit={onSubmit}>
<Grid container spacing={3}>
{renderDetails}
{renderShipper}
{renderActions}
</Grid>
</FormProvider>
......
import { useState } from 'react';
import Grid from '@mui/material/Unstable_Grid2';
import React, { useState, useEffect } from 'react';
import Grid from '@mui/material/Grid';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import StatisticsDeliveredOrders from './StatisticsDeliveredOrders';
import CustomBreadcrumbs from '@/components/custom-breadcrumbs/custom-breadcrumbs';
import { paths } from '@/routes/paths';
import { FormControl, InputLabel, Select, MenuItem } from '@mui/material';
// Définition des types
type Commande = {
id: string;
codepostal: string;
dateLivraison: Date;
nomPays: string;
codePays: string;
nomVille: string;
};
// ----------------------------------------------------------------------
type Country = {
nomPays: string;
codePays: string;
villes: string[];
};
export default function ShippingStatisticsView() {
// Simulated commandes data (should be fetched or initialized properly)
let commandes: Commande[] = [];
let commandes: { codepostal: string; dateLivraison: Date }[] = [];
// Générer les données pour les trois pays
const countries: Country[] = [
{ nomPays: 'France', codePays: 'FR', villes: ['Paris', 'Marseille', 'Lyon'] },
{ nomPays: 'Italie', codePays: 'IT', villes: ['Rome', 'Milan', 'Naples'] },
{ nomPays: 'Espagne', codePays: 'ES', villes: ['Madrid', 'Barcelona', 'Valencia'] },
];
const codesPostaux = generateCodesPostaux(30);
codesPostaux.forEach(codepostal => {
let nombreCommandes = generateRandomNumber(10, 100);
for (let i = 0; i < nombreCommandes; i++) {
let dateLivraison = generateRandomDate();
commandes.push({ codepostal, dateLivraison });
}
countries.forEach(country => {
commandes.push(...generateCountryData(country, 30));
});
function generateCodesPostaux(minimum: number): string[] {
let codesPostaux: string[] = [];
while (codesPostaux.length < 25) {
let codepostal = generateRandomCodePostal();
if (!codesPostaux.includes(codepostal)) {
codesPostaux.push(codepostal);
}
const getCitiesForCountry = (countryCode: string) => {
return Array.from(new Set(commandes
.filter(commande => commande.codePays === countryCode)
.map(commande => commande.nomVille)));
};
// Initialiser la sélection du pays avec la France
const defaultSelectedCountry = countries[0];
const defaultSelectedCity = "all";
const [selectedCountry, setSelectedCountry] = useState<Country>(defaultSelectedCountry);
const [selectedCity, setSelectedCity] = useState<string>(defaultSelectedCity);
const [selectedStartDate, setSelectedStartDate] = useState<Date | null>(null);
const [selectedEndDate, setSelectedEndDate] = useState<Date | null>(null);
const [cities, setCities] = useState<string[]>(getCitiesForCountry(defaultSelectedCountry.codePays));
const [uniquePrefixes, setUniquePrefixes] = useState<string[]>([]);
const [selectedPrefix, setSelectedPrefix] = useState<string>("all");
const [sourceData, setSourceData] = useState<Commande[]>(commandes);
const [chartData, setChartData] = useState<Commande[]>([]);
// Appliquer le filtre par pays au chargement initial de la page
useEffect(() => {
const filteredData = sourceData.filter(commande => commande.codePays === selectedCountry.codePays);
setChartData(filteredData);
setUniquePrefixes(Array.from(new Set(filteredData.map(commande => commande.codepostal.substr(0, 2)))));
}, [sourceData, selectedCountry]);
// Méthode pour filtrer les données
const applyFilters = () => {
let filteredData = sourceData;
// Filtrer par pays
filteredData = filteredData.filter(commande => commande.codePays === selectedCountry.codePays);
// Filtrer par ville
if (selectedCity && selectedCity !== "all") {
filteredData = filteredData.filter(commande => commande.nomVille === selectedCity);
}
return codesPostaux;
}
function generateRandomCodePostal(): string {
const min = 10;
const max = 99;
const codepostal = Math.floor(Math.random() * (max - min + 1) + min).toString();
return codepostal;
}
// Mettre à jour les préfixes uniques en fonction du filtre actuel
const updatedPrefixes = Array.from(new Set(filteredData.map(commande => commande.codepostal.substr(0, 2))));
setUniquePrefixes(updatedPrefixes);
function generateRandomDate(): Date {
let year = 2024;
let month = Math.floor(Math.random() * 12) + 1;
let day = Math.floor(Math.random() * 28) + 1;
return new Date(year, month - 1, day);
}
// Filtrer par préfixe
if (selectedPrefix && selectedPrefix !== "all") {
filteredData = filteredData.filter(commande => commande.codepostal.startsWith(selectedPrefix));
}
function generateRandomNumber(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Filtrer par date
if (selectedStartDate && selectedEndDate) {
filteredData = filteredData.filter(commande => {
const commandDate = new Date(commande.dateLivraison);
return commandDate >= selectedStartDate && commandDate <= selectedEndDate;
});
}
setChartData(filteredData);
};
console.log(commandes);
// Appliquer les filtres de ville, préfixe et date à chaque changement
useEffect(() => {
applyFilters();
}, [selectedCity, selectedPrefix, selectedCountry, selectedStartDate, selectedEndDate]);
const [data, setData] = useState(commandes);
const [selectedDate, setSelectedDate] = useState<Date | null>(null);
useEffect(() => {
const newCities = getCitiesForCountry(selectedCountry.codePays);
setCities(newCities);
setSelectedCity('all');
}, [selectedCountry]);
const handleDateChange = (date: Date | null) => {
setSelectedDate(date);
const filteredData = commandes.filter(commande =>
selectedDate ? new Date(commande.dateLivraison).toDateString() === new Date(selectedDate).toDateString() : true
);
setData(filteredData);
const handleStartDateChange = (date: Date | null) => {
setSelectedStartDate(date);
};
let commandesParCodePostal: { label: string; value: number }[] = [];
const handleEndDateChange = (date: Date | null) => {
setSelectedEndDate(date);
};
let commandesParCodePostal: { label: string; value: number }[] = [];
let countMap: { [codePostal: string]: number } = {};
data.forEach(data => {
chartData.forEach(data => {
if (countMap[data.codepostal]) {
countMap[data.codepostal]++;
} else {
......@@ -78,15 +130,10 @@ export default function ShippingStatisticsView() {
commandesParCodePostal.push({ label: codepostal, value: countMap[codepostal] });
}
console.log(commandesParCodePostal);
return (
<>
<Grid xs={12} md={12} container>
<Grid xs={12} md={4}>
<Grid container spacing={2}>
<Grid item xs={12} md={12}>
<CustomBreadcrumbs
heading="Statistiques de livraison"
links={[
......@@ -103,29 +150,145 @@ export default function ShippingStatisticsView() {
}}
/>
</Grid>
<Grid xs={12} md={8} mt={5}>
<Grid item xs={12} md={12}>
<FormControl variant="outlined" sx={{ mb: 2, width: "20%" }}>
<InputLabel id="country-label">Pays</InputLabel>
<Select
labelId="country-label"
id="country-select"
value={selectedCountry.codePays}
onChange={(event) => {
const countryCode = event.target.value as string;
const newSelectedCountry = countries.find(country => country.codePays === countryCode);
setSelectedCountry(newSelectedCountry || defaultSelectedCountry);
setSelectedCity("all");
}}
label="Pays"
>
{countries.map(country => (
<MenuItem key={country.codePays} value={country.codePays}>
{country.nomPays}
</MenuItem>
))}
</Select>
</FormControl>
<FormControl variant="outlined" sx={{ mb: 2, ml: 1, width: "20%" }}>
<InputLabel id="city-label">Ville</InputLabel>
<Select
labelId="city-label"
id="city-select"
value={selectedCity}
onChange={(event) => {
setSelectedCity(event.target.value as string);
}}
label="Ville"
>
<MenuItem key={"all"} value={"all"}>Toutes les villes</MenuItem>
{cities.map(ville => (
<MenuItem key={ville} value={ville}>
{ville}
</MenuItem>
))}
</Select>
</FormControl>
<FormControl variant="outlined" sx={{ mb: 2, ml: 1, width: "20%" }}>
<InputLabel id="prefix-label">Préfixe</InputLabel>
<Select
labelId="prefix-label"
id="prefix-select"
value={selectedPrefix}
onChange={(event) => {
setSelectedPrefix(event.target.value as string);
}}
label="Préfixe"
>
<MenuItem key={"all"} value={"all"}>
Tous les préfixes
</MenuItem>
{uniquePrefixes.map(prefix => (
<MenuItem key={prefix} value={prefix}>
{prefix}
</MenuItem>
))}
</Select>
</FormControl>
<DatePicker
label="Date de début"
slotProps={{
textField: {
fullWidth: true,
},
}}
sx={{
width: "15%", ml: 1
}}
value={selectedStartDate}
onChange={handleStartDateChange}
/>
<DatePicker
label="Date de livraison"
label="Date de fin"
slotProps={{
textField: {
fullWidth: true,
},
}}
sx={{
maxWidth: { md: 200 },
width: "15%", ml:1
}}
value={selectedDate}
onChange={handleDateChange}
value={selectedEndDate}
onChange={handleEndDateChange}
/>
</Grid>
<Grid xs={12} md={12}>
<StatisticsDeliveredOrders
title="Commandes livrer par code postal"
title="Commandes livrées par code postal"
chart={{
series: commandesParCodePostal
}}
sx={{ mt: 2 }}
/>
</Grid>
</Grid>
</>
);
}
// Fonction pour générer des données de commandes
function generateCountryData(country: Country, numberOfOrders: number): Commande[] {
let commandes: Commande[] = [];
// Générer des commandes pour chaque ville du pays
country.villes.forEach((nomVille) => {
let prefixCommun = Math.floor(Math.random() * 90); // Générer un préfixe commun initial
for (let i = 0; i < numberOfOrders / country.villes.length; i += 2) {
const randomSuffix1 = Math.floor(Math.random() * 10000); // Suffixe aléatoire pour les 4 derniers chiffres
const randomSuffix2 = Math.floor(Math.random() * 10000); // Suffixe aléatoire pour les 4 derniers chiffres
// Générer deux commandes avec le même préfixe
const codePostal1 = `${prefixCommun}${randomSuffix1}`.padStart(6, '0').slice(0, 6);
const codePostal2 = `${prefixCommun}${randomSuffix2}`.padStart(6, '0').slice(0, 6);
let dateLivraison1 = generateRandomDate();
let dateLivraison2 = generateRandomDate();
let id1 = Math.floor(Math.random() * 123).toString();
let id2 = Math.floor(Math.random() * 123).toString();
commandes.push({ id: id1, codepostal: codePostal1, dateLivraison: dateLivraison1, nomPays: country.nomPays, codePays: country.codePays, nomVille });
commandes.push({ id: id2, codepostal: codePostal2, dateLivraison: dateLivraison2, nomPays: country.nomPays, codePays: country.codePays, nomVille });
// Incrémenter le préfixe pour la prochaine paire de codes postaux
prefixCommun = (prefixCommun + 1) % 100; // Assurer que le préfixe reste dans la plage de 0 à 99
}
});
return commandes;
}
// Fonction pour générer une date aléatoire
function generateRandomDate(): Date {
let year = 2024;
let month = Math.floor(Math.random() * 12) + 1;
let day = Math.floor(Math.random() * 28) + 1;
return new Date(year, month - 1, day);
}
......@@ -6,10 +6,12 @@ import Tabs from '@mui/material/Tabs';
import Container from '@mui/material/Container';
import { _userAbout, _userPlans, _userPayment, _userInvoices, _userAddressBook } from '@/shared/_mock';
import { useSettingsContext } from '@/components/settings';
import ConfigVendeurView from './vendeur/ConfigVendeurView';
import ConfigEmailView from './emails/ConfigEmailView';
import ConfigShippingMethodTable from './shippingMethod/ConfigShippingMethodTable';
import ConfigCompteModialRelay from './compte/ConfigCompteMondialRelay';
import ConfigVendorMRView from './vendor/ConfigVendorMRView';
import OrderMondialRelayListView from './orders/MondialRelayOrderListView';
import MondialRelayOrderListView from './orders/MondialRelayOrderListView';
import MondialRelayExpeditionListView from './expeditions/expeditionMondialRelay-list-view';
// ----------------------------------------------------------------------
......@@ -21,15 +23,19 @@ const TABS = [
},
{
value: '2',
label: "Méthode de livraison",
label: 'Vendeur',
},
{
value: '3',
label: 'Vendeur',
label: 'Emails',
},
{
value: '4',
label: 'Emails',
label: 'Commandes',
},
{
value: '5',
label: 'Expéditions',
},
];
......@@ -65,11 +71,13 @@ export default function MondialRelayMainView({ defaultValue }: ShippingMainViewP
{currentTab === '1' && <ConfigCompteModialRelay />}
{currentTab === '2' && <ConfigShippingMethodTable />}
{currentTab === '2' && <ConfigVendorMRView />}
{currentTab === '3' && <ConfigEmailView />}
{currentTab === '3' && <ConfigVendeurView />}
{currentTab === '4' && <MondialRelayOrderListView />}
{currentTab === '4' && <ConfigEmailView />}
{currentTab === '5' && <MondialRelayExpeditionListView />}
</Container>
);
......
......@@ -6,50 +6,20 @@ import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import Grid from '@mui/material/Unstable_Grid2';
import Card from '@mui/material/Card';
import Divider from '@mui/material/Divider';
import Button from '@mui/material/Button';
import Chip from '@mui/material/Chip';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import { useSnackbar } from '@/components/snackbar';
import LoadingButton from '@mui/lab/LoadingButton';
import FormLabel from '@mui/material/FormLabel';
import Checkbox from '@mui/material/Checkbox';
import FormProvider, {
RHFEditor,
RHFTextField,
RHFAutocomplete,
} from "@/shared/components/hook-form";
import Box from '@mui/material/Box';
import Modal from '@mui/material/Modal';
import { EmailConfig } from '@/contexts/types/Shipping';
import AddMediaButton from '@/shared/sections/media/view/Add-media-button';
import { useResponsive } from '@/hooks/use-responsive';
const SmartTags_OPTIONS = [
{ value: "Blog_Info", label: "Blog Info" },
{ value: "Home_Url", label: "Home URL" },
];
const RegisterFormType_OPTIONS = [
{ value: "Default_Form", label: "Default Form" },
{ value: "Untitled", label: "Untitled" },
];
const style = {
position: 'absolute' as 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 400,
bgcolor: 'background.paper',
border: '2px solid #FFF',
boxShadow: 24,
p: 4,
};
export default function ConfigEmailView() {
......@@ -61,9 +31,8 @@ export default function ConfigEmailView() {
description: Yup.string(),
});
const defaultSubject = "Votre commande n°[expedition] a été expédiée.";
const defaultDescription = "Bonjour [prenom] [nom], \n Nous vous informons que votre commande a été expédiée. \nVous la recevrez sous peu, mais si vous souhaitez garder un œil dessus, vous pouvez vous rendre sur [lien] pour suivre son trajet. \nL'expédition [expedition] sera livrée à l’adresse suivante : [adresse]. \nN'hésitez pas à nous contacter pour toute information complémentaire. \nVotre service client";
const defaultDescription = `Bonjour [prenom] [nom], <br/><br/>Nous vous informons que votre commande a été expédiée. Vous la recevrez sous peu, mais si vous souhaitez garder un œil dessus, vous pouvez vous rendre sur [lien] pour suivre son trajet. <br/>L'expédition [expedition] sera livrée à l’adresse suivante : [adresse]. <br/><br/>N'hésitez pas à nous contacter pour toute information complémentaire. <br/><br/>Votre service client`;
const emailConfigValue: EmailConfig = {
subject: defaultSubject,
......@@ -107,10 +76,6 @@ export default function ConfigEmailView() {
setChecked(event.target.checked);
};
const [open, setOpen] = useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const renderBasic = (
<>
<Grid xs={12} md={12}>
......@@ -155,7 +120,6 @@ export default function ConfigEmailView() {
</Typography>
</Typography>
<Card>
<Stack spacing={1.5} p={2}>
<Grid container alignItems="center" spacing={1} mt={1}>
......@@ -167,41 +131,8 @@ export default function ConfigEmailView() {
</Grid>
</Grid>
<Grid container spacing={1} mt={1}>
<AddMediaButton multiple variant="outlined" color="success" size="small" sx={{ mt: 1 }} />
<Button variant="outlined" color="success" sx={{ ml: 1, mt: 1 }} size="small" onClick={handleOpen}>Ajouter formulaire d'inscription</Button>
<Grid md={5} sx={{ ml: 1 }}>
<RHFAutocomplete
name="smartTags"
label="Selectionner SMART TAGS"
placeholder="+ Selectionner SMART TAGS"
multiple
size="small"
freeSolo
disableCloseOnSelect
options={SmartTags_OPTIONS.map(tag => tag.label)}
getOptionLabel={(option) => option}
renderOption={(props, option) => (
<li {...props} key={option}>
{option}
</li>
)}
renderTags={(selected, getTagProps) =>
selected.map((option, index) => (
<Chip
{...getTagProps({ index })}
key={option}
label={option}
size="small"
color="success"
variant="soft"
/>
))
}
style={{ width: "60%", marginBottom: 16 }}
/>
</Grid>
<AddMediaButton multiple variant="outlined" color="success" size="medium" sx={{ mt: 1 }} />
</Grid>
<RHFEditor simple name="description"
onChange={(value) => {
console.log(value);
......@@ -211,57 +142,6 @@ export default function ConfigEmailView() {
</Card>
</Stack>
</Grid>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box sx={style} display="grid" gridTemplateRows="auto 1fr auto" borderRadius={2}>
<Box sx={{ p: 2 }}>
<Typography id="modal-modal-title" variant="h6" component="h2">
Inserer Formulaire
</Typography>
</Box>
<Divider sx={{ mb: 5 }} />
<FormLabel sx={{ color: "black" }}>Sélectionnez un formulaire ci-dessous à insérer</FormLabel>
<Box sx={{ p: 2 }}>
<RHFAutocomplete
name="registerFormType"
label="Sélectionnez un formulaire"
placeholder="+ Select a form below to insert"
freeSolo
options={RegisterFormType_OPTIONS.map(form => form.label)}
getOptionLabel={(option) => option}
renderOption={(props, option) => (
<li {...props} key={option}>
{option}
</li>
)}
renderTags={(selected, getTagProps) =>
selected.map((option, index) => (
<Chip
{...getTagProps({ index })}
key={option}
label={option}
size="small"
color="success"
variant="soft"
/>
))
}
style={{ width: "100%", marginBottom: 16 }}
/>
</Box>
<Divider />
<Box sx={{ display: 'flex', justifyContent: 'flex-end', p: 2 }}>
<Button onClick={handleClose} variant="outlined" color="inherit">Cancel</Button>
<Button variant="contained" color="inherit" sx={{ ml: 1 }}>Valider</Button>
</Box>
</Box>
</Modal>
</>
);
......
......@@ -77,7 +77,7 @@ const HIDE_COLUMNS_TOGGLABLE = ["category", "actions"];
// ----------------------------------------------------------------------
export default function ExpeditionMondialRelayListView() {
export default function MondialRelayExpeditionListView() {
const [orders, setOrders] = useState<IOrderMondialRelayItem[]>(orderMondialRelayList);
......
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter