feat(web): карточка скачивания кассы на странице «Кассы»
Запрашивает GET /api/pos/v1/version и показывает версию + кнопки «Скачать для Windows / для Linux» (ссылки из конфигурации сервера, секция Pos). Если ссылки не настроены — подсказка администратору. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fcd4a69624
commit
cbf92dca3b
|
|
@ -16,6 +16,43 @@ import type { PagedResult, RetailPoint, Store } from '@/lib/types'
|
||||||
|
|
||||||
const URL = '/api/catalog/retail-points'
|
const URL = '/api/catalog/retail-points'
|
||||||
|
|
||||||
|
interface PosVersion { version: string; windowsUrl?: string; linuxUrl?: string; notes?: string; mandatory: boolean }
|
||||||
|
|
||||||
|
/** Карточка со ссылками на скачивание кассового приложения (Windows/Linux). */
|
||||||
|
function PosDownloadCard() {
|
||||||
|
const { data } = useQuery({
|
||||||
|
queryKey: ['pos-version'],
|
||||||
|
queryFn: async () => (await api.get<PosVersion>('/api/pos/v1/version')).data,
|
||||||
|
staleTime: 300_000,
|
||||||
|
})
|
||||||
|
const win = data?.windowsUrl
|
||||||
|
const lin = data?.linuxUrl
|
||||||
|
return (
|
||||||
|
<div className="mb-4 rounded-lg border border-slate-200 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-800/50">
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<div className="flex-1 min-w-[220px]">
|
||||||
|
<div className="font-medium">Кассовое приложение (касса кассира)</div>
|
||||||
|
<div className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
|
Кроссплатформенная касса для Windows 10/11 и Linux.
|
||||||
|
{data?.version && data.version !== '0.0.0' ? ` Последняя версия: ${data.version}.` : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button variant="secondary" size="sm" disabled={!win}
|
||||||
|
onClick={() => win && window.open(win, '_blank')}>Скачать для Windows</Button>
|
||||||
|
<Button variant="secondary" size="sm" disabled={!lin}
|
||||||
|
onClick={() => lin && window.open(lin, '_blank')}>Скачать для Linux</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{!win && !lin && (
|
||||||
|
<div className="mt-2 text-xs text-amber-600 dark:text-amber-400">
|
||||||
|
Ссылки на сборки не настроены (раздел <code>Pos</code> в конфигурации сервера).
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
interface Form {
|
interface Form {
|
||||||
id?: string
|
id?: string
|
||||||
name: string
|
name: string
|
||||||
|
|
@ -73,6 +110,7 @@ export function RetailPointsPage() {
|
||||||
<Pagination page={page} pageSize={data.pageSize} total={data.total} onPageChange={setPage} />
|
<Pagination page={page} pageSize={data.pageSize} total={data.total} onPageChange={setPage} />
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
<PosDownloadCard />
|
||||||
<DataTable
|
<DataTable
|
||||||
rows={data?.items ?? []}
|
rows={data?.items ?? []}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue