Bruno Predot

Ajout model + interface MovieComment.

import type { MovieInterface } from "~/interfaces/movie";
export interface MovieCommentInterface {
username: string;
message: string;
rating: number;
movie_id: unknown;
movie: MovieInterface;
}
... ...
import { Model } from "pinia-orm";
import { Movie } from "~/models/movie";
export class MovieComment extends Model {
/**
*
* @return {string}
*/
static get entity() {
return "MovieComment";
}
/**
*
* @return {string}
*/
static get primaryKey() {
return "id";
}
static fields() {
return {
// Attributs.
id: this.number(null),
username: this.string(''),
message: this.string(''),
rating: this.string(''),
// Relations.
movie_id: this.attr(null),
movie: this.belongsTo(Movie, "movie_id", "id"),
};
}
static piniaOptions = {
persist: true,
};
}
... ...
... ... @@ -105,6 +105,7 @@ async function fetchCredits(id: number | string) {
}
function handleSubmitEvent(event: Comment) {
//todo : faire la gestion des commentaire avec un nouveau model + liaison.
console.log('submitted', event)
}
... ... @@ -183,6 +184,7 @@ onMounted(() => {
</div>
</div>
<!-- Comments form. -->
<h3 class="text-xl font-bold mt-8 mb-4">Ajouter un commentaire</h3>
<form-movie-comment-form @event:submit="handleSubmitEvent" />
</section>
</div>
... ...