Loading...
) : isError ? (Error: {error.message}
diff --git a/src/components/Common/Button.tsx b/src/components/Common/Button.tsx index 752da10..452ede0 100644 --- a/src/components/Common/Button.tsx +++ b/src/components/Common/Button.tsx @@ -1,5 +1,6 @@ -import { type Ref, type ButtonHTMLAttributes, forwardRef } from 'react'; -import { Button as ButtonUI } from 'lib/shadcn/components/ui/button'; +import { type ButtonHTMLAttributes, forwardRef, type Ref } from 'react'; + +import { Button as ButtonUI } from '@/components/ui/button'; interface ButtonProperties extends ButtonHTMLAttributes- {children} -
- ); -} diff --git a/src/components/Common/form/Input.tsx b/src/components/Common/form/Input.tsx index 57fcef0..481839a 100644 --- a/src/components/Common/form/Input.tsx +++ b/src/components/Common/form/Input.tsx @@ -1,5 +1,4 @@ -import { forwardRef } from 'react'; -import type { Ref, InputHTMLAttributes } from 'react'; +import { forwardRef, type InputHTMLAttributes, type Ref } from 'react'; interface InputProperties extends InputHTMLAttributes+ {children} +
+ ); +} diff --git a/src/components/Common/form/index.ts b/src/components/Common/form/index.ts index 713c116..32d1b97 100644 --- a/src/components/Common/form/index.ts +++ b/src/components/Common/form/index.ts @@ -1,4 +1,4 @@ -export { default as FormAlert } from './FormAlert'; -export { default as Input } from './Input'; -export { default as Textarea } from './Textarea'; -export { default as Title } from './Title'; +export { default as FormAlert } from './form-alert'; +export { default as Input } from './input'; +export { default as Textarea } from './text-area'; +export { default as Title } from './title'; diff --git a/src/components/Common/form/text-area.tsx b/src/components/Common/form/text-area.tsx new file mode 100644 index 0000000..c3fe2f0 --- /dev/null +++ b/src/components/Common/form/text-area.tsx @@ -0,0 +1,33 @@ +import { forwardRef, type Ref, type TextareaHTMLAttributes } from 'react'; + +interface TextareaProperties extends TextareaHTMLAttributesLoading...
) : isError ? (Error: {error.message}
diff --git a/src/libraries/shadcn/components/ui/button.tsx b/src/components/ui/button.tsx similarity index 97% rename from src/libraries/shadcn/components/ui/button.tsx rename to src/components/ui/button.tsx index 799c447..6821cc5 100644 --- a/src/libraries/shadcn/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -1,9 +1,9 @@ -import { forwardRef } from 'react'; import { Slot } from '@radix-ui/react-slot'; import { cva, type VariantProps } from 'class-variance-authority'; -import { cn } from '../../utils'; - import type { ButtonHTMLAttributes } from 'react'; +import { forwardRef } from 'react'; + +import { cn } from '../../utils/utils'; const buttonVariants = cva( 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-slate-400 disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-slate-800', @@ -25,7 +25,7 @@ const buttonVariants = cva( default: 'h-9 px-4 py-2', sm: 'h-8 rounded-md px-3 text-xs', lg: 'h-10 rounded-md px-8', - icon: 'h-9 w-9', + icon: 'size-9', }, }, defaultVariants: { diff --git a/src/libraries/shadcn/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx similarity index 94% rename from src/libraries/shadcn/components/ui/dropdown-menu.tsx rename to src/components/ui/dropdown-menu.tsx index 4fbb27e..4f99c3b 100644 --- a/src/libraries/shadcn/components/ui/dropdown-menu.tsx +++ b/src/components/ui/dropdown-menu.tsx @@ -1,10 +1,9 @@ -import { forwardRef } from 'react'; import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; import { CheckIcon, ChevronRightIcon, DotFilledIcon } from '@radix-ui/react-icons'; +import type { ComponentPropsWithoutRef, ElementRef, HTMLAttributes } from 'react'; +import { forwardRef } from 'react'; -import { cn } from '../../utils'; - -import type { ElementRef, ComponentPropsWithoutRef, HTMLAttributes } from 'react'; +import { cn } from '../../utils/utils'; const DropdownMenu = DropdownMenuPrimitive.Root; const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; @@ -29,7 +28,7 @@ const DropdownMenuSubTrigger = forwardRef< {...properties} > {children} -Loading...
) : isError ? (Error: {error.message}
@@ -69,21 +77,13 @@ export default function Home(): JSX.Element {Posts is undefined
) : (Background Updating...
: undefined} diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index 5fbc397..6149d54 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,25 +1,27 @@ -import { useEffect } from 'react'; +import { useCallback, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import useAuthStore from '../stores/AuthStore'; -import useFetch from '../hooks/useFetch'; -import LoginForm from 'comp/forms/auth/LoginForm'; - -import type { FormInputs } from 'comp/forms/auth/LoginForm'; -import type { JwtToken } from 'types'; +import type { FormInputs } from '@/components/forms/auth/login-form'; +import LoginForm from '@/components/forms/auth/login-form'; +import useFetch from '@/hooks/use-fetch'; +import useAuthStore from '@/stores/auth-store'; +import type { JwtToken } from '@/types'; interface ServerResponse extends JwtToken { token: string; } -export default function Login(): JSX.Element { +export default function Login() { const login = useAuthStore((state) => state.login); const { response, error, isLoading, isError, isSuccess, fetch } = useFetchLoading...
} {isError &&{error.message}
} {isSuccess &&Submit successful.
} > diff --git a/src/pages/Post/ViewPost.tsx b/src/pages/post/view-post.tsx similarity index 81% rename from src/pages/Post/ViewPost.tsx rename to src/pages/post/view-post.tsx index 99b1e1a..4cd2fa1 100644 --- a/src/pages/Post/ViewPost.tsx +++ b/src/pages/post/view-post.tsx @@ -1,14 +1,12 @@ -import { useNavigate, useParams } from 'react-router-dom'; -import axios from 'axios'; import { useQuery } from '@tanstack/react-query'; +import axios from 'axios'; +import { useNavigate, useParams } from 'react-router-dom'; +import Comments from 'src/components/comments'; -import Button from 'comp/common/Button'; -import Comments from 'comp/Comments'; - -import type { UseQueryResult } from '@tanstack/react-query'; -import type { PostResponse } from 'types'; +import Button from '@/components/common/button'; +import type { PostResponse } from '@/types'; -export default function ViewPost(): JSX.Element { +export default function ViewPost() { const { id } = useParams(); const navigate = useNavigate(); @@ -17,10 +15,10 @@ export default function ViewPost(): JSX.Element { const { data: post, - isLoading, + isPending, isError, error, - }: UseQueryResultLoading...
) : isError ? (Error: {error.message}
diff --git a/src/pages/User/ViewUser.tsx b/src/pages/user/view-user.tsx similarity index 80% rename from src/pages/User/ViewUser.tsx rename to src/pages/user/view-user.tsx index 011801f..a29cb8e 100644 --- a/src/pages/User/ViewUser.tsx +++ b/src/pages/user/view-user.tsx @@ -1,13 +1,11 @@ -import { useNavigate, useParams } from 'react-router-dom'; -import axios from 'axios'; import { useQuery } from '@tanstack/react-query'; +import axios from 'axios'; +import { useNavigate, useParams } from 'react-router-dom'; -import Button from 'comp/common/Button'; - -import type { UseQueryResult } from '@tanstack/react-query'; -import type { User } from 'types'; +import Button from '@/components/common/button'; +import type { User } from '@/types'; -export default function ViewUser(): JSX.Element { +export default function ViewUser() { const { id } = useParams(); const navigate = useNavigate(); @@ -15,10 +13,10 @@ export default function ViewUser(): JSX.Element { const { data: u, - isLoading, + isPending, isError, error, - }: UseQueryResultLoading...
) : isError ? (Error: {error.message}
diff --git a/src/router.tsx b/src/router.tsx index c2b91a1..c62c795 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -1,10 +1,10 @@ -import { Routes, Route } from 'react-router-dom'; +import { Route, Routes } from 'react-router-dom'; -import Login from './pages/Login'; -import Home from './pages/Home'; -import ViewPost from './pages/post/ViewPost'; -import ViewUser from './pages/user/ViewUser'; -import AddPost from './pages/post/AddPost'; +import Home from './pages/home'; +import Login from './pages/login'; +import AddPost from './pages/post/add-post'; +import ViewPost from './pages/post/view-post'; +import ViewUser from './pages/user/view-user'; export default function Router(): JSX.Element { return ( diff --git a/src/stores/AuthStore.tsx b/src/stores/auth-store.tsx similarity index 87% rename from src/stores/AuthStore.tsx rename to src/stores/auth-store.tsx index 5089532..9e96b84 100644 --- a/src/stores/AuthStore.tsx +++ b/src/stores/auth-store.tsx @@ -1,8 +1,8 @@ -import { create } from 'zustand'; import Cookies from 'js-cookie'; -import jwtDecode from 'jwt-decode'; +import { jwtDecode } from 'jwt-decode'; +import { create } from 'zustand'; -import type { JwtToken } from 'types'; +import type { JwtToken } from '@/types'; interface AuthStore { user: JwtToken | undefined; @@ -12,7 +12,7 @@ interface AuthStore { const defaultUser: () => JwtToken | undefined = () => { const token = Cookies.get('token'); - if (token !== undefined) { + if (token) { return jwtDecode(token); } }; diff --git a/src/types/Comment.d.ts b/src/types/comment.ts similarity index 100% rename from src/types/Comment.d.ts rename to src/types/comment.ts diff --git a/src/types/DummyResponse.d.ts b/src/types/dummy-response.ts similarity index 100% rename from src/types/DummyResponse.d.ts rename to src/types/dummy-response.ts diff --git a/src/types/index.ts b/src/types/index.ts index 7994a54..cb72001 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,6 +1,6 @@ -export type { DummyResponse } from './DummyResponse'; -export type { Response as PostResponse } from './Post'; -export type { Request as PostRequest } from './Post'; -export type { Comment } from './Comment'; -export type { User } from './User'; -export type { JwtToken } from './JwtToken'; +export type { Comment } from './comment'; +export type { DummyResponse } from './dummy-response'; +export type { JwtToken } from './jwt-token'; +export type { Response as PostResponse } from './post'; +export type { Request as PostRequest } from './post'; +export type { User } from './user'; diff --git a/src/types/JwtToken.d.ts b/src/types/jwt-token.ts similarity index 100% rename from src/types/JwtToken.d.ts rename to src/types/jwt-token.ts diff --git a/src/types/other/Company.d.ts b/src/types/other/company.ts similarity index 65% rename from src/types/other/Company.d.ts rename to src/types/other/company.ts index 7628b77..d100e84 100644 --- a/src/types/other/Company.d.ts +++ b/src/types/other/company.ts @@ -1,4 +1,4 @@ -import type { PhysicalAddress } from './PhysicalAddress'; +import type { PhysicalAddress } from './physical-address'; export interface Company { address: PhysicalAddress; diff --git a/src/types/other/PhysicalAddress.d.ts b/src/types/other/physical-address.ts similarity index 100% rename from src/types/other/PhysicalAddress.d.ts rename to src/types/other/physical-address.ts diff --git a/src/types/Post.d.ts b/src/types/post.ts similarity index 100% rename from src/types/Post.d.ts rename to src/types/post.ts diff --git a/src/types/User.d.ts b/src/types/user.ts similarity index 86% rename from src/types/User.d.ts rename to src/types/user.ts index 0c5dd9f..af60b7a 100644 --- a/src/types/User.d.ts +++ b/src/types/user.ts @@ -1,5 +1,5 @@ -import type { PhysicalAddress } from './other/PhysicalAddress'; -import type { Company } from './other/Company'; +import type { Company } from './other/company'; +import type { PhysicalAddress } from './other/physical-address'; // Damn. Whyyy so much info? export interface User { diff --git a/src/libraries/shadcn/utils.ts b/src/utils/utils.ts similarity index 100% rename from src/libraries/shadcn/utils.ts rename to src/utils/utils.ts