Skip to content

Commit

Permalink
Adjust transaction form
Browse files Browse the repository at this point in the history
  • Loading branch information
JJtan2002 committed Jun 21, 2024
1 parent a05ec74 commit 0cf2f9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions backend/budget_tracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def create_from_json(data: dict, user_pk: int) -> 'Transaction':
print(data)
custom_label = CustomLabel.objects.get(
pk=data.get("label").get("id"))
if custom_label.get_wallet() != user_wallet:
raise PermissionError()
#if custom_label.get_wallet() != user_wallet:
#raise PermissionError()
transaction.label = custom_label

# Value section
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/pages/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const Profile = () => {
useEffect(() => {
const fetchLabels = async () => {
if (!isPendingLabels && !isErrorLabels && labels) {
setExpenseCategories(labels.slice(0, 4).map((i) => i["name"]));
setIncomeCategories(labels.slice(5,).map((i) => i["name"]));
setExpenseCategories(labels.slice(0, 4).map((i) => [i["id"], i["name"]]));
setIncomeCategories(labels.slice(5,).map((i) => [i["id"], i["name"]]));
}
};

Expand All @@ -98,7 +98,7 @@ const Profile = () => {
const formData = {
title: ev.target.title.value,
label: {
id: 1,
id: ev.target.label.value,
},
value: parseInt(ev.target.amount.value),
type: ev.target.type.value,
Expand Down Expand Up @@ -167,13 +167,13 @@ const Profile = () => {
<option value="" disabled selected>Select Category</option>
{/* Conditionally render options based on transactionType */}
{transactionType === "Expense" && (
expenseCategories.map(category => (
<option key={category} value={category}>{category}</option>
expenseCategories.map((category) => (
<option key={category[0]} value={category[0]}>{category[1]}</option>
))
)}
{transactionType === "Earning" && (
incomeCategories.map(category => (
<option key={category} value={category}>{category}</option>
incomeCategories.map((category, index) => (
<option key={category[0]} value={category[0]}>{category[1]}</option>
))
)}
</select>
Expand Down

0 comments on commit 0cf2f9f

Please sign in to comment.