navigate to editor with id
This commit is contained in:
@@ -2,6 +2,8 @@ import { type FC } from 'react'
|
|||||||
import { Edit, Eye, Share, Trash } from 'iconsax-react'
|
import { Edit, Eye, Share, Trash } from 'iconsax-react'
|
||||||
import type { CatalogItemType } from '../types/Types'
|
import type { CatalogItemType } from '../types/Types'
|
||||||
import moment from 'moment-jalaali'
|
import moment from 'moment-jalaali'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import { Paths } from '@/config/Paths'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
item: CatalogItemType
|
item: CatalogItemType
|
||||||
@@ -25,9 +27,11 @@ const CatalogueItem: FC<Props> = ({ item }) => {
|
|||||||
<div className='size-6 bg-[#EAECF4] rounded-md flex justify-center items-center'>
|
<div className='size-6 bg-[#EAECF4] rounded-md flex justify-center items-center'>
|
||||||
<Eye size={18} color='#0047FF' />
|
<Eye size={18} color='#0047FF' />
|
||||||
</div>
|
</div>
|
||||||
<div className='size-6 bg-[#EAECF4] rounded-md flex justify-center items-center'>
|
<Link to={Paths.editor + `/id=${item.id}`}>
|
||||||
<Edit size={18} color='#0047FF' />
|
<div className='size-6 bg-[#EAECF4] rounded-md flex justify-center items-center'>
|
||||||
</div>
|
<Edit size={18} color='#0047FF' />
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
<div className='size-6 bg-[#EAECF4] rounded-md flex justify-center items-center'>
|
<div className='size-6 bg-[#EAECF4] rounded-md flex justify-center items-center'>
|
||||||
<Share size={18} color='#000' />
|
<Share size={18} color='#000' />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,9 +6,12 @@ import Button from '@/components/Button'
|
|||||||
import Input from '@/components/Input'
|
import Input from '@/components/Input'
|
||||||
import { toast } from '@/components/Toast'
|
import { toast } from '@/components/Toast'
|
||||||
import { useCreateCatalog } from './hooks/useHomeData'
|
import { useCreateCatalog } from './hooks/useHomeData'
|
||||||
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
import { Paths } from '@/config/Paths'
|
||||||
|
|
||||||
const Home: FC = () => {
|
const Home: FC = () => {
|
||||||
|
|
||||||
|
const navigate = useNavigate()
|
||||||
const [active, setActive] = useState<string>('a4')
|
const [active, setActive] = useState<string>('a4')
|
||||||
const [name, setName] = useState<string>('')
|
const [name, setName] = useState<string>('')
|
||||||
const { mutate: createCatalog, isPending } = useCreateCatalog()
|
const { mutate: createCatalog, isPending } = useCreateCatalog()
|
||||||
@@ -18,12 +21,11 @@ const Home: FC = () => {
|
|||||||
toast('نام کاتالوگ را وارد کنید', 'error')
|
toast('نام کاتالوگ را وارد کنید', 'error')
|
||||||
} else {
|
} else {
|
||||||
createCatalog({ name: name, size: active, content: '' }, {
|
createCatalog({ name: name, size: active, content: '' }, {
|
||||||
onSuccess: () => {
|
onSuccess: (data) => {
|
||||||
toast('کاتالوگ با موفقیت ساخته شد', 'success')
|
toast('کاتالوگ با موفقیت ساخته شد', 'success')
|
||||||
|
navigate(Paths.editor + `/${data?.data?.id}`)
|
||||||
},
|
},
|
||||||
onError: (err) => {
|
onError: () => {
|
||||||
console.log(err);
|
|
||||||
|
|
||||||
toast('خطا در ساخت کاتالوگ', 'error')
|
toast('خطا در ساخت کاتالوگ', 'error')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const MainRouter = () => {
|
|||||||
<div className='flex-1 h-full flex'>
|
<div className='flex-1 h-full flex'>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path={Paths.home} element={<Home />} />
|
<Route path={Paths.home} element={<Home />} />
|
||||||
<Route path={Paths.editor} element={<Editor />} />
|
<Route path={Paths.editor + '/:id'} element={<Editor />} />
|
||||||
<Route path={Paths.viewer} element={<Viewer />} />
|
<Route path={Paths.viewer} element={<Viewer />} />
|
||||||
<Route path={Paths.catalog.list} element={<CatalogueList />} />
|
<Route path={Paths.catalog.list} element={<CatalogueList />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|||||||
Reference in New Issue
Block a user