Merge pull request 'fix(rental): client/server import boundary' (#74) from fix/rental-client-server-boundary into main
All checks were successful
CI / test (push) Successful in 2m11s

This commit is contained in:
tarzzan 2026-06-02 03:31:26 +00:00
commit 1dd2d65626
3 changed files with 24 additions and 30 deletions

View file

@ -2,8 +2,7 @@
import { useState, useTransition } from "react";
import { FormField, inputCls, selectCls, textareaCls } from "@/components/admin/FormField";
import { RENTAL_CATEGORY_LABEL } from "@/lib/admin/rental-items";
import { RentalCategory } from "@/generated/prisma/enums";
import { RENTAL_CATEGORY_LABEL, RENTAL_CATEGORIES } from "@/lib/rental-category-labels";
type Props = {
providers: { id: string; name: string; isSystemD: boolean }[];
@ -26,14 +25,6 @@ type Props = {
submitLabel?: string;
};
const CATEGORIES: RentalCategory[] = [
RentalCategory.SLEEP,
RentalCategory.NAVIGATION,
RentalCategory.FISHING,
RentalCategory.COOKING,
RentalCategory.SAFETY,
];
export function ItemForm({ providers, initial = {}, action, submitLabel = "Enregistrer" }: Props) {
const [pending, startTransition] = useTransition();
const [error, setError] = useState<string | null>(null);
@ -66,7 +57,7 @@ export function ItemForm({ providers, initial = {}, action, submitLabel = "Enreg
<FormField label="Catégorie" required>
<select name="category" defaultValue={initial.category ?? ""} required className={selectCls}>
<option value="" disabled> sélectionner </option>
{CATEGORIES.map((c) => (
{RENTAL_CATEGORIES.map((c) => (
<option key={c} value={c}>{RENTAL_CATEGORY_LABEL[c]}</option>
))}
</select>

View file

@ -4,13 +4,7 @@ import { Prisma } from "@/generated/prisma/client";
import { RentalCategory } from "@/generated/prisma/enums";
import { prisma } from "@/lib/prisma";
export const RENTAL_CATEGORY_LABEL: Record<RentalCategory, string> = {
SLEEP: "💤 Couchage",
NAVIGATION: "🛶 Navigation",
FISHING: "🎣 Pêche",
COOKING: "🍳 Cuisine",
SAFETY: "🦺 Sécurité",
};
export { RENTAL_CATEGORY_LABEL, RENTAL_CATEGORIES, isRentalCategory } from "@/lib/rental-category-labels";
export type AdminRentalItemFilters = {
q?: string;
@ -38,18 +32,6 @@ export type AdminRentalItemListItem = {
updatedAt: Date;
};
const CATEGORY_VALUES: RentalCategory[] = [
RentalCategory.SLEEP,
RentalCategory.NAVIGATION,
RentalCategory.FISHING,
RentalCategory.COOKING,
RentalCategory.SAFETY,
];
export function isRentalCategory(v: string): v is RentalCategory {
return (CATEGORY_VALUES as string[]).includes(v);
}
export async function listRentalItemsAdmin(
filters: AdminRentalItemFilters = {},
): Promise<AdminRentalItemListItem[]> {

View file

@ -0,0 +1,21 @@
import { RentalCategory } from "@/generated/prisma/enums";
export const RENTAL_CATEGORY_LABEL: Record<RentalCategory, string> = {
SLEEP: "💤 Couchage",
NAVIGATION: "🛶 Navigation",
FISHING: "🎣 Pêche",
COOKING: "🍳 Cuisine",
SAFETY: "🦺 Sécurité",
};
export const RENTAL_CATEGORIES: RentalCategory[] = [
RentalCategory.SLEEP,
RentalCategory.NAVIGATION,
RentalCategory.FISHING,
RentalCategory.COOKING,
RentalCategory.SAFETY,
];
export function isRentalCategory(v: string): v is RentalCategory {
return (RENTAL_CATEGORIES as string[]).includes(v);
}