Skip to content

Commit

Permalink
Merge pull request #45 from chingu-voyages/landing-page/signup
Browse files Browse the repository at this point in the history
feature/expenses-overview
  • Loading branch information
yawcoder authored Oct 13, 2024
2 parents 7076d15 + 730e4cb commit ffbba8c
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 209 deletions.
5 changes: 4 additions & 1 deletion src/components/forms/AdminForm.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react/prop-types */

import { useState } from "react";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { Label } from "../ui/label";
Expand Down Expand Up @@ -44,7 +45,9 @@ export default function AdminForm({
required
/>
</Label>
<Button className="md:col-span-full">{customSubmitText}</Button>
<Button className="md:col-span-full" href="/app/first-group">
{customSubmitText}
</Button>
</form>
);
}
63 changes: 39 additions & 24 deletions src/components/forms/ExpenseForm.jsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
import { Label } from "@/components/ui/label"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import PropTypes from "prop-types"
import { Button } from "../ui/button"
import { EXPENSE_CATEGORIES_MOCK, PARTICIPANTS_MOCK_DATA } from "@/lib/mock-data"
import { useEffect, useState } from "react"
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"
import { cn } from "@/lib/utils"
import { CalendarIcon, Percent } from "lucide-react"
import { format } from "date-fns"
import { Calendar } from "../ui/calendar"
import { CONTRIBUTION_WEIGHTS } from "@/lib/constants"
} from "@/components/ui/select";
import PropTypes from "prop-types";
import { Button } from "../ui/button";
import {
EXPENSE_CATEGORIES_MOCK,
PARTICIPANTS_MOCK_DATA,
} from "@/lib/mock-data";
import { useEffect, useState } from "react";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import { cn } from "@/lib/utils";
import { CalendarIcon, Percent } from "lucide-react";
import { format } from "date-fns";
import { Calendar } from "../ui/calendar";
import { CONTRIBUTION_WEIGHTS } from "@/lib/constants";

// TODO add default values prop (needed in case of edit
export function ExpenseForm({ onSubmit, actions, className, date, setDate }) {
const [participants, setParticipants] = useState([])
const [participants, setParticipants] = useState([]);

useEffect(() => {
const participantsData = JSON.parse(localStorage.getItem("participantsData"))
const participantsData = JSON.parse(
localStorage.getItem("participantsData")
);

if(participantsData){
setParticipants(participantsData)
if (participantsData) {
setParticipants(participantsData);
}
})
}, []);

return (
<form
Expand Down Expand Up @@ -110,18 +115,28 @@ export function ExpenseForm({ onSubmit, actions, className, date, setDate }) {
<PopoverTrigger asChild>
<Button
variant={"outline"}
className={cn("justify-start md:self-end", !date && "text-muted-foreground")}
className={cn(
"justify-start md:self-end",
!date && "text-muted-foreground"
)}
>
<CalendarIcon className="mr-2 h-4 w-4" />
{date ? format(date, "PPP") : <span>Purchase date</span>}
</Button>
</PopoverTrigger>
<PopoverContent className="p-0">
<Calendar mode="single" selected={date} onSelect={setDate} initialFocus />
<Calendar
mode="single"
selected={date}
onSelect={setDate}
initialFocus
/>
</PopoverContent>
</Popover>
<Label>
<span className="inline-block mb-2">Receipt proof (can be uploaded later)</span>
<span className="inline-block mb-2">
Receipt proof (can be uploaded later)
</span>
<Input name="expenseReceipt" type="file" />
</Label>
{actions ? (
Expand All @@ -132,7 +147,7 @@ export function ExpenseForm({ onSubmit, actions, className, date, setDate }) {
</Button>
)}
</form>
)
);
}

ExpenseForm.propTypes = {
Expand All @@ -142,4 +157,4 @@ ExpenseForm.propTypes = {
setDate: PropTypes.func,
// defaultValues: PropsTypes.
className: PropTypes.string,
}
};
20 changes: 0 additions & 20 deletions src/hooks/useLocalStorage.js

This file was deleted.

Loading

0 comments on commit ffbba8c

Please sign in to comment.