typescript-typenfehler behoben.. npm run lint läuft nun fehlerfrei durch.

This commit is contained in:
Codex Agent
2025-11-22 11:49:47 +01:00
parent 6c78d7e281
commit eb41cb6194
74 changed files with 469 additions and 396 deletions

View File

@@ -104,7 +104,10 @@ const WizardBody: React.FC<{
[t]
);
const currentIndex = useMemo(() => stepConfig.findIndex((step) => step.id === currentStep), [currentStep]);
const currentIndex = useMemo(
() => stepConfig.findIndex((step) => step.id === currentStep),
[currentStep, stepConfig]
);
const progress = useMemo(() => {
if (currentIndex < 0) {
return 0;

View File

@@ -5,7 +5,7 @@ interface CheckoutState {
currentStep: CheckoutStepId;
selectedPackage: CheckoutPackage | null;
packageOptions: CheckoutPackage[];
authUser: any;
authUser: unknown;
isAuthenticated: boolean;
paymentIntent: string | null;
loading: boolean;
@@ -19,7 +19,7 @@ interface CheckoutWizardContextType {
packageOptions: CheckoutPackage[];
currentStep: CheckoutStepId;
isAuthenticated: boolean;
authUser: any;
authUser: unknown;
paddleConfig?: {
environment?: string | null;
client_token?: string | null;
@@ -27,7 +27,7 @@ interface CheckoutWizardContextType {
paymentCompleted: boolean;
selectPackage: (pkg: CheckoutPackage) => void;
setSelectedPackage: (pkg: CheckoutPackage) => void;
setAuthUser: (user: any) => void;
setAuthUser: (user: unknown) => void;
nextStep: () => void;
prevStep: () => void;
previousStep: () => void;
@@ -56,7 +56,7 @@ const initialState: CheckoutState = {
type CheckoutAction =
| { type: 'SELECT_PACKAGE'; payload: CheckoutPackage }
| { type: 'SET_AUTH_USER'; payload: any }
| { type: 'SET_AUTH_USER'; payload: unknown }
| { type: 'NEXT_STEP' }
| { type: 'PREV_STEP' }
| { type: 'GO_TO_STEP'; payload: CheckoutStepId }
@@ -72,19 +72,23 @@ function checkoutReducer(state: CheckoutState, action: CheckoutAction): Checkout
case 'SET_AUTH_USER':
return { ...state, authUser: action.payload, isAuthenticated: Boolean(action.payload) };
case 'NEXT_STEP':
const steps: CheckoutStepId[] = ['package', 'auth', 'payment', 'confirmation'];
const currentIndex = steps.indexOf(state.currentStep);
if (currentIndex < steps.length - 1) {
return { ...state, currentStep: steps[currentIndex + 1] };
{
const steps: CheckoutStepId[] = ['package', 'auth', 'payment', 'confirmation'];
const currentIndex = steps.indexOf(state.currentStep);
if (currentIndex < steps.length - 1) {
return { ...state, currentStep: steps[currentIndex + 1] };
}
return state;
}
return state;
case 'PREV_STEP':
const prevSteps: CheckoutStepId[] = ['package', 'auth', 'payment', 'confirmation'];
const prevIndex = prevSteps.indexOf(state.currentStep);
if (prevIndex > 0) {
return { ...state, currentStep: prevSteps[prevIndex - 1] };
{
const prevSteps: CheckoutStepId[] = ['package', 'auth', 'payment', 'confirmation'];
const prevIndex = prevSteps.indexOf(state.currentStep);
if (prevIndex > 0) {
return { ...state, currentStep: prevSteps[prevIndex - 1] };
}
return state;
}
return state;
case 'GO_TO_STEP':
return { ...state, currentStep: action.payload };
case 'UPDATE_PAYMENT_INTENT':
@@ -105,7 +109,7 @@ interface CheckoutWizardProviderProps {
initialPackage?: CheckoutPackage;
packageOptions?: CheckoutPackage[];
initialStep?: CheckoutStepId;
initialAuthUser?: any;
initialAuthUser?: unknown;
initialIsAuthenticated?: boolean;
paddle?: {
environment?: string | null;
@@ -173,7 +177,7 @@ export function CheckoutWizardProvider({
dispatch({ type: 'SELECT_PACKAGE', payload: pkg });
}, []);
const setAuthUser = useCallback((user: any) => {
const setAuthUser = useCallback((user: unknown) => {
dispatch({ type: 'SET_AUTH_USER', payload: user });
}, []);

View File

@@ -39,7 +39,7 @@ export const AuthStep: React.FC<AuthStepProps> = ({ privacyHtml, googleProfile,
const page = usePage<{ locale?: string }>();
const locale = page.props.locale ?? "de";
const googleAuth = useMemo<GoogleAuthFlash>(() => {
const props = page.props as Record<string, any>;
const props = page.props as { googleAuth?: GoogleAuthFlash };
return props.googleAuth ?? {};
}, [page.props]);
const { isAuthenticated, authUser, setAuthUser, nextStep, selectedPackage } = useCheckoutWizard();

View File

@@ -8,10 +8,9 @@ import { cn } from "@/lib/utils";
interface ConfirmationStepProps {
onViewProfile?: () => void;
onGoToAdmin?: () => void;
}
export const ConfirmationStep: React.FC<ConfirmationStepProps> = ({ onViewProfile, onGoToAdmin }) => {
export const ConfirmationStep: React.FC<ConfirmationStepProps> = ({ onViewProfile }) => {
const { t } = useTranslation('marketing');
const { selectedPackage } = useCheckoutWizard();
const handleProfile = React.useCallback(() => {
@@ -22,14 +21,6 @@ export const ConfirmationStep: React.FC<ConfirmationStepProps> = ({ onViewProfil
window.location.href = '/settings/profile';
}, [onViewProfile]);
const handleAdmin = React.useCallback(() => {
if (typeof onGoToAdmin === 'function') {
onGoToAdmin();
return;
}
window.location.href = '/event-admin';
}, [onGoToAdmin]);
const packageName = selectedPackage?.name ?? '';
const onboardingItems = [

View File

@@ -149,17 +149,10 @@ export const PackageStep: React.FC = () => {
const { t } = useTranslation('marketing');
const { selectedPackage, packageOptions, setSelectedPackage, resetPaymentState } = useCheckoutWizard();
// Early return if no package is selected
if (!selectedPackage) {
return (
<div className="text-center py-8">
<p className="text-muted-foreground">{t('checkout.package_step.no_package_selected')}</p>
</div>
);
}
const comparablePackages = useMemo(() => {
if (!selectedPackage) {
return [];
}
// Filter by type and sort: free packages first, then by price ascending
return packageOptions
.filter((pkg: CheckoutPackage) => pkg.type === selectedPackage.type)
@@ -180,6 +173,14 @@ export const PackageStep: React.FC = () => {
resetPaymentState();
};
if (!selectedPackage) {
return (
<div className="text-center py-8">
<p className="text-muted-foreground">{t('checkout.package_step.no_package_selected')}</p>
</div>
);
}
return (
<div className="grid gap-8 lg:grid-cols-[2fr_1fr]">
<div className="space-y-6">

View File

@@ -139,7 +139,7 @@ export const PaymentStep: React.FC = () => {
const [couponLoading, setCouponLoading] = useState(false);
const paddleRef = useRef<typeof window.Paddle | null>(null);
const checkoutContainerRef = useRef<HTMLDivElement | null>(null);
const eventCallbackRef = useRef<(event: any) => void>();
const eventCallbackRef = useRef<(event: Record<string, unknown>) => void>();
const hasAutoAppliedCoupon = useRef(false);
const checkoutContainerClass = 'paddle-checkout-container';
@@ -149,7 +149,6 @@ export const PaymentStep: React.FC = () => {
}, [i18n.language]);
const isFree = useMemo(() => (selectedPackage ? Number(selectedPackage.price) <= 0 : false), [selectedPackage]);
const hasCoupon = Boolean(couponPreview);
const applyCoupon = useCallback(async (code: string) => {
if (!selectedPackage) {
@@ -339,7 +338,7 @@ export const PaymentStep: React.FC = () => {
console.info('[Checkout] Hosted checkout response', { status: response.status, rawBody });
}
let data: any = null;
let data: { checkout_url?: string; message?: string } | null = null;
try {
data = rawBody && rawBody.trim().startsWith('{') ? JSON.parse(rawBody) : null;
} catch (parseError) {
@@ -354,7 +353,7 @@ export const PaymentStep: React.FC = () => {
if (/^https?:\/\//i.test(trimmed)) {
checkoutUrl = trimmed;
} else if (trimmed.startsWith('<')) {
const match = trimmed.match(/https?:\/\/["'a-zA-Z0-9._~:\/?#\[\]@!$&'()*+,;=%-]+/);
const match = trimmed.match(/https?:\/\/["'a-zA-Z0-9._~:/?#@!$&'()*+,;=%-]+/);
if (match) {
checkoutUrl = match[0];
}
@@ -444,7 +443,7 @@ export const PaymentStep: React.FC = () => {
locale: paddleLocale,
},
},
eventCallback: (event: any) => eventCallbackRef.current?.(event),
eventCallback: (event: Record<string, unknown>) => eventCallbackRef.current?.(event),
});
inlineReady = true;