feat: Ajout de React pour le front, début de refonte du front

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-02-12 16:12:01 +01:00
parent 73774f84ff
commit 666636e5bf
35 changed files with 2863 additions and 164 deletions

View File

@@ -0,0 +1,10 @@
export class Chapter {
constructor(id, number, title, volume, isVisible, createdAt) {
this.id = id;
this.number = number;
this.title = title;
this.volume = volume;
this.isVisible = isVisible;
this.createdAt = createdAt;
}
}

View File

@@ -0,0 +1,75 @@
import { Chapter } from './chapter.js';
export class Manga {
constructor(
id,
title,
slug,
imageUrl,
author,
publicationYear,
genres,
status,
rating,
description = ''
) {
this.id = id;
this.title = title;
this.slug = slug;
this.imageUrl = imageUrl;
this.author = author;
this.publicationYear = publicationYear;
this.genres = genres;
this.status = status;
this.rating = rating;
this.description = description;
}
}
export class MangaCollection {
constructor(items, total, page, limit, hasNextPage, hasPreviousPage) {
this.items = items;
this.total = total;
this.page = page;
this.limit = limit;
this.hasNextPage = hasNextPage;
this.hasPreviousPage = hasPreviousPage;
}
}
export class MangaDetail extends Manga {
constructor(manga, chapters = []) {
super(
manga.id,
manga.title,
manga.slug,
manga.imageUrl,
manga.author,
manga.publicationYear,
manga.genres,
manga.status,
manga.rating,
manga.description
);
this.chapters = this.organizeChaptersByVolume(chapters);
}
organizeChaptersByVolume(chapters) {
const volumeMap = new Map();
chapters.forEach(chapter => {
const volume = chapter.volume || 0;
if (!volumeMap.has(volume)) {
volumeMap.set(volume, []);
}
volumeMap.get(volume).push(chapter);
});
// Sort chapters within each volume
volumeMap.forEach(chapters => {
chapters.sort((a, b) => b.number - a.number);
});
return new Map([...volumeMap.entries()].sort((a, b) => b[0] - a[0]));
}
}

View File

@@ -0,0 +1,6 @@
// Port (interface) for manga data access
export class MangaRepository {
async getMangaCollection(page = 1) {
throw new Error('Not implemented');
}
}