Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions app/components/add-motorcycle-form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Form, useSubmit, useActionData } from "react-router";
import type { EditorMotorcycle } from "~/db/schema";
import type { EditorMotorcycle, CurrencySetting } from "~/db/schema";
import { useState, useCallback } from "react";
import Cropper from "react-easy-crop";
import getCroppedImg from "~/utils/cropImage";
Expand All @@ -10,9 +10,12 @@ interface AddMotorcycleFormProps {
initialValues?: (EditorMotorcycle & { id?: number });
intent?: string;
submitLabel?: string;
currencies?: CurrencySetting[];
onDelete?: (event: React.MouseEvent<HTMLButtonElement>) => void;
}



const formatDateInput = (value?: string | null) => {
if (!value) {
return "";
Expand All @@ -25,9 +28,13 @@ export function AddMotorcycleForm({
initialValues,
intent = "createMotorcycle",
submitLabel = "Speichern",
currencies = [],
onDelete,
}: AddMotorcycleFormProps) {
const submit = useSubmit();
// Fallback


const actionData = useActionData<{
errors?: {
make?: string;
Expand Down Expand Up @@ -284,9 +291,11 @@ export function AddMotorcycleForm({
className="rounded-r-xl border-l-0 border-gray-200 bg-gray-100 p-3 text-sm text-secondary focus:border-primary focus:ring-primary dark:border-navy-600 dark:bg-navy-800 dark:text-navy-300"
defaultValue={initialValues?.currencyCode ?? "CHF"}
>
<option value="CHF">CHF</option>
<option value="EUR">EUR</option>
<option value="USD">USD</option>
{currencies?.map((c) => (
<option key={c.code} value={c.code}>
{c.code}
</option>
))}
</select>
</div>
{actionData?.errors?.purchasePrice && (
Expand Down
2 changes: 1 addition & 1 deletion app/components/dashboard-stats.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { formatCurrency, formatNumber } from "~/utils/numberUtils";
import type { DashboardStats as DashboardStatsType } from "~/utils/home-stats";
import clsx from "clsx";


interface DashboardStatsProps {
stats: DashboardStatsType;
Expand Down
6 changes: 4 additions & 2 deletions app/components/maintenance-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Modal } from "~/components/modal";
import { MaintenanceForm } from "~/components/maintenance-form";
import type { MaintenanceRecord, Location } from "~/db/schema";
import type { MaintenanceRecord, Location, CurrencySetting } from "~/db/schema";

interface MaintenanceDialogProps {
isOpen: boolean;
Expand All @@ -10,10 +10,11 @@ interface MaintenanceDialogProps {
currencyCode?: string | null;
defaultOdo?: number | null;
userLocations?: Location[];
currencies?: CurrencySetting[];
onDelete?: () => void;
}

export function MaintenanceDialog({ isOpen, onClose, motorcycleId, initialData, currencyCode, defaultOdo, userLocations, onDelete }: MaintenanceDialogProps) {
export function MaintenanceDialog({ isOpen, onClose, motorcycleId, initialData, currencyCode, defaultOdo, userLocations, currencies, onDelete }: MaintenanceDialogProps) {
return (
<Modal
isOpen={isOpen}
Expand All @@ -27,6 +28,7 @@ export function MaintenanceDialog({ isOpen, onClose, motorcycleId, initialData,
currencyCode={currencyCode}
defaultOdo={defaultOdo}
userLocations={userLocations}
currencies={currencies}
onSubmit={onClose}
onCancel={onClose}
onDelete={onDelete}
Expand Down
20 changes: 14 additions & 6 deletions app/components/maintenance-form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import { Form } from "react-router";
import type { MaintenanceRecord, MaintenanceType, Location } from "~/db/schema";
import type { MaintenanceRecord, MaintenanceType, Location, CurrencySetting } from "~/db/schema";
import {
Wrench,
Battery,
Expand All @@ -21,6 +21,7 @@ interface MaintenanceFormProps {
currencyCode?: string | null;
defaultOdo?: number | null;
userLocations?: Location[];
currencies?: CurrencySetting[];
onSubmit: () => void;
onCancel: () => void;
onDelete?: () => void;
Expand All @@ -40,10 +41,15 @@ const maintenanceTypes: { value: MaintenanceType; label: string; icon: any }[] =
{ value: "general", label: "Allgemein", icon: Wrench },
];

export function MaintenanceForm({ motorcycleId, initialData, currencyCode, defaultOdo, userLocations, onSubmit, onCancel, onDelete }: MaintenanceFormProps) {


export function MaintenanceForm({ motorcycleId, initialData, currencyCode, defaultOdo, userLocations, currencies = [], onSubmit, onCancel, onDelete }: MaintenanceFormProps) {
const [type, setType] = useState<MaintenanceType>(initialData?.type || "service");
const [isNewLocation, setIsNewLocation] = useState(false);

// Fallback if no currencies provided


const today = new Date().toISOString().split('T')[0];

return (
Expand Down Expand Up @@ -113,9 +119,11 @@ export function MaintenanceForm({ motorcycleId, initialData, currencyCode, defau
className="rounded-r-xl border-l-0 border-gray-200 bg-gray-100 p-3 text-sm text-secondary focus:border-primary focus:ring-primary dark:border-navy-600 dark:bg-navy-800 dark:text-navy-300"
defaultValue={initialData?.currency || currencyCode || "CHF"}
>
<option value="CHF">CHF</option>
<option value="EUR">EUR</option>
<option value="USD">USD</option>
{currencies?.map((c) => (
<option key={c.code} value={c.code}>
{c.code}
</option>
))}
</select>
</div>
</div>
Expand Down Expand Up @@ -186,7 +194,7 @@ export function MaintenanceForm({ motorcycleId, initialData, currencyCode, defau
)}

{/* Generic Brand/Model */}
{(["tire", "battery", "fluid", "chain", "brakepad", "brakerotor", "general", "repair"].includes(type)) && (
{(["tire", "battery", "fluid", "chain", "brakepad", "brakerotor"].includes(type)) && (
<>
<div className="space-y-1.5">
<label htmlFor="brand" className="text-xs font-semibold uppercase tracking-wider text-secondary dark:text-navy-300">Marke / Hersteller</label>
Expand Down
134 changes: 0 additions & 134 deletions app/db/migrations/0000_initial.sql

This file was deleted.

3 changes: 3 additions & 0 deletions app/db/migrations/0000_nice_sally_floyd.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE `motorcycles` ADD `normalized_purchase_price` real;
--> statement-breakpoint
ALTER TABLE `maintenance_records` ADD `normalized_cost` real;
Comment on lines +1 to +3

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration only contains ALTER TABLE statements, and the migrations folder no longer contains an initial schema/table-creation migration. Running migrations on a fresh database will fail because motorcycles / maintenance_records won’t exist yet. Reintroduce a baseline migration that creates the tables (or otherwise ensure schema creation happens before these ALTERs).

Copilot uses AI. Check for mistakes.
1 change: 0 additions & 1 deletion app/db/migrations/0001_add_torque_end_to_torque_specs.sql

This file was deleted.

2 changes: 0 additions & 2 deletions app/db/migrations/0002_add_privacy_columns_to_documents.sql

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion app/db/migrations/0004_drop_image_column.sql

This file was deleted.

1 change: 0 additions & 1 deletion app/db/migrations/0005_add_image_column_back.sql

This file was deleted.

61 changes: 0 additions & 61 deletions app/db/migrations/0006_make_vin_nullable.sql

This file was deleted.

1 change: 0 additions & 1 deletion app/db/migrations/0007_add_tool_size_to_torque_specs.sql

This file was deleted.

Loading