home page

This commit is contained in:
Betteloni 2024-10-23 18:48:28 -03:00
parent dd1b2763d8
commit 5608fa4184
18 changed files with 546 additions and 103 deletions

View file

@ -1,36 +1,14 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { delay, map } from 'rxjs/operators';
import { Apollo } from 'apollo-angular';
import { FIND_UNIQUE_BANNER, LIST_BANNERS } from './graphql/queries';
import { Banner } from './banner.model';
import { CREATE_BANNER, UPDATE_BANNER } from './graphql/mutations';
const TOTAL_PAGES = 7;
export class NewsPost {
title: string;
link: string;
creator: string;
text: string;
}
@Injectable()
export class BannerService {
constructor(private http: HttpClient, private readonly apollo: Apollo) {}
load(page: number, pageSize: number): Observable<NewsPost[]> {
const startIndex = ((page - 1) % TOTAL_PAGES) * pageSize;
return this.http
.get<NewsPost[]>('assets/data/news.json')
.pipe(
map(news => news.splice(startIndex, pageSize)),
delay(1500),
);
}
constructor(private readonly apollo: Apollo) {}
listBanners(): Observable<any> {
return this.apollo