Code Backup

Alle Dateien zum Kopieren und Sichern

Tipp: Klicke auf "Kopieren" bei jeder Datei und füge den Code in eine lokale Datei mit dem gleichen Namen ein. Für die Daten (99 Namen) nutze den "Export JSON" Button im Admin-Bereich.

Layout.js
import React from 'react';

export default function Layout({ children }) {
  return (
    <div className="min-h-screen bg-gradient-to-br from-amber-50 via-orange-50 to-yellow-50">
      <style>{`
        @import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cormorant+Garamond:wght@400;500;600;700&display=swap');
        .font-arabic {
          font-family: 'Amiri', serif;
        }
        body {
          font-family: 'Cormorant Garamond', serif;
        }
        :root {
          --primary: #7c5a3c;
          --primary-dark: #5d4230;
          --accent: #c9a86c;
          --accent-light: #e8d5b5;
        }
      `}</style>
      {children}
    </div>
  );
}
entities/DivineName.json
{
  "name": "DivineName",
  "type": "object",
  "properties": {
    "name_english": {
      "type": "string",
      "description": "English transliteration of the name (e.g., Al-Rahman)"
    },
    "name_arabic": {
      "type": "string",
      "description": "Arabic script of the name"
    },
    "short_meaning": {
      "type": "string",
      "description": "Brief meaning (e.g., The Most Merciful)"
    },
    "order": {
      "type": "number",
      "description": "Display order"
    },
    "audio_url": {
      "type": "string",
      "description": "URL to audio recitation of the name"
    },
    "meaning_introduction": {
      "type": "string",
      "description": "Section 1: Meaning & Introduction"
    },
    "quranic_references": {
      "type": "string",
      "description": "Section 2: Quranic Usage and References"
    },
    "scholars_explanations": {
      "type": "string",
      "description": "Section 3: Explanations of Islamic Scholars"
    },
    "promised_messiah_sayings": {
      "type": "string",
      "description": "Section 4: Sayings of the Promised Messiah"
    },
    "spiritual_meaning": {
      "type": "string",
      "description": "Section 5: Spiritual Meaning"
    },
    "practical_reflection": {
      "type": "string",
      "description": "Section 6: Practical Reflection"
    },
    "human_service_insight": {
      "type": "string",
      "description": "Section 7: Human Service Insight"
    }
  },
  "required": [
    "name_english",
    "name_arabic",
    "short_meaning"
  ]
}
pages/Home.js
import React, { useState, useEffect } from 'react';
import { base44 } from '@/api/base44Client';
import { useQuery } from '@tanstack/react-query';
import { Link } from 'react-router-dom';
import { createPageUrl } from '@/utils';
import { Settings, Grid3X3, FileCode, Search } from 'lucide-react';
import NameSelector from '@/components/divine-names/NameSelector';
import NameDisplay from '@/components/divine-names/NameDisplay';

export default function Home() {
  const [selectedId, setSelectedId] = useState(null);

  const { data: names = [], isLoading } = useQuery({
    queryKey: ['divineNames'],
    queryFn: () => base44.entities.DivineName.list('order', 100),
  });

  // Check for URL parameter
  useEffect(() => {
    const urlParams = new URLSearchParams(window.location.search);
    const idFromUrl = urlParams.get('id');
    if (idFromUrl) {
      setSelectedId(idFromUrl);
    }
  }, []);

  // Auto-select first name when loaded (only if no URL param)
  useEffect(() => {
    if (names.length > 0 && !selectedId) {
      const urlParams = new URLSearchParams(window.location.search);
      if (!urlParams.get('id')) {
        setSelectedId(names[0].id);
      }
    }
  }, [names, selectedId]);

  const selectedName = names.find(n => n.id === selectedId);

  return (
    <div className="min-h-screen py-6 px-4">
      <div className="max-w-4xl mx-auto">
        {/* Header */}
        <div className="app-header text-white rounded-t-xl p-8 text-center mb-0 relative shadow-lg">
          <div className="absolute top-4 right-4 flex gap-2">
            <Link 
              to={createPageUrl('Search')} 
              className="p-2 hover:bg-amber-600 rounded-full transition-colors"
              title="Suche"
            >
              <Search className="w-5 h-5" />
            </Link>
            <Link 
              to={createPageUrl('NamesOverview')} 
              className="p-2 hover:bg-amber-600 rounded-full transition-colors"
              title="Alle Namen anzeigen"
            >
              <Grid3X3 className="w-5 h-5" />
            </Link>
            <Link 
              to={createPageUrl('CodeBackup')} 
              className="p-2 hover:bg-amber-600 rounded-full transition-colors"
              title="Code Backup"
            >
              <FileCode className="w-5 h-5" />
            </Link>
            <Link 
              to={createPageUrl('Admin')} 
              className="p-2 hover:bg-amber-600 rounded-full transition-colors"
              title="Admin Panel"
            >
              <Settings className="w-5 h-5" />
            </Link>
          </div>
          <h1 className="text-3xl md:text-4xl font-bold mb-2">
            Explore the Names of Allah
          </h1>
          <p className="text-lg text-amber-100">
            Discover the beautiful attributes of the Divine
          </p>
        </div>

        {/* Main Content */}
        <div className="bg-white/90 backdrop-blur-sm rounded-b-xl shadow-lg p-6 border border-amber-100">
          <NameSelector 
            names={names} 
            selectedId={selectedId} 
            onSelect={setSelectedId}
            isLoading={isLoading}
          />
          
          <NameDisplay name={selectedName} />
        </div>
      </div>
    </div>
  );
}
pages/Admin.js
import React, { useState, useEffect } from 'react';
import { base44 } from '@/api/base44Client';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { Button } from "@/components/ui/button";
import { ArrowLeft, Shield, Download } from "lucide-react";
import NamesList from '@/components/admin/NamesList';
import NameForm from '@/components/admin/NameForm';
import { Link } from 'react-router-dom';
import { createPageUrl } from '@/utils';

