|
|
@@ -214,18 +214,30 @@ $(document).ready(function() {
|
|
|
const seasonId = $('#season').val();
|
|
|
const categoryId = $('#category').val();
|
|
|
const groupId = $('#group').val();
|
|
|
+ const type = $('#type').val();
|
|
|
|
|
|
- const selectedCategory = categories.find(c => c.id === parseInt(categoryId));
|
|
|
- if (selectedCategory) {
|
|
|
- const selectedGroup = groupId ? groups.find(g => g.id === parseInt(groupId)) : null;
|
|
|
-
|
|
|
- let urlName = selectedCategory.name;
|
|
|
- if (selectedGroup) {
|
|
|
- urlName += `-${selectedGroup.name}`;
|
|
|
- }
|
|
|
+ const calendar = archivedCalendars.find(cal =>
|
|
|
+ cal.season_id === parseInt(seasonId) &&
|
|
|
+ cal.category_id === parseInt(categoryId) &&
|
|
|
+ (!groupId || cal.group_id === parseInt(groupId)) &&
|
|
|
+ cal.category?.type === type
|
|
|
+ );
|
|
|
|
|
|
- const calendarId = groupId || categoryId;
|
|
|
- const url = `/calendario/${urlName}/${calendarId}`;
|
|
|
+ if (calendar) {
|
|
|
+ const categorySlug = calendar.category.name.toLowerCase()
|
|
|
+ .normalize('NFD')
|
|
|
+ .replace(/[\u0300-\u036f]/g, '')
|
|
|
+ .replace(/[^\w\s-]/g, '')
|
|
|
+ .replace(/\s+/g, '-');
|
|
|
+
|
|
|
+ const groupSlug = calendar.group ? calendar.group.name.toLowerCase()
|
|
|
+ .normalize('NFD')
|
|
|
+ .replace(/[\u0300-\u036f]/g, '')
|
|
|
+ .replace(/[^\w\s-]/g, '')
|
|
|
+ .replace(/\s+/g, '-')
|
|
|
+ : '';
|
|
|
+
|
|
|
+ const url = `/calendario/${categorySlug}-${groupSlug}/${calendar.id}`;
|
|
|
window.location.href = url;
|
|
|
}
|
|
|
});
|