RELEASE V.4.0.0 : VERSION LONG SUPPORT (LTS)
--> Imports de ligne via fichier GTFS --> Extrapolation possible des données --> Générateur de fiches horaires
This commit is contained in:
1 parent
1c68740e41
commit
a7f0c96435
7 files changed
+1085
-183
No files matched your search
+60
-9
@@ -1022,16 +1022,67 @@ export function formatHeure(time) {
|
||||
*/
|
||||
export function getJoursCirculation(horaire) {
|
||||
if (!horaire) return [];
|
||||
|
||||
const parseBool = (v) => {
|
||||
if (typeof v === 'boolean') return v;
|
||||
if (typeof v === 'number') return v === 1;
|
||||
if (typeof v === 'string') {
|
||||
const s = v.trim().toLowerCase();
|
||||
return s === 'true' || s === 't' || s === '1' || s === 'oui' || s === 'yes' || s === 'y';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const jours = [];
|
||||
if (horaire.circule_lundi) jours.push('Lun');
|
||||
if (horaire.circule_mardi) jours.push('Mar');
|
||||
if (horaire.circule_mercredi) jours.push('Mer');
|
||||
if (horaire.circule_jeudi) jours.push('Jeu');
|
||||
if (horaire.circule_vendredi) jours.push('Ven');
|
||||
if (horaire.circule_samedi) jours.push('Sam');
|
||||
if (horaire.circule_dimanche) jours.push('Dim');
|
||||
return jours;
|
||||
}export async function updateQuaisReelsHoraire(horaireId, quaisParOrdre, isPropagation = false) {
|
||||
if (parseBool(horaire.circule_lundi)) jours.push('Lun');
|
||||
if (parseBool(horaire.circule_mardi)) jours.push('Mar');
|
||||
if (parseBool(horaire.circule_mercredi)) jours.push('Mer');
|
||||
if (parseBool(horaire.circule_jeudi)) jours.push('Jeu');
|
||||
if (parseBool(horaire.circule_vendredi)) jours.push('Ven');
|
||||
if (parseBool(horaire.circule_samedi)) jours.push('Sam');
|
||||
if (parseBool(horaire.circule_dimanche)) jours.push('Dim');
|
||||
|
||||
if (jours.length > 0) return jours;
|
||||
|
||||
// Fallback si formaté en chaîne de caractères
|
||||
const txt = String(horaire.jours_circulation || horaire.frequence || horaire.periodicite || '').toLowerCase();
|
||||
if (txt) {
|
||||
if (txt.includes('tous') || txt.includes('quotidien') || txt.includes('7j')) {
|
||||
return ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'];
|
||||
}
|
||||
if (txt.includes('lun') && txt.includes('ven')) {
|
||||
return ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven'];
|
||||
}
|
||||
if (txt.includes('lun') && txt.includes('sam')) {
|
||||
return ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'];
|
||||
}
|
||||
if (txt.includes('sam') && txt.includes('dim')) {
|
||||
return ['Sam', 'Dim'];
|
||||
}
|
||||
if (txt.includes('dim')) return ['Dim'];
|
||||
if (txt.includes('sam')) return ['Sam'];
|
||||
if (txt.includes('ven')) return ['Ven'];
|
||||
}
|
||||
|
||||
// Fallback jours personnalisés
|
||||
if (Array.isArray(horaire.jours_personnalises) && horaire.jours_personnalises.length > 0) {
|
||||
const dows = new Set();
|
||||
const mapDow = ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'];
|
||||
horaire.jours_personnalises.forEach(j => {
|
||||
if (j && j.circule !== false && j.date) {
|
||||
const d = new Date(j.date).getDay();
|
||||
if (!isNaN(d)) dows.add(mapDow[d]);
|
||||
}
|
||||
});
|
||||
if (dows.size > 0) {
|
||||
return ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'].filter(d => dows.has(d));
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
export async function updateQuaisReelsHoraire(horaireId, quaisParOrdre, isPropagation = false) {
|
||||
if (!isSupabaseConfigured) {
|
||||
return { data: null, error: null };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user