Skip to content

Commit

Permalink
First steps toward WoW Upload Timers
Browse files Browse the repository at this point in the history
  • Loading branch information
krz0001 committed Jul 3, 2023
1 parent 8c88dbb commit 10a1765
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/components/navigation/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Dialog, Menu, Transition } from '@headlessui/react'
import {
BellIcon,
ChartSquareBarIcon,
ClockIcon,
CogIcon,
MenuAlt2Icon,
XIcon,
Expand Down Expand Up @@ -224,6 +225,11 @@ const navGroups: Array<{
name: 'Server Transfer Trading Search',
href: '/wow/full-scan',
icon: ChartSquareBarIcon
},
{
name: 'Upload Timers',
href: '/wow/upload-timers',
icon: ClockIcon
}
]
},
Expand Down
25 changes: 25 additions & 0 deletions app/requests/WoW/UploadTimers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { address, UserAgent } from '~/requests/client/config'

export type UploadTimersResponse = Array<UploadTimersItem>

export interface UploadTimersItem {
dataSetID: number
dataSetName: Array<string>
lastUploadMinute: number
lastUploadTimeRaw: string
lastUploadUnix: number
region: string
tableName: string
}

const UploadTimersRequest = async () =>
await fetch(`${address}/api/wow/upload-timers`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'User-Agent': UserAgent
},
body: JSON.stringify({})
})

export default UploadTimersRequest
6 changes: 6 additions & 0 deletions app/routes/wow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ const recommendedQueries = [
'Search for items that can be bought cheaply on a your home server and sold for a profit when transfering realms.',
Icon: DocumentSearchIcon,
href: '/wow/full-scan'
},
{
name: 'Upload Timers',
description: 'lorem ipsum',
Icon: DocumentSearchIcon,
href: '/wow/upload-timers'
}
]

Expand Down
67 changes: 67 additions & 0 deletions app/routes/wow/upload-timers/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { LoaderFunction } from '@remix-run/cloudflare'
import { json } from '@remix-run/cloudflare'
import { PageWrapper } from '~/components/Common'
import type {
UploadTimersResponse,
UploadTimersItem
} from '~/requests/WoW/UploadTimers'
import UploadTimersRequest from '~/requests/WoW/UploadTimers'
import { useLoaderData } from '@remix-run/react'
import NoResults from '~/components/Common/NoResults'
import SmallTable from '~/components/WoWResults/FullScan/SmallTable'
import type { ColumnList } from '~/components/types'

export const loader: LoaderFunction = async ({ request }) => {
return await json(UploadTimersRequest())
}

type UploadTimersActionResponse =
| UploadTimersResponse
| { exception: string }
| {}
| undefined

const UploadTimers = () => {
const results = useLoaderData<UploadTimersActionResponse>()

if (results) {
if (!Object.keys(results).length) {
return <NoResults href="/wow/upload-timers" />
}
}

return (
<PageWrapper>
<SmallTable
title="Upload Timers"
description="Shows when the WoW auction house data was last uploaded."
columnList={columnList}
data={[]}
columnSelectOptions={selectOptions}
sortingOrder={sortingOrder}
mobileColumnList={mobileColumnList}
/>
</PageWrapper>
)
}

export default UploadTimers

const columnList: Array<ColumnList<UploadTimersItem>> = [
{ columnId: 'dataSetID', header: 'Data Set ID' },
{ columnId: 'dataSetName', header: 'Data Set Name' },
{ columnId: 'lastUploadMinute', header: 'Last Upload Minute' },
{ columnId: 'lastUploadTimeRaw', header: 'Last Upload Time Raw' },
{ columnId: 'lastUploadUnix', header: 'Last Upload Unix' },
{ columnId: 'region', header: 'Region' },
{ columnId: 'tableName', header: 'Table Name' }
]

const selectOptions = ['user_price', 'lowest_price', 'realmName']

const sortingOrder = [{ id: 'user_price', desc: true }]

const mobileColumnList: Array<ColumnList<UploadTimersItem>> = [
{ columnId: 'dataSetName', header: 'Data Set Name' },
{ columnId: 'lastUploadMinute', header: 'Last Upload Minute' }
]

0 comments on commit 10a1765

Please sign in to comment.