Skip to content

Commit

Permalink
feat: users | setup route for user page
Browse files Browse the repository at this point in the history
  • Loading branch information
MRoyhanF committed Dec 18, 2024
1 parent bd4a0c6 commit 7903be3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import routeRoutes from "./route/route.routes.js";
import airlineRoutes from "./airline/airline.routes.js";
import flightRoutes from "./flight/flight.routes.js";
import ticketRoutes from "./tikcet/ticket.routes.js";
import userRoutes from "./user/user.routes.js";

export default (app) => {
const router = Router();
Expand All @@ -27,4 +28,5 @@ export default (app) => {
airlineRoutes(router);
flightRoutes(router);
ticketRoutes(router);
userRoutes(router);
};
22 changes: 22 additions & 0 deletions src/modules/user/user.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import axios from 'axios';

export const index = async (req, res, next) => {
try {
const api = process.env.API_URL;
const { token, email, role } = req;

const users = await axios.get(`${api}/api/v1/users`, {
headers: {
Authorization: `Bearer ${token}`,
},
});

const data = {
totalUsers : users.data.data.length,
}

res.edge('pages/user/index', { data, email, role });
} catch (error) {
next(error)
}
};
7 changes: 7 additions & 0 deletions src/modules/user/user.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as UserController from './user.controller.js';
import {validateCookies} from '../../middlewares/auth.js';

export default (router) => {
const prefix = '/users';
router.get(prefix + '/', validateCookies, UserController.index);
}
12 changes: 12 additions & 0 deletions src/resources/views/components/ui/sidebar.edge
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@
</svg>
</div>Tikets
</a>
<a href="/admin/users"
class="flex items-center w-full p-3 rounded-lg text-start leading-tight transition-all hover:bg-blue-50 hover:bg-opacity-80 focus:bg-blue-50 focus:bg-opacity-80 active:bg-blue-50 active:bg-opacity-80 hover:text-blue-900 focus:text-blue-900 active:text-blue-900 outline-none">
<div class="grid place-items-center mr-4">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"
class="h-5 w-5">
<path fill-rule="evenodd"
d="M18.685 19.097A9.723 9.723 0 0021.75 12c0-5.385-4.365-9.75-9.75-9.75S2.25 6.615 2.25 12a9.723 9.723 0 003.065 7.097A9.716 9.716 0 0012 21.75a9.716 9.716 0 006.685-2.653zm-12.54-1.285A7.486 7.486 0 0112 15a7.486 7.486 0 015.855 2.812A8.224 8.224 0 0112 20.25a8.224 8.224 0 01-5.855-2.438zM15.75 9a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"
clip-rule="evenodd"></path>
</svg>
</div>
Users
</a>
<div class="flex items-center w-full p-3 rounded-lg text-start leading-tight transition-all hover:bg-blue-50 hover:bg-opacity-80 focus:bg-blue-50 focus:bg-opacity-80 active:bg-blue-50 active:bg-opacity-80 hover:text-blue-900 focus:text-blue-900 active:text-blue-900 outline-none">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"
class="h-5 w-5">
Expand Down
15 changes: 15 additions & 0 deletions src/resources/views/pages/user/index.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@layout.app({ title: "Dasboard Page" })
@slot('main')

<div class="flex flex-col gap-4 w-full">

<div class="flex flex-row w-full justify-center items-center">
<div class="w-2/6 bg-white rounded-lg p-4">
<div class="text-2xl font-bold w-full text-center border-b-2 border-gray-300">Total User</div>
<div class="text-2xl font-bold w-full text-center">{{ data.totalUsers }}</div>
</div>
</div>
</div>

@endslot
@end

0 comments on commit 7903be3

Please sign in to comment.