Skip to content

Commit

Permalink
Removed user spaces and punctuation
Browse files Browse the repository at this point in the history
  • Loading branch information
joriordan332 committed Sep 10, 2024
1 parent 1ae8026 commit 40a5bfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/ListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function ListItem({ name, listPath, id, isChecked, datePurchased }) {

useEffect(() => {
const today = new Date().getTime();
const datePurchasedInMillis = datePurchased.toMillis();
const datePurchasedInMillis = datePurchased?.toMillis();

if (isChecked && today - datePurchasedInMillis >= ONE_DAY_IN_MILLISECONDS) {
updateItem(listPath, id, !isChecked);
Expand Down
14 changes: 12 additions & 2 deletions src/components/ManageListForms/AddItemForm.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { useState } from 'react';
import { addItem } from '../../api/firebase';

export default function AddItemForm({ listPath }) {
export default function AddItemForm({ listPath, data }) {
const [formData, setFormData] = useState({
itemName: '',
daysUntilNextPurchase: '',
});

const handleSubmit = async (event) => {
event.preventDefault();
try {
event.preventDefault();
console.log(formData.itemName);
const submittedItem = formData.itemName
.toLowerCase()
.replace(/[.,/#!$%^&*;:{}=\-_`~()\s]/g, '')
.replace(/[^\w\s]/gi, '');
setFormData((prevData) => ({
...prevData,
itemName: submittedItem,
}));
console.log('after set form data,', submittedItem);
await addItem(listPath, formData);
alert(`${formData.itemName} was added to the list successfully`);
} catch (error) {
Expand Down

0 comments on commit 40a5bfe

Please sign in to comment.