-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: users | setup route for user page
- Loading branch information
Showing
5 changed files
with
58 additions
and
0 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,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) | ||
} | ||
}; |
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,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); | ||
} |
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 @@ | ||
@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 |