Skip to content

Commit

Permalink
merge dev - patch-user
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoP-ribeiro committed May 14, 2024
1 parent 1c5c308 commit d7d7e57
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/api/hooks/user/queries.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ContentComment, ContentNews, News } from "@/api/types/news/type";
import api from "@/services/api";
import { title } from "process";
import {
QueryFunctionContext,
useMutation,
useQuery,
useQueryClient,
} from "@tanstack/react-query";
import { title } from "process";
import toast from "react-hot-toast";
import { ContentComment, ContentNews, News } from "@/api/types/news/type";
import api from "@/services/api";
import { getIdNews } from "../news/queries";

// News
Expand Down
2 changes: 1 addition & 1 deletion src/api/types/all/type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { title } from "process";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { ReadonlyURLSearchParams } from "next/navigation";
import { title } from "process";

export interface Error {
text: string;
Expand Down
2 changes: 1 addition & 1 deletion src/app/user/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useSearchParams } from "next/navigation";
import NavBar from "@/components/base/common/NavBar";
import TopBanner from "@/components/base/common/TopBanner";
import {
Expand All @@ -12,7 +13,6 @@ import { LinkFilterNewsUser } from "@/components/base/user/LinkFilterNewsUser";
import { RoleGuard } from "@/components/base/common/RoleGuard";
import { appRoles } from "@/lib/sso/authConfig";
import { CommentsUserList } from "@/components/base/user/CommentsUserList";
import { useSearchParams } from "next/navigation";

export default function User() {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/base/common/Comment.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FaTrashCan } from "react-icons/fa6";
import { CommentType } from "@/api/types/news/type";
import { cn } from "@/lib/utils";
import LikeUpvote from "../news/LikeUpvote";
import { MarkdownRenderer } from "./MarkdownRenderer";
import { cn } from "@/lib/utils";
import { FaTrashCan } from "react-icons/fa6";
import { AlertArchiveComment } from "../user/AlertArchiveComment";

interface CommentProps {
Expand Down
14 changes: 7 additions & 7 deletions src/components/base/common/FormNewsLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Button } from "@/components/ui/button";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import z from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
Expand All @@ -9,8 +12,6 @@ import {
DialogTrigger,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import InputTextEdit from "./InputTextEdit";
import ImageButton from "../news/ImageButton";
import {
Form,
FormControl,
Expand All @@ -19,12 +20,11 @@ import {
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { useForm } from "react-hook-form";
import { newsSchema } from "@/types/schemas/newsShema";
import z from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import InputTags from "./InputTags";
import { FormType } from "@/api/types/all/type";
import InputTextEdit from "./InputTextEdit";
import ImageButton from "../news/ImageButton";
import InputTags from "./InputTags";
import { AlertUpdateNews } from "../user/AlertUpdateNews";

interface ModalCreateNewsProps {
Expand Down
1 change: 0 additions & 1 deletion src/components/base/common/InputTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const InputTags: ForwardRefRenderFunction<HTMLInputElement, InputTagsProps> = (
<div>
<div className="w-full flex flex-row gap-3">
<Input
ref={ref}
ref={ref}
placeholder="Search your tags..."
maxLength={35}
Expand Down
5 changes: 4 additions & 1 deletion src/components/base/news/CommentList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useFetchGetCommentNewsId } from "@/api/hooks/news/queries";
import Comment from "../common/Comment";
import ImageError from "../common/ImageError";
import CommentSkeleton from "../skeleton/CommentSkeleton";
Expand All @@ -12,7 +13,9 @@ export default function CommentList({ id }: CommentListProps) {
const commentCards = () => {
return data?.length !== 0 ? (
<div className="flex flex-col gap-5 max-h-96 overflow-y-scroll">
{data?.map((comment) => <Comment key={comment.id} variant="anyComment" data={comment} />)}
{data?.map((comment) => (
<Comment key={comment.id} variant="anyComment" data={comment} />
))}
</div>
) : (
<div className="flex justify-center items-center w-full h-80">
Expand Down
4 changes: 2 additions & 2 deletions src/components/base/news/FormAddNews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import { z } from "zod";
import { useState } from "react";
import { useMutationPostNews } from "@/api/hooks/news/queries";
import { FormNewsLayout } from "../common/FormNewsLayout";
import { msalInstance } from "@/lib/sso/msalInstance";
import { newsSchema } from "@/types/schemas/newsShema";
import { AlertAddNews } from "./AlertAddNews";
import { resizeFile } from "@/lib/utils";
import { AlertAddNews } from "./AlertAddNews";
import { FormNewsLayout } from "../common/FormNewsLayout";

export function FormAddNews() {
const [open, setOpen] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/user/AlertArchiveComment.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useQueryClient } from "@tanstack/react-query";
import {
getUserComments,
useMutationPatchDelete,
} from "@/api/hooks/user/queries";
import AlertLayout from "../common/AlertLayout";
import { useQueryClient } from "@tanstack/react-query";

interface AlertDeleteCommentProps {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/user/AlertArchiveNews.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQueryClient } from "@tanstack/react-query";
import { getUserNews, useMutationPatchArchive } from "@/api/hooks/user/queries";
import AlertLayout from "../common/AlertLayout";
import { useQueryClient } from "@tanstack/react-query";

interface AlertDeleteNewsProps {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/user/AlertPublishNews.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQueryClient } from "@tanstack/react-query";
import { getUserNews, useMutationPatchPublish } from "@/api/hooks/user/queries";
import AlertLayout from "../common/AlertLayout";
import { useQueryClient } from "@tanstack/react-query";

interface AlertDeleteNewsProps {
id: string;
Expand Down
10 changes: 5 additions & 5 deletions src/components/base/user/CommentsUserList.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use client";
import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { useFetchGetUserComments } from "@/api/hooks/user/queries";
import CommentSkeleton from "../skeleton/CommentSkeleton";
import {
Carousel,
CarouselContent,
CarouselPrevious,
CarouselNext,
CarouselPrevious,
} from "@/components/ui/carousel";
import { Error } from "@/api/types/all/type";
import CommentSkeleton from "../skeleton/CommentSkeleton";
import ImageError from "../common/ImageError";
import Comment from "../common/Comment";
import { Error } from "@/api/types/all/type";
import { useSearchParams } from "next/navigation";
import { useState, useEffect } from "react";

export interface CommentsUserListProps {
messageError: Error;
Expand Down
8 changes: 4 additions & 4 deletions src/components/base/user/FormUpdateNews.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useState } from "react";
import { z } from "zod";
import { getIdNews, useFetchGetNewsId } from "@/api/hooks/news/queries";
import { msalInstance } from "@/lib/sso/msalInstance";
import { newsSchema } from "@/types/schemas/newsShema";
import { useState } from "react";
import { z } from "zod";
import { FormNewsLayout } from "../common/FormNewsLayout";
import { getUserNews, useMutationPatchNews } from "@/api/hooks/user/queries";
import { AlertUpdateNews } from "./AlertUpdateNews";
import { queryClient } from "@/services/queryClient";
import { resizeFile } from "@/lib/utils";
import { FormNewsLayout } from "../common/FormNewsLayout";
import { AlertUpdateNews } from "./AlertUpdateNews";

interface FormNewsLayoutProps {
id: string;
Expand Down
6 changes: 2 additions & 4 deletions src/components/base/user/LinkFilterNewsUser.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
"use client";

import { Button } from "@/components/ui/button";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import { Button } from "@/components/ui/button";

export function LinkFilterNewsUser() {
const searchParams = useSearchParams();


const filterNews = searchParams.get("news")
const status = filterNews ? filterNews : 'published'
const [nameButton, setNameButton] = useState('Error');

useEffect(() => {

if(status === "published"){
setNameButton('archived')
}
else if(status === "archived"){
setNameButton('published')
}

}, [searchParams]);
}, [searchParams, status]);


return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/base/user/MenuPopoverEditNews.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IoMenu } from "react-icons/io5";
import { Button } from "@/components/ui/button";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { FormUpdateNews } from "./FormUpdateNews";
import { IoMenu } from "react-icons/io5";
import { AlertArchiveNews } from "./AlertArchiveNews";
import { AlertPublishedNews } from "./AlertPublishNews";

Expand Down

0 comments on commit d7d7e57

Please sign in to comment.