Skip to content

Commit 7376b0c

Browse files
nothing special
1 parent 675adc6 commit 7376b0c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/app/admin/_components/add-post/add-post.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@
88
<div>Title is required.</div>
99
}
1010
}
11+
<<<<<<< HEAD
1112
<button class="btn btn--secondary" type="button" (click)="insertImage()">Insert Image</button>
1213
<quill-editor #quill formControlName="content" class="h-screen w-full"></quill-editor>
1314
<div class="mt-12 btn--group">
1415
<button class="btn btn--primary" type="submit">Submit</button>
1516
<button class="btn btn--secondary" type="button" (click)="onSubmit(true)">Save as a draft</button>
1617
</div>
18+
=======
19+
20+
21+
<button type="submit" [disabled]="blogForm.invalid">Submit</button>
22+
>>>>>>> ab739b9 (nothing special)
1723
</form>
1824
}

src/app/admin/_components/add-post/add-post.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
import {
23
ChangeDetectionStrategy,
34
Component,
@@ -30,10 +31,19 @@ import { DynamicDialogService } from '../../../shared/dynamic-dialog/dynamic-dia
3031
import { ModalConfig } from '../../../shared/_models/modal-config.intreface';
3132
import { AddImageComponent } from './add-image/add-image.component';
3233
import { AddImageForm } from './add-image/add-image-controls.interface';
34+
=======
35+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
36+
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
37+
import { ApiService } from '../../_services/api.service';
38+
import { Firestore, FirestoreModule} from '@angular/fire/firestore';
39+
import { HttpClient } from '@angular/common/http';
40+
import { AsyncPipe } from '@angular/common';
41+
>>>>>>> ab739b9 (nothing special)
3342

3443
@Component({
3544
selector: 'blog-add-post',
3645
standalone: true,
46+
<<<<<<< HEAD
3747
imports: [
3848
ReactiveFormsModule,
3949
FirestoreModule,
@@ -43,6 +53,10 @@ import { AddImageForm } from './add-image/add-image-controls.interface';
4353
RouterModule,
4454
],
4555
providers: [AdminApiService, NgModel],
56+
=======
57+
imports: [ReactiveFormsModule, FirestoreModule, AsyncPipe],
58+
providers: [ApiService, HttpClient],
59+
>>>>>>> ab739b9 (nothing special)
4660
templateUrl: './add-post.component.html',
4761
styleUrl: './add-post.component.scss',
4862
schemas: [CUSTOM_ELEMENTS_SCHEMA],
@@ -65,10 +79,14 @@ export class AddPostComponent implements OnInit {
6579
this.blogForm = this.fb.group({
6680
title: ['', [Validators.required]],
6781
content: ['', [Validators.required]],
82+
<<<<<<< HEAD
6883
date: new Timestamp(0, 0),
6984
description: [null],
7085
isDraft: [false],
7186
}) as FormGroup<PostForm>;
87+
=======
88+
});
89+
>>>>>>> ab739b9 (nothing special)
7290
}
7391

7492
ngOnInit(): void {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import { Injectable, inject } from '@angular/core';
3+
import { Firestore, collection, collectionData, doc, setDoc } from '@angular/fire/firestore';
4+
import { Blog } from '../../shared/_models/blog.interface';
5+
import { Observable } from 'rxjs';
6+
7+
@Injectable()
8+
export class ApiService {
9+
firestore = inject(Firestore);
10+
http = inject(HttpClient);
11+
12+
addBlog(blog: Blog) {
13+
const newTaskRef = doc(collection(this.firestore, 'blog'));
14+
setDoc(newTaskRef, blog).finally(() => {
15+
console.log('Document written with ID: ', newTaskRef.id);
16+
});
17+
}
18+
}

0 commit comments

Comments
 (0)