mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 12:59:36 +02:00
client sorting
This commit is contained in:
parent
82db6f1789
commit
f5fc2f5add
2 changed files with 36 additions and 9 deletions
|
@ -363,6 +363,11 @@ export const actions: Actions = {
|
|||
const planned = formData.get('planned');
|
||||
const featured = formData.get('featured');
|
||||
|
||||
const order_direction = formData.get('order_direction') as string;
|
||||
const order_by = formData.get('order_by') as string;
|
||||
|
||||
console.log(order_direction, order_by);
|
||||
|
||||
let adventures: Adventure[] = [];
|
||||
|
||||
if (!event.locals.user) {
|
||||
|
@ -399,7 +404,7 @@ export const actions: Actions = {
|
|||
console.log(filterString);
|
||||
|
||||
let visitedFetch = await fetch(
|
||||
`${serverEndpoint}/api/adventures/filtered?types=${filterString}`,
|
||||
`${serverEndpoint}/api/adventures/filtered?types=${filterString}&order_by=${order_by}&order_direction=${order_direction}`,
|
||||
{
|
||||
headers: {
|
||||
Cookie: `${event.cookies.get('auth')}`
|
||||
|
|
|
@ -252,22 +252,44 @@
|
|||
<button type="submit" class="btn btn-primary mt-4">Filter</button>
|
||||
<div class="divider"></div>
|
||||
<h3 class="text-center font-semibold text-lg mb-4">Sort</h3>
|
||||
<label for="name-asc">Name ASC</label>
|
||||
<p>Order Direction</p>
|
||||
<label for="asc">Ascending</label>
|
||||
<input
|
||||
type="radio"
|
||||
name="name"
|
||||
id="name-asc"
|
||||
name="order_direction"
|
||||
id="asc"
|
||||
class="radio radio-primary"
|
||||
checked
|
||||
on:click={() => sort({ attribute: 'name', order: 'asc' })}
|
||||
value="asc"
|
||||
/>
|
||||
<label for="name-desc">Name DESC</label>
|
||||
<label for="desc">Descending</label>
|
||||
<input
|
||||
type="radio"
|
||||
name="name"
|
||||
id="name-desc"
|
||||
name="order_direction"
|
||||
id="desc"
|
||||
value="desc"
|
||||
class="radio radio-primary"
|
||||
/>
|
||||
<br />
|
||||
<p>Order By</p>
|
||||
<label for="name">Name</label>
|
||||
<input
|
||||
type="radio"
|
||||
name="order_by"
|
||||
id="name"
|
||||
class="radio radio-primary"
|
||||
checked
|
||||
value="name"
|
||||
/>
|
||||
<label for="date">Date</label>
|
||||
<input type="radio" value="date" name="order_by" id="date" class="radio radio-primary" />
|
||||
<label for="rating">Rating</label>
|
||||
<input
|
||||
type="radio"
|
||||
value="rating"
|
||||
name="order_by"
|
||||
id="rating"
|
||||
class="radio radio-primary"
|
||||
on:click={() => sort({ attribute: 'name', order: 'desc' })}
|
||||
/>
|
||||
</form>
|
||||
<div class="divider"></div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue