Open dwip708 opened 4 days ago
I am working on this . Please assign this to me @dwip708 .
`import React, { useState } from 'react'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Pencil, Plus, Save, X } from 'lucide-react';
const AddressComponent = () => { // Dummy initial addresses data const initialAddresses = [ { id: 1, type: 'Home', street: '123 Main St', city: 'San Francisco', state: 'CA', zipCode: '94105', isDefault: true }, { id: 2, type: 'Work', street: '456 Market St', city: 'San Francisco', state: 'CA', zipCode: '94103', isDefault: false } ];
const [addresses, setAddresses] = useState(initialAddresses); const [editingId, setEditingId] = useState(null); const [isAdding, setIsAdding] = useState(false); const [newAddress, setNewAddress] = useState({ type: '', street: '', city: '', state: '', zipCode: '', isDefault: false });
const handleEdit = (id) => { setEditingId(id); setIsAdding(false); };
const handleSave = (id) => { setEditingId(null); };
const handleCancel = () => { setEditingId(null); setIsAdding(false); setNewAddress({ type: '', street: '', city: '', state: '', zipCode: '', isDefault: false }); };
const handleAdd = () => { setIsAdding(true); setEditingId(null); };
const handleAddSave = () => { setAddresses([ ...addresses, { ...newAddress, id: addresses.length + 1 } ]); setIsAdding(false); setNewAddress({ type: '', street: '', city: '', state: '', zipCode: '', isDefault: false }); };
const handleInputChange = (id, field, value) => { if (id === 'new') { setNewAddress({ ...newAddress,
});
} else {
setAddresses(addresses.map(addr =>
addr.id === id ? { ...addr, [field]: value } : addr
));
}
};
return (
{address.street}
{address.city}, {address.state} {address.zipCode}
> )}@aniruddhaadak80
Create a Address.js component in the folder ProfileComponents inside components. Attach the code there. Finally render the component in Profile.js.
Also attach a screenshot of the page with the PR.
This is what it currently looks like.
Implement the address component. Unlike personal Information, no need to take all state variables and functions as props. Simply take a dummy data in your component and local state variables and functions and implement just like Personal Information page.