Skip to content

Commit 9149095

Browse files
committed
chore(fe/fetch): change hook to service
1 parent 6ae7578 commit 9149095

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

spez-frontend/src/app/page.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// "use client"
2-
import { useEffect } from 'react';
32
// import { useRouter } from 'next/navigation';
43
import NewsFeed from '@/components/NewsFeed';
54
export default function Home() {

spez-frontend/src/app/post/[id]/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use client"
2-
import usePost from "@/hooks/usePost";
2+
import svPost from "@/utils/svPost";
33
import Link from "next/link";
44
import Comment from "@/components/Comment";
55
import Parser from 'html-react-parser'
@@ -14,7 +14,7 @@ type Props = {
1414
};
1515
export default async function Post({ params }: Props) {
1616
const id: string = params.id;
17-
const { getPost, getLike, getComment, delPost } = await usePost();
17+
const { getPost, getLike, getComment, delPost } = svPost();
1818

1919
const info: any = await getPost(id);
2020
const likes: any = await getLike(id);

spez-frontend/src/app/user/[id]/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import useUser from "@/hooks/useUser";
2+
import useUser from "@/utils/svUser";
33
import ImageUploader from "@/components/ImgUpload";
44
import ImageFromBase64 from "@/components/DisplayImg";
55
type Props = {

spez-frontend/src/components/Comment.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getRelativeTime } from "@/utils/getRelativeTime";
22
import Link from "next/link";
33
import Parser from "html-react-parser";
4-
import usePost from "@/hooks/usePost";
4+
import svPost from "@/utils/svPost";
55
import { GoTrash } from "react-icons/go";
66
type Prop = {
77
id: string;
@@ -12,7 +12,7 @@ type Prop = {
1212

1313
export default async function Comment({ id, author, content, date }: Prop) {
1414
const usr_url = "/user/" + author.id;
15-
const { delComment } = await usePost();
15+
const { delComment } = await svPost();
1616
const handleDelCmt = async (e: any) => {
1717
let token: any;
1818
if (typeof window !== "undefined") token = localStorage.getItem("jwt");

spez-frontend/src/components/ImgUpload.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22
import React, { useState } from "react";
3-
import useUser from "@/hooks/useUser";
3+
import useUser from "@/utils/svUser";
44
interface ImgUploadProps {
55
userId: string;
66
}

spez-frontend/src/components/NewsFeed.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import usePost from "@/hooks/usePost"
1+
import svPost from "@/utils/svPost"
22
import Post from "./Post";
33

44
export default async function NewsFeed() {
5-
const {getAllPost} = await usePost();
5+
const {getAllPost} = svPost();
66
const AllPost = await getAllPost();
77
// console.log(AllPost)
88
return (

spez-frontend/src/components/Post.tsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
import Link from "next/link";
2-
import Parser from 'html-react-parser'
2+
import Parser from "html-react-parser";
33
import { getRelativeTime } from "@/utils/getRelativeTime";
4-
type Props = {
4+
type PostProps = {
55
id: string;
66
title: string;
77
content: string;
88
author: any;
99
date: string;
1010
};
11-
export default function Post({ id, title, content, author, date }: Props) {
11+
const Post: React.FC<PostProps> = ({ id, title, content, author, date }) => {
1212
const author_url = "/user/" + author.id;
1313
const post_url = "/post/" + id;
1414
return (
1515
<div className="text-black p-2 border-2 border-slate-950 rounded w-1/2 shadow h-[17rem] overflow-hidden">
1616
<div className="pl-10">
17-
<Link href={author_url} className="font-semibold "> {author.username}</Link>
18-
{" "}
19-
<a className="text-sm">
20-
{getRelativeTime(date) }
21-
</a>
17+
<Link href={author_url} className="font-semibold ">
18+
{" "}
19+
{author.username}
20+
</Link>
21+
{" "}
22+
<a className="text-sm">{getRelativeTime(date)}</a>
2223
</div>
2324
<div className="pl-2 text-2xl font-bold">
2425
<Link href={post_url}>{title}</Link>
2526
</div>
2627
<div className="p-2">{Parser(content)}</div>
27-
<div>
28-
</div>
28+
<div></div>
2929
</div>
3030
);
31-
}
31+
};
32+
export default Post;

spez-frontend/src/hooks/usePost.ts spez-frontend/src/utils/svPost.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BE_URI } from "@/utils/constants";
22
import axios from "axios";
3-
export default function usePost() {
3+
export default function svPost() {
44
let token: any;
55
if (typeof window !== "undefined") token = localStorage.getItem("jwt");
66
console.log(token);

spez-frontend/src/hooks/useUser.ts spez-frontend/src/utils/svUser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BE_URI } from "@/utils/constants";
22
import axios from "axios";
33

4-
export default function useUser() {
4+
export default function svUser() {
55
const API: any = {
66
usr: BE_URI + "/users/",
77
// useprofile: BE_URI +

0 commit comments

Comments
 (0)