-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aca99fd
commit c6b4ba3
Showing
18 changed files
with
456 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Link from "next/link"; | ||
import { ADMIN_OUTILS } from "../../constants/adminOutils"; | ||
|
||
const AdminIndex: React.FC = () => { | ||
return ( | ||
<div className="flex justify-center"> | ||
<div className="container px-4"> | ||
<div className="flex justify-center py-10"> | ||
<h1 className="relative z-10 text-center font-serif text-3xl font-semibold text-gray-900 after:absolute after:top-full after:left-0 after:h-2 after:w-full after:origin-left after:skew-y-1 after:animate-reveal after:bg-blue-primary"> | ||
Outils d'administration | ||
</h1> | ||
</div> | ||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4 "> | ||
{ADMIN_OUTILS.map((outil) => ( | ||
<Link | ||
href={outil.path} | ||
key={outil.path} | ||
className="flex cursor-pointer items-center justify-center gap-x-4 border bg-white py-6 px-8 shadow transition duration-200 hover:bg-blue-light active:scale-95" | ||
> | ||
<outil.Icon className="text-xl text-blue-primary" /> | ||
<p className="text-base font-semibold text-gray-700"> | ||
{outil.name} | ||
</p> | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AdminIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import dynamic from "next/dynamic"; | ||
import { useEffect, useState } from "react"; | ||
import AnnouncementService from "../../services/annoucement.service"; | ||
import { Announcement } from "../../typings/announcement"; | ||
import Loading from "../shared/Loading"; | ||
const ReactJson = dynamic(() => import("react-json-view"), { ssr: false }); | ||
|
||
const announcementService = AnnouncementService.getInstance(); | ||
|
||
const ScrapAnnoucenemntIndex = () => { | ||
const [annoucement, setAnnouncement] = useState<Announcement.Announcement[]>( | ||
[] | ||
); | ||
const [loading, setLoading] = useState<boolean>(false); | ||
|
||
const getAnnouncements = async () => { | ||
setLoading(true); | ||
try { | ||
const response = await announcementService.scrapAnnouncement(); | ||
setAnnouncement(response.data); | ||
setLoading(false); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
getAnnouncements(); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex justify-center"> | ||
<div className="container px-4"> | ||
<div className="flex justify-center py-10"> | ||
<h1 className="relative z-10 text-center font-serif text-3xl font-semibold text-gray-900 after:absolute after:top-full after:left-0 after:h-2 after:w-full after:origin-left after:skew-y-1 after:animate-reveal after:bg-blue-primary"> | ||
Scrap d'annonces | ||
</h1> | ||
</div> | ||
<div className=" bg-white p-2 shadow"> | ||
{loading ? ( | ||
<div className="flex h-96 items-center justify-center"> | ||
<Loading /> | ||
</div> | ||
) : ( | ||
<ReactJson src={annoucement} /> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ScrapAnnoucenemntIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import DataTable, { TableColumn } from "react-data-table-component"; | ||
import UserService from "../../services/user.service"; | ||
import { Auth } from "../../typings/user"; | ||
import Loading from "../shared/Loading"; | ||
|
||
const userService = UserService.getInstance(); | ||
|
||
const columns: TableColumn<Auth.User>[] = [ | ||
{ | ||
name: "N", | ||
cell: (_, index) => ( | ||
<span className="text-sm font-medium">{index + 1}</span> | ||
), | ||
selector: (_, index) => index || 0, | ||
sortable: true, | ||
width: "1rem", | ||
}, | ||
{ | ||
name: "Nom", | ||
cell: (row) => <span className="text-sm font-medium">{row.nom}</span>, | ||
selector: (row) => row.nom, | ||
sortable: true, | ||
}, | ||
{ | ||
name: "Prénom", | ||
cell: (row) => <span className="text-sm font-medium">{row.prenom}</span>, | ||
selector: (row) => row.prenom, | ||
sortable: true, | ||
}, | ||
{ | ||
name: "Email", | ||
cell: (row) => <span className="text-sm font-medium">{row.email}</span>, | ||
selector: (row) => row.email, | ||
sortable: true, | ||
}, | ||
{ | ||
name: "Téléphone", | ||
cell: (row) => <span className="text-sm font-medium">{row.tel}</span>, | ||
selector: (row) => row.tel || "", | ||
sortable: true, | ||
}, | ||
{ | ||
name: "Role", | ||
cell: (row) => <span className="text-sm font-medium">{row.role}</span>, | ||
selector: (row) => row.role, | ||
sortable: true, | ||
}, | ||
]; | ||
|
||
const UsersIndex: React.FC = () => { | ||
const [users, setUsers] = useState<Auth.User[]>([]); | ||
const [loading, setLoading] = useState<boolean>(true); | ||
|
||
const getUsers = async () => { | ||
setLoading(true); | ||
try { | ||
const response = await userService.getAllUsers(); | ||
setUsers(response.data); | ||
} catch (e) { | ||
console.log(e); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
getUsers(); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex justify-center"> | ||
<div className="container px-4"> | ||
<div className="flex justify-center py-10"> | ||
<h1 className="relative z-10 text-center font-serif text-3xl font-semibold text-gray-900 after:absolute after:top-full after:left-0 after:h-2 after:w-full after:origin-left after:skew-y-1 after:animate-reveal after:bg-blue-primary"> | ||
Liste des utilisateurs | ||
</h1> | ||
</div> | ||
<div className="flex w-full flex-col divide-y bg-white shadow"> | ||
<DataTable | ||
columns={columns} | ||
data={users} | ||
customStyles={{ | ||
headCells: { | ||
style: { | ||
fontWeight: 700, | ||
fontFamily: "'Merriweather', sarif", | ||
}, | ||
}, | ||
}} | ||
pagination | ||
progressPending={loading} | ||
progressComponent={ | ||
<div className="flex h-52 w-full items-center justify-center dark:bg-slate-800"> | ||
<Loading /> | ||
</div> | ||
} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UsersIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ROUTES } from "./routes"; | ||
|
||
export const ADMIN_OUTILS = [ROUTES.SCRAP_ANNOUNCEMENTS, ROUTES.LIST_USERS]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { ROUTES } from "./routes"; | ||
|
||
export const MENU_NAV = [ROUTES.SETTINGS]; | ||
export const MENU_NAV = [ROUTES.ADMIN, ROUTES.SETTINGS]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NextPage } from "next"; | ||
import { NextSeo } from "next-seo"; | ||
import AdminIndex from "../../components/admin/AdminIndex"; | ||
import { ROUTES } from "../../constants/routes"; | ||
|
||
const Admin: NextPage = () => { | ||
return ( | ||
<> | ||
<NextSeo title={ROUTES.ADMIN.name} /> | ||
<AdminIndex /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Admin; |
Oops, something went wrong.