-
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.
added list user functionality, SvelteButton component
- Loading branch information
Showing
3 changed files
with
57 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script lang="ts"> | ||
export let buttonItem, action; | ||
</script> | ||
|
||
<button on:click={action} | ||
class="transition ease-in-out delay-10 hover:-translate-y-1 hover:scale-110 duration-300 bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow shadow-lg shadow-cyan-500/50" | ||
>{buttonItem}</button> |
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,5 +1,51 @@ | ||
<h1>Admin</h1> | ||
<script> | ||
import axios from "axios"; | ||
import SvelteButton from "../../lib/SvelteButton.svelte"; | ||
let listUsersCallCount = 0; | ||
let userList = []; | ||
async function listUsers() { | ||
let error = null; | ||
try { | ||
const res = await axios.get( | ||
"https://music-tonic.herokuapp.com/client1-rest/listUsers" | ||
); | ||
userList = res.data; | ||
listUsersCallCount += 1; | ||
console.log("user list retrieved as:", userList); | ||
return userList; | ||
} catch (e) { | ||
error = e; | ||
listUsersCallCount += 1; | ||
return ["Bad request"]; | ||
} | ||
} | ||
</script> | ||
|
||
<button>list users</button> | ||
<button>add user</button> | ||
<button>delete user</button> | ||
<h1 class="text-lg w-screen text-center mx-auto font-bold">Admin</h1> | ||
<div class="px-4 py-4 auto-cols-auto"> | ||
<div class="px-4 py-4"> | ||
<SvelteButton buttonItem="list users" action={listUsers} /> | ||
<div class="px-4 py-4"> | ||
{#key listUsersCallCount} | ||
<ul> | ||
{#each userList as { userId, realName, userType, mainGenre, age }} | ||
<li> | ||
userId: {userId} Name: {realName} userType: {userType} mainGenre: {mainGenre} | ||
age:{age} | ||
</li> | ||
{/each} | ||
</ul> | ||
{/key} | ||
</div> | ||
</div> | ||
<div class="px-4 py-4"> | ||
<SvelteButton buttonItem="add user" action={listUsers} /> | ||
<div class="px-4 py-4"> | ||
</div> | ||
</div> | ||
<div class="px-4 py-4"> | ||
<SvelteButton buttonItem="delete user" action={listUsers} /> | ||
<div class="px-4 py-4"> | ||
</div> | ||
</div> | ||
</div> |
949194a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mean-rice – ./
mean-rice.vercel.app
mean-rice-j-rebs.vercel.app
mean-rice-git-main-j-rebs.vercel.app