no idea why shit isn't updating weee
parent
87afb5e11b
commit
38653bf4a6
|
|
@ -29,7 +29,7 @@ type catalogHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *catalogHandler) GetUpcoming(ctx context.Context, cmd *api.AuctionSearchCriteria) (out *api.GetUpcomingResult, err error) {
|
func (rh *catalogHandler) GetUpcoming(ctx context.Context, cmd *api.AuctionSearchCriteria) (out *api.GetUpcomingResult, err error) {
|
||||||
page := int(math.Min(1, float64(cmd.GetPage())))
|
page := int(math.Max(0, float64(cmd.GetPage())))
|
||||||
pageSize := int(cmd.GetLimit())
|
pageSize := int(cmd.GetLimit())
|
||||||
|
|
||||||
if pageSize < 32 {
|
if pageSize < 32 {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { LayoutData } from './$types';
|
import type { LayoutData } from './$types';
|
||||||
import { goto } from '$app/navigation';
|
import { goto, invalidateAll } from '$app/navigation';
|
||||||
import SearchBox from '$lib/SearchBox.svelte';
|
import SearchBox from '$lib/SearchBox.svelte';
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
|
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
|
|
||||||
async function onSubmit(evt: CustomEvent) {
|
async function onSubmit(evt: CustomEvent) {
|
||||||
const { query, page } = evt.detail;
|
let { query } = evt.detail;
|
||||||
await goto(query ? `/?query=${query}&page=${page || 0}` : '/', {
|
await goto(query ? `/?query=${query}` : '/', {
|
||||||
invalidateAll: true
|
invalidateAll: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import type { LayoutLoad } from './$types';
|
||||||
export const load = (({ url }) => {
|
export const load = (({ url }) => {
|
||||||
return {
|
return {
|
||||||
query: url.searchParams.get('query') || '',
|
query: url.searchParams.get('query') || '',
|
||||||
page: parseInt(url.searchParams.get('page') || '1'),
|
page: parseInt(url.searchParams.get('page') || '0'),
|
||||||
limit: parseInt(url.searchParams.get('pageSize') || '32'),
|
limit: parseInt(url.searchParams.get('pageSize') || '64'),
|
||||||
};
|
};
|
||||||
|
|
||||||
}) satisfies LayoutLoad;
|
}) satisfies LayoutLoad;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,30 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
import AuctionResult from '$lib/AuctionResult.svelte';
|
import AuctionResult from '$lib/AuctionResult.svelte';
|
||||||
|
import { invalidateAll } from '$app/navigation';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
$: hasResults = (data?.results || []).length > 0;
|
$: hasResults = (data?.results || []).length > 0;
|
||||||
|
$: currentPage = data.page + 1;
|
||||||
|
$: pageCount = Math.floor(data.total / 64);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if hasResults}
|
{#if hasResults}
|
||||||
|
<section>
|
||||||
<h1 class="pb-5 text-lg">{data?.results.length} of {data?.total} Upcoming & Live Auctions</h1>
|
<h1 class="pb-5 text-lg">{data?.results.length} of {data?.total} Upcoming & Live Auctions</h1>
|
||||||
|
<ol class="flex justify-between w-full center" style="padding: 0 10%;">
|
||||||
|
{#if currentPage > 1}
|
||||||
|
<li><a href="/?query={data.query}&page={data.page - 1}"><Previous</a></li>
|
||||||
|
{:else}
|
||||||
|
<li />
|
||||||
|
{/if}
|
||||||
|
<li>Page {currentPage} of {pageCount}</li>
|
||||||
|
{#if currentPage < pageCount}
|
||||||
|
<li><a href="/?query={data.query}&page={data.page + 1}">Next></a></li>
|
||||||
|
{/if}
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
|
||||||
<ul class="flex flex-col m-0 p-0 justify-between pr-10">
|
<ul class="flex flex-col m-0 p-0 justify-between pr-10">
|
||||||
{#each data?.results as auction, i}
|
{#each data?.results as auction, i}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ const API_HOST = 'http://localhost:8000/api/v1'
|
||||||
|
|
||||||
export const load = (async ({ fetch, url }) => {
|
export const load = (async ({ fetch, url }) => {
|
||||||
const searchTerm = url.searchParams.get('query') || '';
|
const searchTerm = url.searchParams.get('query') || '';
|
||||||
const currentPage = url.searchParams.get('page') || 1;
|
const currentPage = url.searchParams.get('page') || 0;
|
||||||
|
const currentLimit = url.searchParams.get('limit') || 64;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(API_HOST + `/upcoming?searchTerm=${searchTerm}&page=${currentPage}`);
|
const response = await fetch(API_HOST + `/upcoming?searchTerm=${searchTerm}&page=${currentPage}&limit=${currentLimit}`);
|
||||||
const { page, total, results } = await response.json() || {};
|
const { page, total, results } = await response.json() || {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue