mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 14:23:02 -05:00
feat: add leaderboard
This commit is contained in:
@@ -54,19 +54,19 @@ export default defineConfig({
|
|||||||
ru: 'Руководство'
|
ru: 'Руководство'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// label: 'Leaderboard',
|
label: 'Leaderboard',
|
||||||
// autogenerate: {
|
autogenerate: {
|
||||||
// directory: 'leaderboard',
|
directory: 'leaderboard',
|
||||||
// collapsed: true
|
collapsed: true
|
||||||
// },
|
},
|
||||||
// translations: {
|
translations: {
|
||||||
// es: 'Leaderboard',
|
es: 'Leaderboard',
|
||||||
// fr: 'Leaderboard',
|
fr: 'Leaderboard',
|
||||||
// pt: 'Leaderboard',
|
pt: 'Leaderboard',
|
||||||
// ru: 'Leaderboard'
|
ru: 'Leaderboard'
|
||||||
// }
|
}
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
label: 'Challenges',
|
label: 'Challenges',
|
||||||
autogenerate: {
|
autogenerate: {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { derived, writable } from 'svelte/store';
|
import { derived, writable } from 'svelte/store';
|
||||||
|
|
||||||
export const token = writable<string | null>(null);
|
export const token = writable<string | null>(null);
|
||||||
|
export const isConnected = writable(false);
|
||||||
|
|
||||||
export const isLoading = writable(true);
|
export const isLoading = writable(true);
|
||||||
export const error = writable(false);
|
export const error = writable(false);
|
||||||
@@ -18,6 +19,9 @@ export function loadToken() {
|
|||||||
const persistedToken = localStorage.getItem(TOKEN_KEY);
|
const persistedToken = localStorage.getItem(TOKEN_KEY);
|
||||||
if (persistedToken) {
|
if (persistedToken) {
|
||||||
token.set(JSON.parse(persistedToken));
|
token.set(JSON.parse(persistedToken));
|
||||||
|
isConnected.set(true);
|
||||||
|
} else {
|
||||||
|
isConnected.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import UserBox from './UserBox.svelte';
|
import UserBox from './UserBox.svelte';
|
||||||
import Spinner from './Spinner.svelte';
|
import Spinner from './Spinner.svelte';
|
||||||
import { token } from '../github/github-store';
|
import { isConnected, token } from '../github/github-store';
|
||||||
|
|
||||||
let users = [];
|
let users = [];
|
||||||
let loading = true;
|
let loading = true;
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
if (token) {
|
if (token) {
|
||||||
fetchGitHubUsers();
|
fetchGitHubUsers();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
async function fetchGitHubUsers() {
|
async function fetchGitHubUsers() {
|
||||||
try {
|
try {
|
||||||
@@ -71,6 +71,9 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if !$isConnected}
|
||||||
|
<div class="important-block not-connected">Log in to Github to see the list</div>
|
||||||
|
{:else}
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner />
|
<Spinner />
|
||||||
{:else if error}
|
{:else if error}
|
||||||
@@ -85,8 +88,13 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.not-connected {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import UserBox from './UserBox.svelte';
|
import UserBox from './UserBox.svelte';
|
||||||
import Spinner from './Spinner.svelte';
|
import Spinner from './Spinner.svelte';
|
||||||
import { token } from '../github/github-store';
|
import { isConnected, token } from '../github/github-store';
|
||||||
|
|
||||||
|
|
||||||
let users = [];
|
let users = [];
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
if (token) {
|
if (token) {
|
||||||
fetchGitHubUsers();
|
fetchGitHubUsers();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
const createUser = (items) => {
|
const createUser = (items) => {
|
||||||
const prCounts = {};
|
const prCounts = {};
|
||||||
@@ -55,6 +55,9 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if !$isConnected}
|
||||||
|
<div class="important-block not-connected">Log in to Github to see the list</div>
|
||||||
|
{:else}
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner />
|
<Spinner />
|
||||||
{:else if error}
|
{:else if error}
|
||||||
@@ -68,8 +71,13 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.not-connected {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import UserBox from './UserBox.svelte';
|
import UserBox from './UserBox.svelte';
|
||||||
import Spinner from './Spinner.svelte';
|
import Spinner from './Spinner.svelte';
|
||||||
import { token } from '../github/github-store';
|
import { isConnected, token } from '../github/github-store';
|
||||||
|
|
||||||
let users = [];
|
let users = [];
|
||||||
let loading = true;
|
let loading = true;
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
if (token) {
|
if (token) {
|
||||||
fetchGitHubUsers();
|
fetchGitHubUsers();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
async function fetchGitHubUsers() {
|
async function fetchGitHubUsers() {
|
||||||
try {
|
try {
|
||||||
@@ -71,6 +71,9 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if !$isConnected}
|
||||||
|
<div class="important-block not-connected">Log in to Github to see the list</div>
|
||||||
|
{:else}
|
||||||
{#if loading}
|
{#if loading}
|
||||||
<Spinner />
|
<Spinner />
|
||||||
{:else if error}
|
{:else if error}
|
||||||
@@ -84,8 +87,13 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.not-connected {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|||||||
Reference in New Issue
Block a user