fix: Add WNW_CONFIG type definitions and fix TypeScript errors

This commit is contained in:
dwindown
2025-11-05 12:05:29 +07:00
parent af3ae9d1fb
commit 855f3fcae5
3 changed files with 34 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ export function Login() {
setError('');
try {
const response = await fetch(window.WNW_CONFIG.restUrl + '/auth/login', {
const response = await fetch((window.WNW_CONFIG?.restUrl || '') + '/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -118,7 +118,7 @@ export function Login() {
{/* Footer Links */}
<div className="mt-6 space-y-3">
<a
href={window.WNW_CONFIG.wpAdminUrl}
href={window.WNW_CONFIG?.wpAdminUrl || '/wp-admin'}
className="flex items-center justify-center gap-2 text-sm text-blue-600 hover:text-blue-700 dark:text-blue-400 transition-colors"
>
<ArrowLeft className="w-4 h-4" />
@@ -127,7 +127,7 @@ export function Login() {
<div className="text-center">
<a
href={window.WNW_CONFIG.siteUrl + '/wp-login.php?action=lostpassword'}
href={(window.WNW_CONFIG?.siteUrl || '') + '/wp-login.php?action=lostpassword'}
className="text-sm text-gray-600 hover:text-gray-700 dark:text-gray-400 transition-colors"
>
{__('Forgot password?')}
@@ -138,7 +138,7 @@ export function Login() {
{/* Site Info */}
<div className="text-center mt-6 text-sm text-gray-600 dark:text-gray-400">
{window.WNW_CONFIG.siteName}
{window.WNW_CONFIG?.siteName || 'WooNooW'}
</div>
</div>
</div>