Skip to content

Commit e7fbe67

Browse files
author
KutayGuler
committed
fixed bugs: #1 and #2
1 parent 5262fb4 commit e7fbe67

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

src/lib/PieChart.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
return Math.floor((degrees / 360) * 100);
1212
}
1313
14-
for (let i = 0; i < 9; i++) {
14+
const sliceCount = data.length < 9 ? data.length : 9;
15+
16+
for (let i = 0; i < sliceCount; i++) {
1517
if (i == 4) {
1618
let value = data.slice(9).reduce((acc, [_, v]) => {
1719
if (v <= 0) return acc;

src/lib/userSection.svelte

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@
3838
</a>
3939
{#key [currentPie, numberType]}
4040
<PieChart data={pieData[currentPie]} {numberType}>
41-
<select class="select rounded-3xl" bind:value={currentPie}>
42-
{#each Object.keys(pieData) as value}
43-
<option {value}>{pieNames[value]}</option>
44-
{/each}
45-
</select>
46-
<select class="select rounded-3xl" bind:value={numberType}>
47-
<option value="percentage">Percentage</option>
48-
<option value="literal">Literal</option>
49-
</select>
41+
{#if pieData[currentPie].length > 0}
42+
<select class="select rounded-3xl" bind:value={currentPie}>
43+
{#each Object.keys(pieData) as value}
44+
<option {value}>{pieNames[value]}</option>
45+
{/each}
46+
</select>
47+
<select class="select rounded-3xl" bind:value={numberType}>
48+
<option value="percentage">Percentage</option>
49+
<option value="literal">Literal</option>
50+
</select>
51+
{:else}
52+
<div>No visualizations available.</div>
53+
{/if}
5054
</PieChart>
5155
{/key}
5256
</div>

src/routes/+page.svelte

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
let authorData = [];
1313
let pieData = {};
1414
let type: RetrievalType = 'submission';
15+
let requestCompleted = false;
1516
1617
$: console.log(returnData);
1718
$: console.log(authorData);
@@ -27,6 +28,8 @@
2728
input.value = null;
2829
}
2930
}
31+
32+
requestCompleted = false;
3033
}
3134
3235
function clearResults() {
@@ -97,6 +100,7 @@
97100
98101
populateForm();
99102
loading = true;
103+
requestCompleted = false;
100104
101105
let authorName = url.searchParams.get('author');
102106
let type: RetrievalType = (url.searchParams.get('type') as RetrievalType) || 'submission';
@@ -121,6 +125,7 @@
121125
}
122126
123127
loading = false;
128+
requestCompleted = true;
124129
}
125130
126131
async function fetchPullPush(retrievalType: RetrievalType, value: string) {
@@ -132,16 +137,6 @@
132137
);
133138
const json = await response.json();
134139
_returnData = json.data;
135-
if (_returnData.length === 0) {
136-
return {
137-
toast: {
138-
message:
139-
'No results found for your search. Please try again with different parameters.',
140-
background: 'variant-filled-error',
141-
autohide: false
142-
}
143-
};
144-
}
145140
return _returnData;
146141
} catch {
147142
return {
@@ -469,5 +464,13 @@
469464
</div>
470465
{/if}
471466
<IntersectionObserver element={itemCountDiv} on:intersect={paginate} />
467+
{:else if requestCompleted}
468+
<div class="w-full flex justify-center">
469+
<div
470+
class="flex justify-center self-center alert card variant-ghost-warning max-w-5xl w-full rounded-3xl"
471+
>
472+
No results found for your search.
473+
</div>
474+
</div>
472475
{/if}
473476
{/if}

0 commit comments

Comments
 (0)