Skip to content

Commit 8c85947

Browse files
committed
chore: organize components
1 parent e85b2fd commit 8c85947

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

src/app/(ui)/(protected)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useRouter } from "next/navigation";
66
import TopHeader from "@/components/top-header";
77
import { useGetProfile } from "@/hooks/user/user.hooks";
88
import { BoxLoader } from "@/components/loader";
9-
import ChangePassword from "@/components/change-password";
9+
import ChangePassword from "@/components/user/change-password";
1010

1111
export default function ProtectedLayout({ children }: { children: React.ReactNode }) {
1212
const [checking, setChecking] = useState(true);

src/app/(ui)/(protected)/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { BoxLoader } from "@/components/loader";
44
import PageHeader from "@/components/page-header";
55
import Proxies from "@/components/proxies/proxies";
6+
import ProxiesActions from "@/components/proxies/proxies-actions";
67
import { Separator } from "@/components/ui/separator";
78
import { useGetRegisteredDomains } from "@/hooks/domains/domain.hooks";
89

@@ -15,6 +16,7 @@ export default function Home() {
1516
title="Proxies"
1617
description="Manage your proxies from here!"
1718
showBackButton={false}
19+
actions={<ProxiesActions />}
1820
/>
1921
<Separator />
2022
{isLoading ? (
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react'
2+
import { Button } from '../ui/button'
3+
import { IconPlus, IconRefresh } from '@tabler/icons-react'
4+
import { useQueryClient, useIsFetching } from '@tanstack/react-query'
5+
6+
const ProxiesActions = () => {
7+
const queryClient = useQueryClient();
8+
const isFetchingDomains = useIsFetching({ queryKey: ["registered-domains"] });
9+
10+
const refreshProxies = async () => {
11+
queryClient.invalidateQueries({
12+
queryKey: ["registered-domains"]
13+
})
14+
}
15+
16+
const handleAddProxy = () => {
17+
18+
}
19+
20+
return (
21+
<div className='flex items-center justify-end gap-4'>
22+
<Button onClick={refreshProxies} className='cursor-pointer' variant={'outline'}>
23+
<span>
24+
<IconRefresh className={isFetchingDomains ? 'animate-spin' : ''} />
25+
</span>
26+
Refresh
27+
</Button>
28+
<Button onClick={refreshProxies} className='cursor-pointer' variant={'default'}>
29+
<span>
30+
<IconPlus className={isFetchingDomains ? 'animate-spin' : ''} />
31+
</span>
32+
Add Proxy
33+
</Button>
34+
</div>
35+
)
36+
}
37+
38+
export default ProxiesActions

src/components/top-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Header } from "./header"
33
import { usePathname } from "next/navigation"
44
import Link from "next/link"
55
import { ProfileDropdown } from "./profile-dropdown"
6-
import ChangePassword from "./change-password"
6+
import ChangePassword from "./user/change-password"
77
import { useState } from "react"
88

99
const NAV_ITEMS = [

src/components/change-password.tsx renamed to src/components/user/change-password.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react'
2-
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './ui/dialog'
3-
import { Button } from './ui/button'
2+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '../ui/dialog'
3+
import { Button } from '../ui/button'
44
import { cn } from '@/lib/utils'
5-
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from './ui/form'
6-
import { PasswordInput } from './password-input'
5+
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'
6+
import { PasswordInput } from '../password-input'
77
import { PasswordChangeData, PasswordChangeSchema } from '@/schemas/user/auth.schema'
88
import { useForm } from 'react-hook-form'
99
import { zodResolver } from '@hookform/resolvers/zod'

0 commit comments

Comments
 (0)