export default function Admin() {
  const [user, setUser] = useState(null);
  const [isCheckingAuth, setIsCheckingAuth] = useState(true);
  const [view, setView] = useState('list'); // 'list' | 'add' | 'edit'
  const [editingName, setEditingName] = useState(null);
  
  const queryClient = useQueryClient();

  // Check authentication and admin status
  useEffect(() => {
    const checkAuth = async () => {
      try {
        const currentUser = await base44.auth.me();
        setUser(currentUser);
      } catch (error) {
        // Not logged in
        setUser(null);
      }
      setIsCheckingAuth(false);
    };
    checkAuth();
  }, []);

  const isAdmin = user?.role === 'admin';

  const { data: names = [], isLoading } = useQuery({
    queryKey: ['divineNames'],
    queryFn: () => base44.entities.DivineName.list('order'),
    enabled: !!user, // Alle angemeldeten User können sehen
  });

  const createMutation = useMutation({
    mutationFn: (data) => base44.entities.DivineName.create(data),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['divineNames'] });
      setView('list');
    },
  });

  const updateMutation = useMutation({
    mutationFn: ({ id, data }) => base44.entities.DivineName.update(id, data),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['divineNames'] });
      setView('list');
      setEditingName(null);
    },
  });

  const deleteMutation = useMutation({
    mutationFn: (id) => base44.entities.DivineName.delete(id),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['divineNames'] });
    },
  });

  const handleSave = (data) => {
    if (editingName) {
      updateMutation.mutate({ id: editingName.id, data });
    } else {
      createMutation.mutate(data);
    }
  };

  const handleEdit = (name) => {
    setEditingName(name);
    setView('edit');
  };

  const handleCancel = () => {
    setView('list');
    setEditingName(null);
  };

  const handleExport = () => {
    const dataStr = JSON.stringify(names, null, 2);
    const blob = new Blob([dataStr], { type: 'application/json' });
    const url = URL.createObjectURL(blob);
    const link = document.createElement('a');
    link.href = url;
    link.download = `99-names-of-allah-backup-${new Date().toISOString().split('T')[0]}.json`;
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    URL.revokeObjectURL(url);
  };

  // Loading state
  if (isCheckingAuth) {
    return (
      <div className="min-h-screen bg-gray-100 flex items-center justify-center">
        <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-teal-700"></div>
      </div>
    );
  }

  // Not logged in
  if (!user) {
    return (
      <div className="min-h-screen bg-gray-100 flex items-center justify-center p-4">
        <div className="bg-white rounded-xl shadow-lg p-8 max-w-md w-full text-center">
          <Shield className="w-16 h-16 text-teal-700 mx-auto mb-4" />
          <h1 className="text-2xl font-bold mb-2">Admin Access Required</h1>
          <p className="text-gray-600 mb-6">Please log in to access the admin panel.</p>
          <Button 
            onClick={() => base44.auth.redirectToLogin()}
            className="bg-teal-700 hover:bg-teal-800"
          >
            Log In
          </Button>
        </div>
      </div>
    );
  }



  return (
    <div className="min-h-screen bg-gray-100 py-6 px-4">
      <div className="max-w-5xl mx-auto">
        {/* Header */}
        <div className="bg-teal-700 text-white rounded-t-xl p-6">
          <div className="flex items-center justify-between">
            <div>
              <h1 className="text-2xl font-bold">Admin Panel</h1>
              <p className="text-teal-100">Manage the Names of Allah</p>
              <p className="text-xs text-teal-200 mt-1">
                User: {user?.email} | Rolle: {user?.role} | isAdmin: {isAdmin ? 'Ja' : 'Nein'}
              </p>
            </div>
            <div className="flex gap-2">
              <Button 
                variant="secondary" 
                size="sm" 
                onClick={handleExport}
                disabled={names.length === 0}
              >
                <Download className="w-4 h-4 mr-2" />
                Export JSON
              </Button>
              <Link to={createPageUrl('Home')}>
                <Button variant="secondary" size="sm">
                  <ArrowLeft className="w-4 h-4 mr-2" />
                  View Site
                </Button>
              </Link>
            </div>
          </div>
        </div>

        {/* Content */}
        <div className="bg-white rounded-b-xl shadow-lg p-6">
          {view === 'list' && (
            <NamesList
              names={names}
              onEdit={isAdmin ? handleEdit : null}
              onDelete={isAdmin ? (id) => deleteMutation.mutate(id) : null}
              onAdd={isAdmin ? () => setView('add') : null}
              isLoading={isLoading}
              readOnly={!isAdmin}
            />
          )}

          {(view === 'add' || view === 'edit') && isAdmin && (
            <div>
              <div className="mb-6">
                <Button variant="ghost" onClick={handleCancel}>
                  <ArrowLeft className="w-4 h-4 mr-2" />
                  Back to List
                </Button>
                <h2 className="text-xl font-bold mt-2">
                  {view === 'add' ? 'Add New Divine Name' : `Edit: ${editingName?.name_english}`}
                </h2>
              </div>
              <NameForm
                initialData={editingName}
                onSave={handleSave}
                onCancel={handleCancel}
                isLoading={createMutation.isPending || updateMutation.isPending}
              />
            </div>
          )}
        </div>
      </div>
    </div>
  );
}
pages/NamesOverview.jsx
import React, { useState, useEffect, useRef } from 'react';
import { base44 } from '@/api/base44Client';
import { useQuery } from '@tanstack/react-query';
import { Link } from 'react-router-dom';
import { createPageUrl } from '@/utils';
import { Settings } from 'lucide-react';
import ScrollToTop from '@/components/common/ScrollToTop';

export default function NamesOverview() {
  const [visibleCount, setVisibleCount] = useState(30);
  const loaderRef = useRef(null);

  const { data: names = [], isLoading } = useQuery({
    queryKey: ['divineNames'],
    queryFn: () => base44.entities.DivineName.list('order', 100),
  });

  // Infinite scroll observer
  useEffect(() => {
    const observer = new IntersectionObserver(
      (entries) => {
        if (entries[0].isIntersecting && visibleCount < names.length) {
          setVisibleCount(prev => Math.min(prev + 20, names.length));
        }
      },
      { threshold: 0.1 }
    );

    if (loaderRef.current) {
      observer.observe(loaderRef.current);
    }

    return () => observer.disconnect();
  }, [visibleCount, names.length]);

  const visibleNames = names.slice(0, visibleCount);

  // Split visible names into 5 columns
  const columns = [[], [], [], [], []];
  visibleNames.forEach((name, index) => {
    const colIndex = Math.floor(index / Math.ceil(visibleNames.length / 5));
    if (colIndex < 5) {
      columns[colIndex].push(name);
    }
  });

  return (
    <div className="min-h-screen bg-white py-8 px-4">
      <div className="max-w-6xl mx-auto">
        {/* Header */}
        <div className="text-center mb-8 relative">
          <Link 
            to={createPageUrl('Admin')} 
            className="absolute top-0 right-0 p-2 hover:bg-gray-100 rounded-full transition-colors text-gray-500"
            title="Admin Panel"
          >
            <Settings className="w-5 h-5" />
          </Link>
          
          <div className="flex flex-col md:flex-row items-center justify-center gap-6 mb-6">
            <div className="text-left">
              <h1 className="text-3xl md:text-4xl font-serif italic text-gray-800">
                The Greatest Name,
              </h1>
              <h2 className="text-3xl md:text-4xl font-serif italic text-gray-800 mt-2">
                The All-Encompassing One
              </h2>
            </div>
            <div className="w-32 h-32 md:w-40 md:h-40">
              <div className="w-full h-full rounded-full bg-gradient-to-br from-amber-200 via-amber-400 to-amber-600 flex items-center justify-center shadow-lg">
                <span className="text-5xl md:text-6xl text-white font-arabic">الله</span>
              </div>
            </div>
          </div>
        </div>

        {/* Names Grid */}
        {isLoading ? (
          <div className="flex justify-center py-12">
            <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-teal-700"></div>
          </div>
        ) : (
          <div className="overflow-x-auto">
            <div className="grid grid-cols-2 md:grid-cols-5 gap-x-4 gap-y-1 min-w-[600px]">
              {columns.map((column, colIndex) => (
                <div key={colIndex} className="space-y-1">
                  {column.map((name) => (
                    <Link
                      key={name.id}
                      to={`${createPageUrl('Home')}?id=${name.id}`}
                      className="flex items-baseline gap-2 py-1 px-2 hover:bg-teal-50 rounded transition-colors group"
                    >
                      <span className="text-gray-500 text-sm w-6 text-right">{name.order}</span>
                      <span className="text-gray-800 group-hover:text-teal-700 transition-colors">
                        {name.name_english}
                      </span>
                    </Link>
                  ))}
                </div>
              ))}
            </div>
          </div>
        )}

        {/* Infinite Scroll Loader */}
        {visibleCount < names.length && (
          <div ref={loaderRef} className="flex justify-center py-8">
            <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-teal-700"></div>
          </div>
        )}

        {/* Link to Detail View */}
        <div className="text-center mt-8">
          <Link 
            to={createPageUrl('Home')}
            className="inline-block bg-teal-700 text-white px-6 py-3 rounded-lg hover:bg-teal-800 transition-colors"
          >
            Zur Detail-Ansicht
          </Link>
        </div>
      </div>
      <ScrollToTop />
    </div>
  );
}
pages/Search.jsx
import React, { useState, useEffect, useMemo } from 'react';
import { base44 } from '@/api/base44Client';
import { useQuery } from '@tanstack/react-query';
import { Link } from 'react-router-dom';
import { createPageUrl } from '@/utils';
import { Search as SearchIcon, ArrowLeft } from 'lucide-react';
import { Input } from "@/components/ui/input";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { debounce } from 'lodash';
import ScrollToTop from '@/components/common/ScrollToTop';

export default function Search() {
  const [inputValue, setInputValue] = useState('');
  const [searchQuery, setSearchQuery] = useState('');

  // Debounced search update
  const debouncedSetSearch = useMemo(
    () => debounce((value) => setSearchQuery(value), 300),
    []
  );

  const handleInputChange = (e) => {
    const value = e.target.value;
    setInputValue(value);
    debouncedSetSearch(value);
  };

  // Get query from URL
  useEffect(() => {
    const urlParams = new URLSearchParams(window.location.search);
    const q = urlParams.get('q');
    if (q) {
      setInputValue(q);
      setSearchQuery(q);
    }
  }, []);

  // Cleanup debounce on unmount
  useEffect(() => {
    return () => debouncedSetSearch.cancel();
  }, [debouncedSetSearch]);

  const { data: names = [], isLoading } = useQuery({
    queryKey: ['divineNames'],
    queryFn: () => base44.entities.DivineName.list('order', 100),
  });

  const filteredNames = names.filter(name => {
    const query = searchQuery.toLowerCase().trim();
    if (!query) return false;
    
    return (
      name.name_english?.toLowerCase().includes(query) ||
      name.name_arabic?.includes(searchQuery) ||
      name.short_meaning?.toLowerCase().includes(query) ||
      name.meaning_introduction?.toLowerCase().includes(query)
    );
  });

  return (
    <div className="min-h-screen bg-gray-100 py-6 px-4">
      <div className="max-w-4xl mx-auto">
        {/* Header */}
        <div className="bg-teal-700 text-white rounded-t-xl p-6">
          <div className="flex items-center gap-4 mb-4">
            <Link to={createPageUrl('Home')}>
              <Button variant="secondary" size="sm">
                <ArrowLeft className="w-4 h-4 mr-2" />
                Zurück
              </Button>
            </Link>
            <h1 className="text-2xl font-bold">Suche</h1>
          </div>
          
          {/* Search Input */}
          <div className="relative">
            <SearchIcon className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" />
            <Input
              type="text"
              placeholder="Name, Bedeutung oder arabisch suchen..."
              value={inputValue}
              onChange={handleInputChange}
              className="pl-10 bg-white text-gray-900 h-12 text-lg"
              autoFocus
            />
          </div>
        </div>

        {/* Results */}
        <div className="bg-white rounded-b-xl shadow-lg p-6">
          {isLoading ? (
            <div className="flex justify-center py-12">
              <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-teal-700"></div>
            </div>
          ) : !searchQuery.trim() ? (
            <div className="text-center py-12 text-gray-500">
              <SearchIcon className="w-16 h-16 mx-auto mb-4 text-gray-300" />
              <p className="text-lg">Gib einen Suchbegriff ein</p>
              <p className="text-sm mt-2">Suche nach englischen Namen, arabischen Namen oder Bedeutungen</p>
            </div>
          ) : filteredNames.length === 0 ? (
            <div className="text-center py-12 text-gray-500">
              <p className="text-lg">Keine Ergebnisse für "{searchQuery}"</p>
              <p className="text-sm mt-2">Versuche einen anderen Suchbegriff</p>
            </div>
          ) : (
            <div>
              <p className="text-sm text-gray-500 mb-4">
                {filteredNames.length} Ergebnis{filteredNames.length !== 1 ? 'se' : ''} für "{searchQuery}"
              </p>
              <div className="space-y-3">
                {filteredNames.map((name) => (
                  <Link
                    key={name.id}
                    to={`${createPageUrl('Home')}?id=${name.id}`}
                    className="block"
                  >
                    <Card className="hover:shadow-md transition-shadow hover:border-teal-300">
                      <CardContent className="p-4">
                        <div className="flex items-center justify-between">
                          <div>
                            <div className="flex items-center gap-3">
                              <span className="text-sm text-gray-500 bg-gray-100 px-2 py-1 rounded">
                                {name.order}
                              </span>
                              <h3 className="font-semibold text-gray-900">
                                {name.name_english}
                              </h3>
                            </div>
                            <p className="text-gray-600 mt-1">{name.short_meaning}</p>
                          </div>
                          <span className="text-3xl text-amber-500 font-arabic">
                            {name.name_arabic}
                          </span>
                        </div>
                      </CardContent>
                    </Card>
                  </Link>
                ))}
              </div>
            </div>
          )}
        </div>
      </div>
      <ScrollToTop />
    </div>
  );
}
components/divine-names/NameSelector.jsx
import React from 'react';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";

