Back

Version 15

12/3/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";

// Utility function to hash password
const hashPassword = async (password: string) => {
const encoder = new TextEncoder();
const data = encoder.encode(password);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
};

function AddressForm({
address = { name: '', street: '', city: '', state: '', zip: '' },
onSubmit,
onCancel
}) {
const [formData, setFormData] = useState(address);

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

const handleSubmit = async (e) => {
e.preventDefault();
console.log('Submitting address:', formData); // Debug logging
try {
await onSubmit(formData);
} catch (error) {
console.error('Address submission error:', error);
alert('Failed to add address. Please try again.');
}
};

zdmta-laudableturquoiseopossum.web.val.run
Updated: December 3, 2024