Skip to content

Commit

Permalink
made per user page have old PR logs
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragrao04 committed Oct 10, 2023
1 parent 47eea1c commit c9fdeec
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 29 deletions.
4 changes: 1 addition & 3 deletions src/routes/[slug]/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ let user_details;

export async function load({ params, fetch }) {
let username = params.slug;
console.log(username);
try {
const response = await fetch(
`http://smaran.ddns.net:3000/records?user=${username}`
`https:/hacknight.navinshrinivas.com/records?user=${username}`
);
if (!response.ok) {
throw new Error(response.status, "Reddy Anna Is Not Talking");
} else {
user_details = await response.json();
console.log(user_details);
return {
user_details
};
Expand Down
90 changes: 64 additions & 26 deletions src/routes/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@
export let data;
let user_details = data.user_details;
let user_details_grouped = user_details.reduce((accumulator, current) => {
const key = current.Pullreq_url;
if (!accumulator[key]) {
accumulator[key] = [];
}
accumulator[key].push(current);
return accumulator;
}, {});
user_details_grouped = Object.values(user_details_grouped);
const latestPullRequests = Object.values(
user_details.reduce((accumulator, current) => {
const key = current.Pullreq_url;
if (!accumulator[key]) {
accumulator[key] = current;
}
return accumulator;
}, {})
);
</script>

<main>
<body>
<Background info={user_details} maintainer />

<Background info={latestPullRequests} maintainer />
<div class="flex justify-center items-center my-12">
<div class="image-container">
<img
Expand All @@ -17,47 +36,66 @@
class="w-40 h-auto block"
/>
<img
src="https://github.com/{user_details[0].Contributor_name}.png"
src="https://github.com/{latestPullRequests[0].Contributor_name}.png"
alt=""
class="rounded-md w-32 h-auto mr-12 overlay-image"
/>
</div>
<a
href="https://github.com/{user_details[0].Contributor_name}"
href="https://github.com/{latestPullRequests[0].Contributor_name}"
class="text-2xl md:text-2xl lg:text-5xl text-[#EFEDEF] font-bold m-4 mb-1 lg:m-4 md:mb-3"
target="_blank"
>
{user_details[0].Contributor_name.toUpperCase()}
{latestPullRequests[0].Contributor_name.toUpperCase()}
</a>
</div>
<div class="text-center text-4xl font-semibold md:text-2xl lg:text-4xl">
PULL REQUEST HISTORY
</div>
<div class="bg-[#0F0913] m-4 lg:m-10 pt-2 pb-2">
{#each user_details as user}
{#each user_details_grouped as pr_arr}
<div
class="card p-6 block md:grid md:grid-cols-3 md:justify-center md:items-center text-center rounded-xl"
>
<p class="text-5xl my-auto pb-2 md:pb-0">{user.Points_allotted}</p>
<div>
<a
href="https://github.com/{user.Maintainer_name}"
class="deets"
target="_blank">Maintainer: {user.Maintainer_name}</a
>
<p class="deets">Timestamp: {user.CreatedAt}</p>
</div>
<a href={user.Pullreq_url} class="deets" target="_blank">
<button
class="relative inline-flex items-center justify-center p-0.5 mr-2 overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-[#FFFBA4] via-[#D2B863] to-[#AD832D] group-hover:from-red-200 group-hover:via-red-300 group-hover:to-yellow-200 dark:text-white dark:hover:text-gray-900 focus:ring-4 focus:outline-none focus:ring-red-100 dark:focus:ring-red-400"
>
<span
class="relative px-5 py-2.5 transition-all ease-in duration-75 bg-white dark:bg-gray-900 rounded-md group-hover:bg-opacity-0"
>
View Pull Request
</span>
</button>
</a>
{#each pr_arr as pr, i}
{#if i == 0}
<p class="text-5xl my-auto pb-2 md:pb-0 text-[#d2b863]">
{pr.Points_allotted}
</p>
<div>
<a
href="https://github.com/{pr.Maintainer_name}"
class="deets"
target="_blank">Maintainer: {pr.Maintainer_name}</a
>
<p class="deets">
{new Date(pr.CreatedAt).toLocaleDateString() +
" " +
new Date(pr.CreatedAt).toLocaleTimeString()}
</p>
</div>
<a href={pr.Pullreq_url} class="deets" target="_blank">
<button
class="relative inline-flex items-center justify-center p-0.5 mr-2 overflow-hidden text-sm font-medium text-gray-900 rounded-lg group bg-gradient-to-br from-[#FFFBA4] via-[#D2B863] to-[#AD832D] group-hover:from-red-200 group-hover:via-red-300 group-hover:to-yellow-200 dark:text-white dark:hover:text-gray-900 focus:ring-4 focus:outline-none focus:ring-red-100 dark:focus:ring-red-400"
>
<span
class="relative px-5 py-2.5 transition-all ease-in duration-75 bg-white dark:bg-gray-900 rounded-md group-hover:bg-opacity-0"
>
View Pull Request
</span>
</button>
</a>
{#if pr_arr.length !== 1}
<div class="text-center pt-2 md:hidden">Previous Points:</div>
<div class="col-span-2 md:hidden" />
{/if}
{:else}
<div class="text-gray-500 line-through text-center text-xl">
{pr.Points_allotted}
</div>
<div class="col-span-2" />
{/if}
{/each}
</div>
{/each}
</div>
Expand Down

0 comments on commit c9fdeec

Please sign in to comment.