export default function NameSelector({ names, selectedId, onSelect, isLoading }) {
  if (isLoading) {
    return (
      <div className="text-center py-4">
        <div className="animate-pulse bg-gray-200 h-10 w-64 mx-auto rounded-md"></div>
      </div>
    );
  }

  return (
    <div className="text-center mb-6">
      <Select value={selectedId} onValueChange={onSelect}>
        <SelectTrigger className="w-full max-w-sm mx-auto text-lg">
          <SelectValue placeholder="Select a Divine Name" />
        </SelectTrigger>
        <SelectContent className="max-h-80 overflow-y-auto">
            {names.map((name) => (
              <SelectItem key={name.id} value={name.id}>
                {name.order}. {name.name_english} ({name.short_meaning})
              </SelectItem>
            ))}
          </SelectContent>
      </Select>
    </div>
  );
}
components/divine-names/NameDisplay.jsx
import React from 'react';
import ContentSection from './ContentSection';
import AudioPlayer from './AudioPlayer';

export default function NameDisplay({ name }) {
  if (!name) {
    return (
      <div className="text-center py-12 text-gray-500">
        <p className="text-lg">Please select a Divine Name to explore</p>
      </div>
    );
  }

  return (
    <div>
      {/* Arabic Name Display */}
      <div className="text-center mb-8">
        <span className="text-5xl md:text-6xl text-amber-700 font-arabic block mb-2">
          {name.name_arabic}
        </span>
        <h2 className="text-2xl font-bold text-gray-800">{name.name_english}</h2>
        <p className="text-lg text-gray-600 mb-3">{name.short_meaning}</p>
        <div className="flex justify-center">
          <AudioPlayer audioUrl={name.audio_url} />
        </div>
      </div>

      {/* Content Sections */}
      <div className="space-y-4">
        <ContentSection 
          title="1. Meaning & Introduction" 
          content={name.meaning_introduction} 
        />
        
        <ContentSection 
          title="2. Qur'ānic Usage and References" 
          content={name.quranic_references}
          variant="quran"
        />
        
        <ContentSection 
          title="3. Explanations of Islamic Scholars" 
          content={name.scholars_explanations} 
        />
        
        <ContentSection 
          title="4. Sayings of the Promised Messiah (Mirza Ghulam Ahmad)" 
          content={name.promised_messiah_sayings} 
        />
        
        <ContentSection 
          title="5. Spiritual Meaning" 
          content={name.spiritual_meaning}
          variant="spiritual"
        />
        
        <ContentSection 
          title="6. Practical Reflection" 
          content={name.practical_reflection}
          variant="practical"
        />
        
        <ContentSection 
          title="7. Human Service Insight" 
          content={name.human_service_insight} 
        />
      </div>
    </div>
  );
}
components/divine-names/ContentSection.jsx
import React from 'react';
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import ReactMarkdown from 'react-markdown';

export default function ContentSection({ title, content, variant = "default" }) {
  if (!content) return null;

  const variantStyles = {
    default: "bg-amber-50/50 border-amber-200",
    quran: "bg-emerald-50/70 border-l-4 border-l-emerald-600",
    spiritual: "bg-rose-50/50 border-l-4 border-l-rose-500",
    practical: "bg-orange-50/50 border-l-4 border-l-orange-500"
  };

  return (
    <Card className={`mb-4 ${variantStyles[variant]} shadow-sm`}>
      <CardHeader className="pb-2">
        <CardTitle className="text-lg font-bold text-amber-800 border-b-2 border-amber-600 pb-2">
          {title}
        </CardTitle>
      </CardHeader>
      <CardContent className="prose prose-sm max-w-none">
        <ReactMarkdown
          components={{
            a: ({ node, ...props }) => (
              <a {...props} target="_blank" rel="noopener noreferrer" className="text-amber-700 font-semibold hover:underline" />
            ),
            p: ({ node, ...props }) => <p {...props} className="mb-3 text-gray-700" />,
            ul: ({ node, ...props }) => <ul {...props} className="list-disc pl-5 mb-3" />,
            li: ({ node, ...props }) => <li {...props} className="mb-1 text-gray-700" />,
            strong: ({ node, ...props }) => <strong {...props} className="font-bold text-gray-900" />
          }}
        >
          {content}
        </ReactMarkdown>
      </CardContent>
    </Card>
  );
}
components/divine-names/AudioPlayer.jsx
import React, { useState, useRef } from 'react';
import { Button } from "@/components/ui/button";
import { Volume2, VolumeX, Loader2 } from "lucide-react";

