File size: 39,183 Bytes
96b1102 36d9cf7 96b1102 36d9cf7 96b1102 36d9cf7 96b1102 36d9cf7 96b1102 36d9cf7 96b1102 f0887f8 96b1102 53721df 96b1102 53721df 96b1102 f0887f8 96b1102 53721df 96b1102 f0887f8 96b1102 f0887f8 96b1102 f0887f8 96b1102 f0887f8 96b1102 f0887f8 96b1102 f0887f8 96b1102 53721df f0887f8 53721df 96b1102 36d9cf7 96b1102 36d9cf7 96b1102 53721df 96b1102 36d9cf7 96b1102 36d9cf7 96b1102 f2f6bf4 f0887f8 96b1102 f0887f8 96b1102 485bef2 96b1102 53721df 485bef2 53721df 485bef2 53721df 485bef2 96b1102 53721df 96b1102 53721df 96b1102 f0887f8 96b1102 f0887f8 96b1102 53721df 96b1102 53721df f0887f8 53721df 96b1102 53721df 96b1102 f0887f8 96b1102 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tableau d'Annonces - Petites annonces locales</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');
body {
font-family: 'Comic Neue', cursive;
background-color: #f5f5f5;
}
.cork-board {
background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="%23b08968" /><circle cx="20" cy="20" r="5" fill="%239c6e54" /><circle cx="60" cy="30" r="7" fill="%239c6e54" /><circle cx="40" cy="60" r="6" fill="%239c6e54" /><circle cx="70" cy="70" r="4" fill="%239c6e54" /><circle cx="30" cy="80" r="5" fill="%239c6e54" /></svg>');
background-size: 50px 50px;
min-height: 100vh;
border: 15px solid #8B5A2B;
border-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="%238B5A2B" /><path d="M0,20 Q25,10 50,20 T100,20 L100,30 Q75,40 50,30 T0,30 Z" fill="%23A67C52" /><path d="M0,50 Q25,40 50,50 T100,50 L100,60 Q75,70 50,60 T0,60 Z" fill="%23A67C52" /><path d="M0,80 Q25,70 50,80 T100,80 L100,90 Q75,100 50,90 T0,90 Z" fill="%23A67C52" />') 30 round;
box-shadow: 0 0 30px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.3);
}
.post-it {
box-shadow: 2px 2px 5px rgba(0,0,0,0.5), 0 0 2px rgba(0,0,0,0.3);
transform: rotate(-1deg);
transition: all 0.3s ease;
position: relative;
}
.post-it:hover {
transform: rotate(0deg) scale(1.05);
box-shadow: 8px 8px 10px rgba(0,0,0,0.4);
}
.post-it-animation {
animation: appear 0.5s ease-out;
}
@keyframes appear {
from {
opacity: 0;
transform: translateY(20px) rotate(-5deg);
}
to {
opacity: 1;
transform: translateY(0) rotate(-1deg);
}
}
.pin {
width: 20px;
height: 20px;
background: radial-gradient(circle at 30% 30%, #fff, #aaa 40%, #333 70%);
border-radius: 50%;
box-shadow: 0 0 5px rgba(0,0,0,0.5);
position: absolute;
top: -10px;
left: 50%;
transform: translateX(-50%);
}
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect } = React;
// Simulate API calls
const mockApi = {
login: async (email, password) => {
return { success: true, token: 'mock-token', user: { id: 1, name: 'Test User', email } };
},
register: async (name, email, password, city) => {
return { success: true, user: { id: 2, name, email, city } };
},
getAds: async () => {
return [
{
id: 1,
title: "Vélo à vendre",
description: "Vélo de ville en bon état, taille M",
phone: "0612345678",
city: "Maurepas",
author: "Jean Dupont",
likes: 5,
price: 120,
comments: [
{ id: 1, author: "Marie", text: "Est-il encore disponible ?" },
{ id: 2, author: "Jean", text: "Oui, toujours disponible !" }
],
color: "yellow"
},
{
id: 2,
title: "Cours de piano",
description: "Donne cours de piano pour débutants",
phone: "0698765432",
city: "Maurepas",
author: "Sophie Martin",
likes: 3,
price: 25,
comments: [],
color: "pink"
},
{
id: 3,
title: "Cherche baby-sitter",
description: "Recherche baby-sitter pour nos enfants 2 soirs par semaine",
phone: "0601020304",
city: "Elancourt",
author: "Thomas Leroy",
likes: 2,
comments: [],
color: "blue"
}
];
},
createAd: async (adData) => {
return {
success: true,
ad: {
...adData,
id: Math.floor(Math.random() * 1000),
likes: 0,
comments: [],
photo: adData.photo || null
}
};
},
likeAd: async (adId) => {
return { success: true };
},
addComment: async (adId, comment) => {
return { success: true, comment: { id: Math.floor(Math.random() * 1000), author: "Current User", text: comment } };
}
};
const App = () => {
const [user, setUser] = useState(null);
const [ads, setAds] = useState([]);
const [selectedCity, setSelectedCity] = useState("Maurepas");
const [showLogin, setShowLogin] = useState(false);
const [showRegister, setShowRegister] = useState(false);
const [showAdForm, setShowAdForm] = useState(false);
const [cities, setCities] = useState(["Maurepas", "Elancourt", "Trappes", "Montigny", "Guyancourt"]);
useEffect(() => {
// Simulate loading all ads
const loadAds = async () => {
const data = await mockApi.getAds();
setAds(data);
};
loadAds();
}, []);
const handleLogin = async (email, password) => {
const result = await mockApi.login(email, password);
if (result.success) {
setUser(result.user);
setShowLogin(false);
}
};
const handleRegister = async (name, email, password, city) => {
const result = await mockApi.register(name, email, password, city);
if (result.success) {
setUser(result.user);
setShowRegister(false);
setSelectedCity(city);
}
};
const handleCreateAd = async (title, description, phone, city, color, price, photo) => {
// Ajouter la nouvelle ville si elle n'existe pas déjà
const newCity = city.trim();
if (newCity && !cities.includes(newCity)) {
setCities([...cities, newCity]);
}
const result = await mockApi.createAd({
title,
description,
phone,
city: newCity,
author: user.name,
color,
price: price === "" ? null : Number(price),
photo: photo ? URL.createObjectURL(photo) : null
});
if (result.success) {
setAds([result.ad, ...ads]);
setShowAdForm(false);
}
};
const handleLike = async (adId) => {
if (!user) {
setShowLogin(true);
return;
}
await mockApi.likeAd(adId);
setAds(ads.map(ad =>
ad.id === adId ? { ...ad, likes: ad.likes + 1 } : ad
));
};
const handleAddComment = async (adId, comment) => {
if (!user) {
setShowLogin(true);
return;
}
const result = await mockApi.addComment(adId, comment);
if (result.success) {
setAds(ads.map(ad =>
ad.id === adId ? { ...ad, comments: [...ad.comments, result.comment] } : ad
));
}
};
return (
<div className="min-h-screen">
{/* Header */}
<header className="bg-gray-700 text-white shadow-md" style={{
background: 'linear-gradient(135deg, #4b5563 0%, #6b7280 50%, #4b5563 100%)',
borderBottom: '1px solid #9ca3af'
}}>
<div className="container mx-auto px-4 py-3 flex justify-between items-center">
<h1 className="text-2xl font-bold">Tableau d'Annonces</h1>
<div className="flex items-center space-x-4">
<select
value={selectedCity}
onChange={(e) => setSelectedCity(e.target.value)}
className="bg-amber-600 hover:bg-amber-500 text-white px-3 py-1 rounded-md transition-colors"
>
{cities.map(city => (
<option key={city} value={city}>{city}</option>
))}
</select>
{user ? (
<div className="flex items-center space-x-2">
<span>Bonjour, {user.name}</span>
<button
onClick={() => setShowAdForm(true)}
className="bg-amber-600 hover:bg-amber-500 px-3 py-1 rounded-md"
>
Nouvelle annonce
</button>
</div>
) : (
<div className="flex space-x-2">
<button
onClick={() => setShowLogin(true)}
className="bg-gray-600 hover:bg-gray-500 px-3 py-1 rounded-md transition-colors"
>
Connexion
</button>
<button
onClick={() => setShowRegister(true)}
className="bg-gray-500 hover:bg-gray-400 px-3 py-1 rounded-md transition-colors"
>
Inscription
</button>
</div>
)}
</div>
</div>
</header>
{/* Main content */}
<main className="cork-board">
<div className="container mx-auto px-4 pt-4 pb-8">
<div className="mb-8">
<h2 className="text-xl font-semibold mb-4 text-amber-900">Annonces - {selectedCity}</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{ads
.filter(ad => ad.city === selectedCity)
.map(ad => (
<PostIt
key={ad.id}
ad={ad}
onLike={handleLike}
onAddComment={handleAddComment}
isLoggedIn={!!user}
/>
))}
</div>
</div>
</div>
</main>
{/* Modals */}
{showLogin && (
<LoginModal
onClose={() => setShowLogin(false)}
onLogin={handleLogin}
onSwitchToRegister={() => {
setShowLogin(false);
setShowRegister(true);
}}
/>
)}
{showRegister && (
<RegisterModal
onClose={() => setShowRegister(false)}
onRegister={handleRegister}
cities={cities}
onSwitchToLogin={() => {
setShowRegister(false);
setShowLogin(true);
}}
/>
)}
{showAdForm && (
<AdFormModal
onClose={() => setShowAdForm(false)}
onCreateAd={handleCreateAd}
cities={cities}
selectedCity={selectedCity}
/>
)}
</div>
);
};
const PostIt = ({ ad, onLike, onAddComment, isLoggedIn }) => {
const [showComments, setShowComments] = useState(false);
const [newComment, setNewComment] = useState("");
const [showPhotoModal, setShowPhotoModal] = useState(false);
const bgColors = {
yellow: "bg-yellow-200",
pink: "bg-pink-200",
blue: "bg-blue-200",
green: "bg-green-200"
};
return (
<div className={`post-it post-it-animation ${bgColors[ad.color]} relative p-4 rounded-md`}>
<div className="pin"></div>
<h3 className="font-bold text-lg mb-2">{ad.title}</h3>
{ad.photo && (
<div className="mb-3 cursor-pointer" onClick={() => setShowPhotoModal(true)}>
<img
src={ad.photo}
alt={ad.title}
className="w-full h-40 object-cover rounded hover:opacity-90 transition-opacity"
/>
</div>
)}
{showPhotoModal && (
<div className="fixed inset-0 bg-black bg-opacity-90 flex items-center justify-center z-50 p-4" onClick={() => setShowPhotoModal(false)}>
<div className="relative max-w-full max-h-full">
<img
src={ad.photo}
alt={ad.title}
className="max-w-full max-h-[90vh] object-contain"
/>
<button
className="absolute top-4 right-4 bg-black bg-opacity-50 text-white p-2 rounded-full hover:bg-opacity-70"
onClick={(e) => {
e.stopPropagation();
setShowPhotoModal(false);
}}
>
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
)}
<p className="mb-3">{ad.description}</p>
<div className="flex justify-between items-center mb-2">
<div className="text-sm text-gray-700">
<span className="font-semibold">Tél:</span> {ad.phone}
</div>
{ad.price ? (
<div className="text-sm font-semibold bg-amber-100 px-2 py-1 rounded">
{ad.price} €
</div>
) : (
<div className="text-sm font-semibold bg-green-100 px-2 py-1 rounded text-green-800">
Contactez-moi
</div>
)}
</div>
<div className="text-xs text-gray-600 mb-3">
Publié par {ad.author}
</div>
<div className="flex justify-between items-center border-t border-gray-300 pt-2 mt-3">
<button
onClick={() => onLike(ad.id)}
className="flex items-center space-x-1 text-gray-700 hover:text-red-500"
>
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
</svg>
<span>{ad.likes}</span>
</button>
<button
onClick={() => setShowComments(!showComments)}
className="text-sm text-gray-700 hover:underline"
>
{ad.comments.length} commentaire{ad.comments.length !== 1 ? 's' : ''}
</button>
</div>
{showComments && (
<div className="mt-3">
<div className="space-y-2 max-h-40 overflow-y-auto">
{ad.comments.map(comment => (
<div key={comment.id} className="bg-white bg-opacity-50 p-2 rounded">
<div className="font-semibold text-sm">{comment.author}</div>
<div className="text-sm">{comment.text}</div>
</div>
))}
</div>
{isLoggedIn && (
<div className="mt-3 flex">
<input
type="text"
value={newComment}
onChange={(e) => setNewComment(e.target.value)}
placeholder="Ajouter un commentaire..."
className="flex-1 px-2 py-1 text-sm border rounded-l"
/>
<button
onClick={() => {
onAddComment(ad.id, newComment);
setNewComment("");
}}
className="bg-amber-600 text-white px-2 py-1 rounded-r text-sm"
>
Envoyer
</button>
</div>
)}
</div>
)}
</div>
);
};
const LoginModal = ({ onClose, onLogin, onSwitchToRegister }) => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
return (
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div className="bg-white rounded-lg p-6 w-full max-w-md">
<div className="flex justify-between items-center mb-4">
<h3 className="text-xl font-bold">Connexion</h3>
<button onClick={onClose} className="text-gray-500 hover:text-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div className="space-y-4">
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Mot de passe</label>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div className="flex justify-between items-center pt-2">
<button
onClick={() => onLogin(email, password)}
className="bg-amber-600 text-white px-4 py-2 rounded-md hover:bg-amber-500"
>
Se connecter
</button>
<button
onClick={onSwitchToRegister}
className="text-amber-600 hover:underline text-sm"
>
Pas encore inscrit ?
</button>
</div>
</div>
</div>
</div>
);
};
const RegisterModal = ({ onClose, onRegister, cities, onSwitchToLogin }) => {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [city, setCity] = useState(cities[0]);
return (
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div className="bg-white rounded-lg p-6 w-full max-w-md">
<div className="flex justify-between items-center mb-4">
<h3 className="text-xl font-bold">Inscription</h3>
<button onClick={onClose} className="text-gray-500 hover:text-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div className="space-y-4">
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Nom complet</label>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Mot de passe</label>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Ville</label>
<select
value={city}
onChange={(e) => setCity(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
>
{cities.map(c => (
<option key={c} value={c}>{c}</option>
))}
</select>
</div>
<div className="flex justify-between items-center pt-2">
<button
onClick={() => onRegister(name, email, password, city)}
className="bg-amber-600 text-white px-4 py-2 rounded-md hover:bg-amber-500"
>
S'inscrire
</button>
<button
onClick={onSwitchToLogin}
className="text-amber-600 hover:underline text-sm"
>
Déjà un compte ?
</button>
</div>
</div>
</div>
</div>
);
};
const AdFormModal = ({ onClose, onCreateAd, cities, selectedCity }) => {
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [phone, setPhone] = useState("");
const [city, setCity] = useState("");
const [color, setColor] = useState("yellow");
const [price, setPrice] = useState(null);
const [photo, setPhoto] = useState(null);
const [photoPreview, setPhotoPreview] = useState(null);
return (
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div className="bg-white rounded-lg p-6 w-full max-w-md">
<div className="flex justify-between items-center mb-4">
<h3 className="text-xl font-bold">Nouvelle annonce</h3>
<button onClick={onClose} className="text-gray-500 hover:text-gray-700">
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div className="space-y-4">
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Titre</label>
<input
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea
value={description}
onChange={(e) => setDescription(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
rows="4"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Téléphone</label>
<input
type="tel"
value={phone}
onChange={(e) => setPhone(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Ville</label>
<input
type="text"
value={city}
onChange={(e) => setCity(e.target.value)}
className="w-full px-3 py-2 border rounded-md"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Photo</label>
<input
type="file"
accept="image/*"
onChange={(e) => {
const file = e.target.files[0];
if (file) {
setPhoto(file);
setPhotoPreview(URL.createObjectURL(file));
}
}}
className="w-full px-3 py-2 border rounded-md"
/>
{photoPreview && (
<div className="mt-2">
<img
src={photoPreview}
alt="Preview"
className="max-h-40 object-contain rounded"
/>
</div>
)}
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Couleur du Post-it</label>
<div className="flex space-x-2">
{["yellow", "pink", "blue", "green"].map(c => (
<button
key={c}
onClick={() => setColor(c)}
className={`w-8 h-8 rounded-full ${color === c ? 'ring-2 ring-offset-2 ring-amber-500' : ''}`}
style={{ backgroundColor:
c === "yellow" ? "#fef08a" :
c === "pink" ? "#fbcfe8" :
c === "blue" ? "#bfdbfe" :
"#bbf7d0"
}}
></button>
))}
</div>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Type d'annonce</label>
<div className="flex space-x-4">
<div className="flex items-center">
<input
type="radio"
id="priceOption"
name="announceType"
checked={price !== null}
onChange={() => setPrice("")}
className="mr-2"
/>
<label htmlFor="priceOption" className="text-sm">
Avec prix
</label>
{price !== null && (
<input
type="number"
value={price}
onChange={(e) => setPrice(e.target.value)}
className="ml-2 px-2 py-1 border rounded-md w-20"
placeholder="€"
/>
)}
</div>
<div className="flex items-center">
<input
type="radio"
id="contactOption"
name="announceType"
checked={price === null}
onChange={() => setPrice(null)}
className="mr-2"
/>
<label htmlFor="contactOption" className="text-sm">
Contactez-moi
</label>
</div>
</div>
</div>
<div className="flex justify-end pt-4">
<button
onClick={() => onCreateAd(title, description, phone, city, color, price, photo)}
className="bg-amber-600 text-white px-4 py-2 rounded-md hover:bg-amber-500"
>
Publier
</button>
</div>
</div>
</div>
</div>
);
};
ReactDOM.render(<App />, document.getElementById('root'));
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Sheld0ne/postly" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |