@@ -25,71 +25,19 @@ export class PostService {
2525 ) ;
2626 }
2727
28+ searchPosts ( page : number , size : number , search ?: string | null ) {
29+ return this . api . get < ApiResponse < IPaginationResponse < PostResponse [ ] > > > (
30+ API_CONFIG . ENDPOINTS . GET . SEARCH_POST ( page , size , search ) ,
31+ true
32+ ) ;
33+ }
34+
2835 getPostDetails ( id : string ) {
2936 return this . api . get < ApiResponse < PostResponse > > (
3037 API_CONFIG . ENDPOINTS . GET . GET_POST_DETAILS ( id )
3138 ) ;
3239 }
3340
34- //deprecated
35- // addPost(data: CreatePostRequest) {
36- // const formData = new FormData();
37-
38- // // Helper append (chỉ thêm nếu có giá trị thật sự)
39- // const safeAppend = (key: string, value: any) => {
40- // if (
41- // value !== undefined &&
42- // value !== null &&
43- // !(typeof value === 'string' && value.trim() === '')
44- // ) {
45- // formData.append(key, value);
46- // }
47- // };
48-
49- // // basic fields
50- // safeAppend('title', data.title);
51- // safeAppend('orgId', data.orgId);
52- // safeAppend('content', data.content);
53- // safeAppend('isPublic', String(data.isPublic));
54- // safeAppend('allowComment', String(data.allowComment));
55- // safeAppend('postType', data.postType);
56- // safeAppend('hashtag', data.hashtag);
57-
58- // // array fields
59- // safeAppend(`oldImgesUrls`, data.oldImgesUrls);
60-
61- // // optional status
62- // safeAppend('status', data.status);
63-
64- // // fileDocument
65- // if (data.fileDocument) {
66- // const fd = data.fileDocument;
67- // safeAppend('fileDocument.file', fd.file);
68- // safeAppend('fileDocument.category', fd.category);
69- // safeAppend('fileDocument.description', fd.description);
70- // fd.tags?.forEach((tag, i) => safeAppend(`fileDocument.tags[${i}]`, tag));
71- // if (typeof fd.isLectureVideo === 'boolean') {
72- // safeAppend('fileDocument.isLectureVideo', String(fd.isLectureVideo));
73- // }
74- // if (typeof fd.isTextBook === 'boolean') {
75- // safeAppend('fileDocument.isTextBook', String(fd.isTextBook));
76- // }
77- // safeAppend('fileDocument.orgId', fd.orgId);
78- // }
79-
80- // // Debug log
81- // for (const [key, val] of formData.entries()) {
82- // console.log(key, val);
83- // }
84-
85- // // Gửi form-data (KHÔNG ép Content-Type)
86- // return this.api.post<NhatApiResponeNoData>(
87- // API_CONFIG.ENDPOINTS.POST.ADD_POST,
88- // formData,
89- // true
90- // );
91- // }
92-
9341 //sử dụng postWithFormData
9442 createPost ( data : CreatePostRequest ) {
9543 const { fileDocument, ...otherData } = data ;
0 commit comments