export default function AudioPlayer({ audioUrl }) {
  const [isPlaying, setIsPlaying] = useState(false);
  const [isLoading, setIsLoading] = useState(false);
  const audioRef = useRef(null);

  if (!audioUrl) {
    return null;
  }

  const handlePlay = () => {
    if (!audioRef.current) return;
    
    if (isPlaying) {
      audioRef.current.pause();
      audioRef.current.currentTime = 0;
      setIsPlaying(false);
    } else {
      setIsLoading(true);
      audioRef.current.play()
        .then(() => {
          setIsLoading(false);
          setIsPlaying(true);
        })
        .catch(() => {
          setIsLoading(false);
        });
    }
  };

  const handleEnded = () => {
    setIsPlaying(false);
  };

  return (
    <div className="flex items-center gap-2">
      <audio 
        ref={audioRef} 
        src={audioUrl} 
        onEnded={handleEnded}
        preload="none"
      />
      <Button
        variant="outline"
        size="sm"
        onClick={handlePlay}
        disabled={isLoading}
        className="flex items-center gap-2 border-teal-300 text-teal-700 hover:bg-teal-50"
      >
        {isLoading ? (
          <Loader2 className="w-4 h-4 animate-spin" />
        ) : isPlaying ? (
          <VolumeX className="w-4 h-4" />
        ) : (
          <Volume2 className="w-4 h-4" />
        )}
        {isPlaying ? 'Stopp' : 'Aussprache anhören'}
      </Button>
    </div>
  );
}
components/admin/NamesList.jsx
import React from 'react';
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { Pencil, Trash2, Plus } from "lucide-react";
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog";

export default function NamesList({ names, onEdit, onDelete, onAdd, isLoading, readOnly = false }) {
  if (isLoading) {
    return (
      <Card>
        <CardContent className="p-6">
          <div className="animate-pulse space-y-4">
            {[1, 2, 3].map(i => (
              <div key={i} className="h-12 bg-gray-200 rounded"></div>
            ))}
          </div>
        </CardContent>
      </Card>
    );
  }

  return (
    <Card>
      <CardContent className="p-0">
        <div className="p-4 border-b flex justify-between items-center">
          <h2 className="text-lg font-semibold">Divine Names ({names.length})</h2>
          {!readOnly && onAdd && (
            <Button onClick={onAdd} className="bg-teal-700 hover:bg-teal-800">
              <Plus className="w-4 h-4 mr-2" />
              Add New Name
            </Button>
          )}
          {readOnly && (
            <span className="text-sm text-gray-500 bg-gray-100 px-3 py-1 rounded-full">
              Nur Lesezugriff
            </span>
          )}
        </div>
        
        {names.length === 0 ? (
          <div className="p-8 text-center text-gray-500">
            <p>No Divine Names added yet.</p>
            <p className="text-sm mt-2">Click "Add New Name" to get started.</p>
          </div>
        ) : (
          <Table>
            <TableHeader>
              <TableRow>
                <TableHead className="w-16">Order</TableHead>
                <TableHead>Name (English)</TableHead>
                <TableHead>Name (Arabic)</TableHead>
                <TableHead>Short Meaning</TableHead>
                {!readOnly && <TableHead className="w-24 text-right">Actions</TableHead>}
              </TableRow>
            </TableHeader>
            <TableBody>
              {names.map((name) => (
                <TableRow key={name.id}>
                  <TableCell className="font-medium">{name.order}</TableCell>
                  <TableCell className="font-medium">{name.name_english}</TableCell>
                  <TableCell className="text-xl" dir="rtl">{name.name_arabic}</TableCell>
                  <TableCell className="text-gray-600">{name.short_meaning}</TableCell>
                  {!readOnly && (
                    <TableCell className="text-right">
                      <div className="flex gap-1 justify-end">
                        <Button 
                          variant="ghost" 
                          size="icon"
                          onClick={() => onEdit(name)}
                        >
                          <Pencil className="w-4 h-4 text-blue-600" />
                        </Button>

                        <AlertDialog>
                          <AlertDialogTrigger asChild>
                            <Button variant="ghost" size="icon">
                              <Trash2 className="w-4 h-4 text-red-600" />
                            </Button>
                          </AlertDialogTrigger>
                          <AlertDialogContent>
                            <AlertDialogHeader>
                              <AlertDialogTitle>Delete "{name.name_english}"?</AlertDialogTitle>
                              <AlertDialogDescription>
                                This action cannot be undone. This will permanently delete this Divine Name and all its content.
                              </AlertDialogDescription>
                            </AlertDialogHeader>
                            <AlertDialogFooter>
                              <AlertDialogCancel>Cancel</AlertDialogCancel>
                              <AlertDialogAction 
                                onClick={() => onDelete(name.id)}
                                className="bg-red-600 hover:bg-red-700"
                              >
                                Delete
                              </AlertDialogAction>
                            </AlertDialogFooter>
                          </AlertDialogContent>
                        </AlertDialog>
                      </div>
                    </TableCell>
                  )}
                </TableRow>
              ))}
            </TableBody>
          </Table>
        )}
      </CardContent>
    </Card>
  );
}
components/admin/NameForm.jsx
import React, { useState, useEffect } from 'react';
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
import { Save, X, BookOpen, Sparkles, Heart, Users, Volume2, Upload } from "lucide-react";
import { base44 } from '@/api/base44Client';

