fork download
  1. import { useState } from 'react';
  2. import { Card, CardContent } from '@/components/ui/card';
  3. import { Button } from '@/components/ui/button';
  4. import { Input } from '@/components/ui/input';
  5. import { Textarea } from '@/components/ui/textarea';
  6.  
  7. export default function IceDeliveryApp() {
  8. const [orders, setOrders] = useState([]);
  9. const [form, setForm] = useState({
  10. customer: '',
  11. location: '',
  12. quantity: '',
  13. note: '',
  14. });
  15.  
  16. const handleChange = (e) => {
  17. setForm({ ...form, [e.target.name]: e.target.value });
  18. };
  19.  
  20. const handleSubmit = () => {
  21. if (form.customer && form.location && form.quantity) {
  22. setOrders([...orders, { ...form, id: Date.now() }]);
  23. setForm({ customer: '', location: '', quantity: '', note: '' });
  24. }
  25. };
  26.  
  27. return (
  28. <div className="max-w-2xl mx-auto p-4 space-y-6">
  29. <h1 className="text-2xl font-bold">ระบบจัดการออเดอร์ส่งน้ำแข็ง (เชียงใหม่)</h1>
  30.  
  31. <Card>
  32. <CardContent className="space-y-4 p-4">
  33. <Input
  34. placeholder="ชื่อลูกค้า"
  35. name="customer"
  36. value={form.customer}
  37. onChange={handleChange}
  38. />
  39. <Input
  40. placeholder="สถานที่จัดส่ง"
  41. name="location"
  42. value={form.location}
  43. onChange={handleChange}
  44. />
  45. <Input
  46. placeholder="จำนวนกระสอบน้ำแข็ง"
  47. name="quantity"
  48. type="number"
  49. value={form.quantity}
  50. onChange={handleChange}
  51. />
  52. <Textarea
  53. placeholder="หมายเหตุเพิ่มเติม (ถ้ามี)"
  54. name="note"
  55. value={form.note}
  56. onChange={handleChange}
  57. />
  58. <Button onClick={handleSubmit} className="w-full">
  59. เพิ่มออเดอร์
  60. </Button>
  61. </CardContent>
  62. </Card>
  63.  
  64. <div className="space-y-4">
  65. {orders.map((order) => (
  66. <Card key={order.id}>
  67. <CardContent className="p-4">
  68. <p><strong>ลูกค้า:</strong> {order.customer}</p>
  69. <p><strong>สถานที่:</strong> {order.location}</p>
  70. <p><strong>จำนวน:</strong> {order.quantity} กระสอบ</p>
  71. {order.note && <p><strong>หมายเหตุ:</strong> {order.note}</p>}
  72. </CardContent>
  73. </Card>
  74. ))}
Success #stdin #stdout 0.03s 25272KB
stdin
Standard input is empty
stdout
import { useState } from 'react';
import { Card, CardContent } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';

export default function IceDeliveryApp() {
  const [orders, setOrders] = useState([]);
  const [form, setForm] = useState({
    customer: '',
    location: '',
    quantity: '',
    note: '',
  });

  const handleChange = (e) => {
    setForm({ ...form, [e.target.name]: e.target.value });
  };

  const handleSubmit = () => {
    if (form.customer && form.location && form.quantity) {
      setOrders([...orders, { ...form, id: Date.now() }]);
      setForm({ customer: '', location: '', quantity: '', note: '' });
    }
  };

  return (
    <div className="max-w-2xl mx-auto p-4 space-y-6">
      <h1 className="text-2xl font-bold">ระบบจัดการออเดอร์ส่งน้ำแข็ง (เชียงใหม่)</h1>

      <Card>
        <CardContent className="space-y-4 p-4">
          <Input
            placeholder="ชื่อลูกค้า"
            name="customer"
            value={form.customer}
            onChange={handleChange}
          />
          <Input
            placeholder="สถานที่จัดส่ง"
            name="location"
            value={form.location}
            onChange={handleChange}
          />
          <Input
            placeholder="จำนวนกระสอบน้ำแข็ง"
            name="quantity"
            type="number"
            value={form.quantity}
            onChange={handleChange}
          />
          <Textarea
            placeholder="หมายเหตุเพิ่มเติม (ถ้ามี)"
            name="note"
            value={form.note}
            onChange={handleChange}
          />
          <Button onClick={handleSubmit} className="w-full">
            เพิ่มออเดอร์
          </Button>
        </CardContent>
      </Card>

      <div className="space-y-4">
        {orders.map((order) => (
          <Card key={order.id}>
            <CardContent className="p-4">
              <p><strong>ลูกค้า:</strong> {order.customer}</p>
              <p><strong>สถานที่:</strong> {order.location}</p>
              <p><strong>จำนวน:</strong> {order.quantity} กระสอบ</p>
              {order.note && <p><strong>หมายเหตุ:</strong> {order.note}</p>}
            </CardContent>
          </Card>
        ))}