feat: Ajout de React pour le front, début de refonte du front
This commit is contained in:
parent
73774f84ff
commit
666636e5bf
10
assets/react/app/domain/chapter.js
Normal file
10
assets/react/app/domain/chapter.js
Normal 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;
|
||||
}
|
||||
}
|
||||
75
assets/react/app/domain/manga.js
Normal file
75
assets/react/app/domain/manga.js
Normal 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]));
|
||||
}
|
||||
}
|
||||
6
assets/react/app/domain/ports/mangaRepository.js
Normal file
6
assets/react/app/domain/ports/mangaRepository.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Port (interface) for manga data access
|
||||
export class MangaRepository {
|
||||
async getMangaCollection(page = 1) {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user