frontend phase 15
This commit is contained in:
@@ -4,6 +4,10 @@ import type { PageParams } from '@/lib/api/types';
|
||||
import { REVIEWS_PAGE_SIZE } from '../constants';
|
||||
import type {
|
||||
CreateReviewRequest,
|
||||
ModerateReviewResult,
|
||||
ModerationAction,
|
||||
ModerationQueueFilters,
|
||||
ModerationQueueItem,
|
||||
MyReviewState,
|
||||
NurseReviews,
|
||||
ReviewEligibility,
|
||||
@@ -20,6 +24,12 @@ interface NurseReviewsWire {
|
||||
reviews: Paginated<ReviewListItem>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire `ModerationQueueItemDto`. Per the b14 contract it does **not** carry `tagCodes` (REQ-037 — the admin
|
||||
* card can't show the review's tags); the client defaults it to `[]` on map.
|
||||
*/
|
||||
type ModerationQueueItemWire = Omit<ModerationQueueItem, 'tagCodes'>;
|
||||
|
||||
/**
|
||||
* Real HTTP implementation of the `ReviewsApi` seam (b14 contract `dev/contracts/domains/reviews-records.md`,
|
||||
* swagger `dev/contracts/openapi/swagger.v1.json`). Two of the four methods map **published** b14 routes:
|
||||
@@ -63,4 +73,30 @@ export const reviewsClientApi: ReviewsApi = {
|
||||
body: JSON.stringify({ rating: body.rating, body: body.body ?? null, tagCodes: body.tagCodes ?? [] }),
|
||||
}),
|
||||
),
|
||||
|
||||
listModerationQueue: async (filters, params): Promise<Paginated<ModerationQueueItem>> => {
|
||||
const query = new URLSearchParams();
|
||||
query.set('status', filters.status ?? 'pending_moderation');
|
||||
query.set('page', String(params.page ?? 1));
|
||||
query.set('pageSize', String(params.pageSize ?? REVIEWS_PAGE_SIZE));
|
||||
const wire = unwrap(
|
||||
await clientFetch<ApiEnvelope<Paginated<ModerationQueueItemWire>>>(
|
||||
`${API}/admin/reviews/moderation_queue?${query.toString()}`,
|
||||
),
|
||||
);
|
||||
// REQ-037: the wire dto omits tagCodes — default to [] so the admin card renders without them.
|
||||
return { ...wire, items: wire.items.map((item) => ({ ...item, tagCodes: [] })) };
|
||||
},
|
||||
|
||||
moderateReview: async (
|
||||
reviewId: number,
|
||||
action: ModerationAction,
|
||||
reason?: string,
|
||||
): Promise<ModerateReviewResult> =>
|
||||
unwrap(
|
||||
await clientFetch<ApiEnvelope<ModerateReviewResult>>(`${API}/reviews/${reviewId}/status`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ action, reason: reason ?? null }),
|
||||
}),
|
||||
),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user