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