diff --git a/src/components/dashboard/AddNewExpense.tsx b/src/components/dashboard/AddNewExpense.tsx deleted file mode 100644 index db51dcb..0000000 --- a/src/components/dashboard/AddNewExpense.tsx +++ /dev/null @@ -1,426 +0,0 @@ -import { useState } from "react"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { Slider } from "@/components/ui/slider"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; -import { Textarea } from "@/components/ui/textarea"; -import { - CalendarIcon, - DollarSign, - Home, - Receipt, - ShoppingBag, - Utensils, - Car, - Plane, - Film, - Wifi, -} from "lucide-react"; - -const categories = [ - { id: "food", name: "Food & Drink", icon: Utensils }, - { id: "groceries", name: "Groceries", icon: ShoppingBag }, - { id: "housing", name: "Housing", icon: Home }, - { id: "transportation", name: "Transportation", icon: Car }, - { id: "travel", name: "Travel", icon: Plane }, - { id: "entertainment", name: "Entertainment", icon: Film }, - { id: "utilities", name: "Utilities", icon: Wifi }, - { id: "other", name: "Other", icon: Receipt }, -]; - -const groups = [ - { id: 1, name: "Roommates" }, - { id: 2, name: "Trip to Paris" }, - { id: 3, name: "Dinner Club" }, - { id: 4, name: "Office Lunch" }, -]; - -const members = [ - { - id: 1, - name: "You", - email: "you@example.com", - avatar: "/placeholder.svg?height=40&width=40&text=You", - initials: "You", - }, - { - id: 2, - name: "Alex Johnson", - email: "alex@example.com", - avatar: "/placeholder.svg?height=40&width=40&text=AJ", - initials: "AJ", - }, - { - id: 3, - name: "Sarah Miller", - email: "sarah@example.com", - avatar: "/placeholder.svg?height=40&width=40&text=SM", - initials: "SM", - }, - { - id: 4, - name: "Mike Wilson", - email: "mike@example.com", - avatar: "/placeholder.svg?height=40&width=40&text=MW", - initials: "MW", - }, -]; - -function AddNewExpense() { - const [splitMethod, setSplitMethod] = useState("equal"); - const [selectedCategory, setSelectedCategory] = useState("food"); - const [isLoading, setIsLoading] = useState(false); - const [customSplits, setCustomSplits] = useState>({ - 1: 25, - 2: 25, - 3: 25, - 4: 25, - }); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - setIsLoading(true); - // Simulate API call - setTimeout(() => { - setIsLoading(false); - }, 1500); - }; - - const handleSliderChange = (memberId: number, value: number[]) => { - const newValue = value[0]; - const currentTotal = Object.values(customSplits).reduce( - (sum, val) => sum + val, - 0 - ); - const currentMemberValue = customSplits[memberId] || 0; - const difference = newValue - currentMemberValue; - - if (currentTotal + difference > 100) return; - - setCustomSplits((prev) => ({ - ...prev, - [memberId]: newValue, - })); - - // Distribute the remaining percentage - const remaining = 100 - (currentTotal + difference); - const otherMembers = Object.keys(customSplits) - .map(Number) - .filter((id) => id !== memberId); - - if (remaining > 0 && otherMembers.length > 0) { - const perMember = remaining / otherMembers.length; - const newSplits = { ...customSplits, [memberId]: newValue }; - - otherMembers.forEach((id) => { - newSplits[id] = perMember; - }); - - setCustomSplits(newSplits); - } - }; - - return ( -
- - - Expense Details - - -
- - -
- -
- -
- - -
-
- -
- -
- - -
-
- -
- - -
- -
- -
- {categories.map((category) => { - const Icon = category.icon; - return ( -
setSelectedCategory(category.id)} - > - - {category.name} -
- ); - })} -
-
- -
- - - - - Equal - - - Custom - - - Percentage - - - -

- Split equally among all members -

-
- {members.map((member) => ( -
-
- - - {member.initials} - - {member.name} -
- 25% -
- ))} -
-
- -

- Enter custom amounts for each person -

- -
- - -
-
- - -
-
-
- {members.map((member) => ( -
-
-
- - - {member.initials} - - {member.name} -
-
- - -
-
-
- ))} -
-
- -

- Adjust percentages for each person -

-
- {members.map((member) => ( -
-
-
- - - {member.initials} - - {member.name} -
- - {customSplits[member.id]}% - -
- - handleSliderChange(member.id, value) - } - className="[&>.slider-track]:h-2 [&>.slider-track]:bg-secondary [&>.slider-range]:bg-gradient-to-r [&>.slider-range]:from-primary [&>.slider-range]:to-[#ff4ecd] [&>.slider-thumb]:h-5 [&>.slider-thumb]:w-5 [&>.slider-thumb]:bg-background [&>.slider-thumb]:border-2 [&>.slider-thumb]:border-primary [&>.slider-thumb]:shadow-glow" - /> -
- ))} -
-
-
-
- -
- -