const SECTIONS = [
  { key: 'meaning_introduction', label: 'Meaning & Introduction', icon: BookOpen, variant: 'default', description: 'Explain the linguistic meaning and provide an introduction to this Divine Name.' },
  { key: 'quranic_references', label: 'Quranic Usage and References', icon: BookOpen, variant: 'quran', description: 'List verses from the Quran where this name appears or is referenced.' },
  { key: 'scholars_explanations', label: 'Explanations of Islamic Scholars', icon: BookOpen, variant: 'default', description: 'Include insights and interpretations from classical and contemporary scholars.' },
  { key: 'promised_messiah_sayings', label: 'Sayings of the Promised Messiah', icon: Sparkles, variant: 'default', description: 'Quotes and teachings from Mirza Ghulam Ahmad about this name.' },
  { key: 'spiritual_meaning', label: 'Spiritual Meaning', icon: Sparkles, variant: 'spiritual', description: 'Explore the deeper spiritual significance and connection to the soul.' },
  { key: 'practical_reflection', label: 'Practical Reflection', icon: Heart, variant: 'practical', description: 'How can one apply this attribute in daily life and personal growth?' },
  { key: 'human_service_insight', label: 'Human Service Insight', icon: Users, variant: 'default', description: 'How does this name inspire service to humanity?' },
];

const variantStyles = {
  default: 'bg-white border-gray-200 hover:border-gray-300',
  quran: 'bg-emerald-50 border-emerald-200 hover:border-emerald-300',
  spiritual: 'bg-purple-50 border-purple-200 hover:border-purple-300',
  practical: 'bg-amber-50 border-amber-200 hover:border-amber-300',
};

const iconStyles = {
  default: 'text-teal-600',
  quran: 'text-emerald-600',
  spiritual: 'text-purple-600',
  practical: 'text-amber-600',
};

