update the adminpage ui

This commit is contained in:
2026-09-25 16:29:41 +05:30
parent 91e4db8217
commit b36a30385c
168 changed files with 10535 additions and 1008 deletions

View File

@@ -0,0 +1,35 @@
import type {NextRequest} from 'next/server';
import {sitesApi} from '@/services/api/sitesApi';
import {serveUpstream} from '@/shared/services/bff';
import type {ApiSiteCheck} from '@/services/api/types';
import type {SiteCheck} from '@/features/stores/types/siteCheck';
export const dynamic = 'force-dynamic';
function toSiteCheck(c: ApiSiteCheck): SiteCheck {
return {
siteName: c.site,
ok: c.ok,
steps: (c.steps ?? []).map((s) => ({
name: s.name,
status: s.status,
detail: s.detail,
advice: s.advice || null,
})),
};
}
/**
* GET /api/sites/{site}/check — is this shop working, in five ordered steps.
*
* Answered from what head office already knows, so it works when the shop PC
* is off — which is itself one of the answers. Read-only and cheap, so it is a
* GET the screen can repeat as often as somebody taps it.
*/
export async function GET(
req: NextRequest,
{params}: {params: Promise<{site: string}>},
) {
const {site} = await params;
return serveUpstream(req, (token) => sitesApi.check(token, site), toSiteCheck);
}

View File

@@ -0,0 +1,40 @@
import type {NextRequest} from 'next/server';
import {sitesApi} from '@/services/api/sitesApi';
import {proxyUpstream} from '@/shared/services/bff';
import type {ApiSiteUpdate} from '@/services/api/types';
export const dynamic = 'force-dynamic';
/**
* PATCH /api/sites/{site} — rename a shop or change its timezone. Manager or owner.
* DELETE /api/sites/{site} — remove a shop opened by mistake. Owner only.
*
* `{site}` is the slug, which never changes: renaming edits the display name
* only, so every saved URL and scheduled report keeps working.
*
* DELETE succeeds only for an EMPTY shop. One with cameras or visit history
* answers 409 `in_use` with the platform's own explanation, which is passed
* through verbatim — removing footfall and faces is an erasure decision, not a
* tidy-up this console should make easy.
*/
export async function PATCH(
req: NextRequest,
{params}: {params: Promise<{site: string}>},
) {
const {site} = await params;
return proxyUpstream(req, (token, body) => {
// An omitted field is left alone upstream, so only what was sent is sent.
const patch: ApiSiteUpdate = {};
if (typeof body.name === 'string') patch.name = body.name.trim();
if (typeof body.timezone === 'string') patch.timezone = body.timezone.trim();
return sitesApi.update(token, site, patch);
});
}
export async function DELETE(
req: NextRequest,
{params}: {params: Promise<{site: string}>},
) {
const {site} = await params;
return proxyUpstream(req, (token) => sitesApi.remove(token, site));
}