Deepseek ArtifactsDeepseek Artifacts

React.js 费用追踪应用

4.0
en
Web 开发
React.js
费用管理
Google Sheets

Prompt

Build me a simple but professional expense tracking web application using React.js (or another suitable modern framework) for use in an interior finishing company (focused on villas).

Features required:
Expense Entry Form:

Text input: "Expense Description"

Number input: "Amount in EGP"

Dropdown menu: "Select Project" (e.g., Villa El Qarnfel, Duplex El Qarnfel, Palm Hills Villa...)

Dropdown menu: "Select Item" (e.g., Electrical, Plumbing, Carpentry...)

Dropdown menu: "Select Contractor"

Submit button that sends the input to a connected Google Sheet using Google Apps Script or the Sheets API.

Google Sheet backend should collect and organize data by:

Project name

Date

Amount

Contractor name

Item name

Expense description

The UI should be professional and clean, preferably using Tailwind CSS or a similar framework.

The app should be mobile responsive and easily accessible from both desktop and mobile.

Generated Result

import React, { useState } from 'react';

const App = () => {
  const [expenseDescription, setExpenseDescription] = useState('');
  const [amount, setAmount] = useState('');
  const [selectedProject, setSelectedProject] = useState('');
  const [selectedItem, setSelectedItem] = useState('');
  const [selectedContractor, setSelectedContractor] = useState('');

  const projects = ['Villa El Qarnfel', 'Duplex El Qarnfel', 'Palm Hills Villa'];
  const items = ['Electrical', 'Plumbing', 'Carpentry'];
  const contractors = ['Contractor A', 'Contractor B', 'Contractor C'];

  const handleSubmit = (e) => {
    e.preventDefault();
    const expenseData = {
      expenseDescription,
      amount,
      selectedProject,
      selectedItem,
      selectedContractor,
      date: new Date().toLocaleDateString(),
    };
    console.log(expenseData);
    // Here you would send the data to Google Sheets
  };

  return (
    <div className="min-h-screen bg-gray-100 flex items-center justify-center p-4">
      <div className="bg-white p-8 rounded-lg shadow-lg w-full max-w-md">
        <h1 className="text-2xl font-bold mb-6 text-center text-gray-800">Expense Tracker</h1>
        <form onSubmit={handleSubmit} className="space-y-4">
          <div>
            <label className="block text-sm font-medium text-gray-700">Expense Description</label>
            <input
              type="text"
              value={expenseDescription}
              onChange={(e) => setExpenseDescription(e.target.value)}
              className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
              required
            />
          </div>
          <div>
            <label className="block text-sm font-medium text-gray-700">Amount in EGP</label>
            <input
              type="number"
              value={amount}
              onChange={(e) => setAmount(e.target.value)}
              className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
              required
            />
          </div>
          <div>
            <label className="block text-sm font-medium text-gray-700">Select Project</label>
            <select
              value={selectedProject}
              onChange={(e) => setSelectedProject(e.target.value)}
              className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
              required
            >
              <option value="">Select a project</option>
              {projects.map((project) => (
                <option key={project} value={project}>
                  {project}
                </option>
              ))}
            </select>
          </div>
          <div>
            <label className="block text-sm font-medium text-gray-700">Select Item</label>
            <select
              value={selectedItem}
              onChange={(e) => setSelectedItem(e.target.value)}
              className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
              required
            >
              <option value="">Select an item</option>
              {items.map((item) => (
                <option key={item} value={item}>
                  {item}
                </option>
              ))}
            </select>
          </div>
          <div>
            <label className="block text-sm font-medium text-gray-700">Select Contractor</label>
            <select
              value={selectedContractor}
              onChange={(e) => setSelectedContractor(e.target.value)}
              className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
              required
            >
              <option value="">Select a contractor</option>
              {contractors.map((contractor) => (
                <option key={contractor} value={contractor}>
                  {contractor}
                </option>
              ))}
            </select>
          </div>
          <div>
            <button
              type="submit"
              className="w-full bg-indigo-600 text-white py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
            >
              Submit Expense
            </button>
          </div>
        </form>
      </div>
    </div>
  );
};

export default App;

More Recommendations

View All