export default function NameForm({ initialData, onSave, onCancel, isLoading }) {
  const [formData, setFormData] = useState({
    name_english: '',
    name_arabic: '',
    short_meaning: '',
    order: 1,
    audio_url: '',
    meaning_introduction: '',
    quranic_references: '',
    scholars_explanations: '',
    promised_messiah_sayings: '',
    spiritual_meaning: '',
    practical_reflection: '',
    human_service_insight: '',
  });
  const [isUploadingAudio, setIsUploadingAudio] = useState(false);

  useEffect(() => {
    if (initialData) {
      setFormData({
        name_english: initialData.name_english || '',
        name_arabic: initialData.name_arabic || '',
        short_meaning: initialData.short_meaning || '',
        order: initialData.order || 1,
        audio_url: initialData.audio_url || '',
        meaning_introduction: initialData.meaning_introduction || '',
        quranic_references: initialData.quranic_references || '',
        scholars_explanations: initialData.scholars_explanations || '',
        promised_messiah_sayings: initialData.promised_messiah_sayings || '',
        spiritual_meaning: initialData.spiritual_meaning || '',
        practical_reflection: initialData.practical_reflection || '',
        human_service_insight: initialData.human_service_insight || '',
      });
    }
  }, [initialData]);

  const handleAudioUpload = async (e) => {
    const file = e.target.files?.[0];
    if (!file) return;
    
    setIsUploadingAudio(true);
    const { file_url } = await base44.integrations.Core.UploadFile({ file });
    setFormData(prev => ({ ...prev, audio_url: file_url }));
    setIsUploadingAudio(false);
  };

  const handleChange = (field, value) => {
    setFormData(prev => ({ ...prev, [field]: value }));
  };

  const handleSubmit = (e) => {
    e.preventDefault();
    onSave(formData);
  };

  return (
    <form onSubmit={handleSubmit} className="space-y-6">
      <Card className="border-2 border-teal-200 bg-teal-50/50">
        <CardHeader className="pb-4">
          <CardTitle className="text-teal-800 flex items-center gap-2">
            <Sparkles className="w-5 h-5" />
            Basic Information
          </CardTitle>
          <CardDescription>Enter the fundamental details of this Divine Name</CardDescription>
        </CardHeader>
        <CardContent className="grid grid-cols-1 md:grid-cols-2 gap-6">
          <div className="space-y-2">
            <Label htmlFor="name_english" className="text-sm font-medium text-gray-700">
              Name (English Transliteration)
            </Label>
            <Input
              id="name_english"
              value={formData.name_english}
              onChange={(e) => handleChange('name_english', e.target.value)}
              placeholder="e.g., Al-Rahman"
              className="bg-white border-gray-300 focus:border-teal-500 focus:ring-teal-500"
              required
            />
          </div>
          <div className="space-y-2">
            <Label htmlFor="name_arabic" className="text-sm font-medium text-gray-700">
              Name (Arabic Script)
            </Label>
            <Input
              id="name_arabic"
              value={formData.name_arabic}
              onChange={(e) => handleChange('name_arabic', e.target.value)}
              placeholder="e.g., الرَّحْمٰن"
              className="text-right text-2xl font-arabic bg-white border-gray-300 focus:border-teal-500 focus:ring-teal-500 h-12"
              dir="rtl"
              required
            />
          </div>
          <div className="space-y-2">
            <Label htmlFor="short_meaning" className="text-sm font-medium text-gray-700">
              Brief Meaning
            </Label>
            <Input
              id="short_meaning"
              value={formData.short_meaning}
              onChange={(e) => handleChange('short_meaning', e.target.value)}
              placeholder="e.g., The Most Merciful"
              className="bg-white border-gray-300 focus:border-teal-500 focus:ring-teal-500"
              required
            />
          </div>
          <div className="space-y-2">
            <Label htmlFor="order" className="text-sm font-medium text-gray-700">
              Display Order (1-99)
            </Label>
            <Input
              id="order"
              type="number"
              value={formData.order}
              onChange={(e) => handleChange('order', parseInt(e.target.value) || 1)}
              min="1"
              max="99"
              className="bg-white border-gray-300 focus:border-teal-500 focus:ring-teal-500"
            />
          </div>
          <div className="space-y-2 md:col-span-2">
            <Label htmlFor="audio" className="text-sm font-medium text-gray-700 flex items-center gap-2">
              <Volume2 className="w-4 h-4" />
              Audio-Rezitation
            </Label>
            <div className="flex items-center gap-3">
              <label className="cursor-pointer">
                <Input
                  id="audio"
                  type="file"
                  accept="audio/*"
                  onChange={handleAudioUpload}
                  className="hidden"
                />
                <div className="flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors">
                  <Upload className="w-4 h-4" />
                  {isUploadingAudio ? 'Lädt hoch...' : 'Audio hochladen'}
                </div>
              </label>
              {formData.audio_url && (
                <div className="flex items-center gap-2 text-sm text-green-600">
                  <Volume2 className="w-4 h-4" />
                  Audio vorhanden
                  <audio src={formData.audio_url} controls className="h-8" />
                </div>
              )}
            </div>
          </div>
        </CardContent>
      </Card>

      {SECTIONS.map((section, index) => {
        const IconComponent = section.icon;
        return (
          <Card key={section.key} className={`border-2 transition-colors ${variantStyles[section.variant]}`}>
            <CardHeader className="pb-3">
              <CardTitle className="text-base font-semibold flex items-center gap-2">
                <IconComponent className={`w-5 h-5 ${iconStyles[section.variant]}`} />
                <span className="text-gray-500 font-normal">{index + 1}.</span>
                {section.label}
              </CardTitle>
              <CardDescription className="text-sm">
                {section.description}
              </CardDescription>
            </CardHeader>
            <CardContent>
              <Textarea
                value={formData[section.key]}
                onChange={(e) => handleChange(section.key, e.target.value)}
                placeholder="Enter content here... (Markdown formatting is supported)"
                className="min-h-36 bg-white border-gray-300 focus:border-teal-500 focus:ring-teal-500 resize-y"
              />
              <p className="text-xs text-gray-500 mt-2">
                💡 Markdown: **bold**, *italic*, [link text](url), - bullet lists
              </p>
            </CardContent>
          </Card>
        );
      })}

      <div className="flex gap-3 justify-end sticky bottom-4 bg-white p-4 rounded-lg shadow-lg">
        <Button type="button" variant="outline" onClick={onCancel} disabled={isLoading}>
          <X className="w-4 h-4 mr-2" />
          Cancel
        </Button>
        <Button type="submit" className="bg-teal-700 hover:bg-teal-800" disabled={isLoading}>
          <Save className="w-4 h-4 mr-2" />
          {isLoading ? 'Saving...' : 'Save'}
        </Button>
      </div>
    </form>
  );
}
components/common/ScrollToTop.jsx
import React, { useState, useEffect } from 'react';
import { Button } from "@/components/ui/button";
import { ArrowUp } from "lucide-react";

export default function ScrollToTop() {
  const [isVisible, setIsVisible] = useState(false);

  useEffect(() => {
    const toggleVisibility = () => {
      setIsVisible(window.scrollY > 300);
    };

    window.addEventListener('scroll', toggleVisibility);
    return () => window.removeEventListener('scroll', toggleVisibility);
  }, []);

  const scrollToTop = () => {
    window.scrollTo({ top: 0, behavior: 'smooth' });
  };

  if (!isVisible) return null;

  return (
    <Button
      onClick={scrollToTop}
      className="fixed bottom-6 right-6 rounded-full w-12 h-12 bg-teal-700 hover:bg-teal-800 shadow-lg z-50"
      size="icon"
    >
      <ArrowUp className="w-5 h-5" />
    </Button>
  );
}
base44
Edit with Base44