forked from VinokurovVE/tests
routing and fetching data
This commit is contained in:
3
frontend_reactjs/src/pages/Main.tsx
Normal file
3
frontend_reactjs/src/pages/Main.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export default function Main (){
|
||||
return ( <><h1>Main page</h1></>)
|
||||
}
|
3
frontend_reactjs/src/pages/NotFound.tsx
Normal file
3
frontend_reactjs/src/pages/NotFound.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export default function NotFound (){
|
||||
return ( <><h1>Page not found</h1></>)
|
||||
}
|
26
frontend_reactjs/src/pages/Roles.tsx
Normal file
26
frontend_reactjs/src/pages/Roles.tsx
Normal file
@ -0,0 +1,26 @@
|
||||
import { useState} from 'react'
|
||||
import RoleCard from '../components/RoleCard'
|
||||
import Modal from '../components/Modal'
|
||||
import useDataFetching from '../components/FetchingData'
|
||||
|
||||
interface IRoleCard{
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
interface Props {
|
||||
showModal: boolean;
|
||||
}
|
||||
function Users() {
|
||||
const [showModal, setShowModal] = useState<Props>({showModal: false});
|
||||
const cards = useDataFetching<IRoleCard[]>("http://localhost:8000/auth/role/",[])
|
||||
|
||||
return (
|
||||
<div>
|
||||
{cards.map((card, index) => <RoleCard key={index} {...card}/>)}
|
||||
<button className='absolute w-0 h-0' onClick={() => setShowModal({showModal:true})}>+</button>
|
||||
<Modal {...showModal}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Users
|
18
frontend_reactjs/src/pages/Users.tsx
Normal file
18
frontend_reactjs/src/pages/Users.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import Card from '../components/Card'
|
||||
import useDataFetching from '../components/FetchingData'
|
||||
interface ICard{
|
||||
firstname: string
|
||||
lastname: string
|
||||
email: string
|
||||
}
|
||||
|
||||
function Users() {
|
||||
const cards= useDataFetching<ICard[]>("http://localhost:8000/auth/user/",[])
|
||||
return (
|
||||
<div>
|
||||
{cards.map((card, index) => <Card key={index} {...card}/>)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Users
|
Reference in New Issue
Block a user