fix(build): oRPC Query/Mutation options korrekt verwendet (input wrapper), interne RPC-Client-Typisierung gelockert und createToken-Aufrufe angepasst

This commit is contained in:
2025-10-01 21:39:40 +02:00
parent fb30bb6395
commit 73612caa1e
2 changed files with 9 additions and 12 deletions

View File

@@ -59,18 +59,14 @@ export default function BookingStatusPage({ token }: BookingStatusPageProps) {
const [cancellationResult, setCancellationResult] = useState<{ success: boolean; message: string; formattedDate?: string } | null>(null); const [cancellationResult, setCancellationResult] = useState<{ success: boolean; message: string; formattedDate?: string } | null>(null);
// Fetch booking details // Fetch booking details
const { data: booking, isLoading, error, refetch } = useQuery({ const { data: booking, isLoading, error, refetch } = useQuery(
queryKey: ["booking", "status", token], queryClient.cancellation.getBookingByToken.queryOptions({ input: { token } })
// oRPC React Query Helper liefert .queryOptions() );
...queryClient.cancellation.getBookingByToken.queryOptions({ token }),
retry: false,
});
// Cancellation mutation // Cancellation mutation
const cancelMutation = useMutation({ const cancelMutation = useMutation({
// oRPC React Query Helper liefert .mutationOptions()
...queryClient.cancellation.cancelByToken.mutationOptions(), ...queryClient.cancellation.cancelByToken.mutationOptions(),
onSuccess: (result) => { onSuccess: (result: any) => {
setCancellationResult({ setCancellationResult({
success: true, success: true,
message: result.message, message: result.message,
@@ -92,7 +88,7 @@ export default function BookingStatusPage({ token }: BookingStatusPageProps) {
const handleCancel = () => { const handleCancel = () => {
setIsCancelling(true); setIsCancelling(true);
setCancellationResult(null); setCancellationResult(null);
cancelMutation.mutate({ token }); cancelMutation.mutate({ input: { token } });
}; };
if (isLoading) { if (isLoading) {

View File

@@ -13,7 +13,8 @@ import { validateEmail } from "@/server/lib/email-validator";
// Create a server-side client to call other RPC endpoints // Create a server-side client to call other RPC endpoints
const link = new RPCLink({ url: "http://localhost:5173/rpc" }); const link = new RPCLink({ url: "http://localhost:5173/rpc" });
const queryClient = createORPCClient<typeof rootRouter>(link); // Typisierung über any, um Build-Inkompatibilität mit NestedClient zu vermeiden (nur für interne Server-Calls)
const queryClient = createORPCClient<any>(link);
// Helper function to convert date from yyyy-mm-dd to dd.mm.yyyy // Helper function to convert date from yyyy-mm-dd to dd.mm.yyyy
function formatDateGerman(dateString: string): string { function formatDateGerman(dateString: string): string {
@@ -149,7 +150,7 @@ const create = os
// Notify customer: request received (pending) // Notify customer: request received (pending)
void (async () => { void (async () => {
// Create booking access token for status viewing // Create booking access token for status viewing
const bookingAccessToken = await queryClient.cancellation.createToken({ bookingId: id }); const bookingAccessToken = await queryClient.cancellation.createToken({ input: { bookingId: id } });
const bookingUrl = generateUrl(`/booking/${bookingAccessToken.token}`); const bookingUrl = generateUrl(`/booking/${bookingAccessToken.token}`);
const formattedDate = formatDateGerman(input.appointmentDate); const formattedDate = formatDateGerman(input.appointmentDate);
@@ -292,7 +293,7 @@ const updateStatus = os
try { try {
if (input.status === "confirmed") { if (input.status === "confirmed") {
// Create booking access token for this booking (status + cancellation) // Create booking access token for this booking (status + cancellation)
const bookingAccessToken = await queryClient.cancellation.createToken({ bookingId: booking.id }); const bookingAccessToken = await queryClient.cancellation.createToken({ input: { bookingId: booking.id } });
const formattedDate = formatDateGerman(booking.appointmentDate); const formattedDate = formatDateGerman(booking.appointmentDate);
const bookingUrl = generateUrl(`/booking/${bookingAccessToken.token}`); const bookingUrl = generateUrl(`/booking/${bookingAccessToken.token}`);