Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrenallen committed Mar 5, 2025
1 parent a37b7ee commit 62cfe67
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 127 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/CarrierController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function destroy(Carrier $carrier)

public function bouncedLoads(Carrier $carrier)
{
return response(
return response()->json(
CarrierBounceResource::collection(
$carrier->bounces
->sortByDesc('created_at')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Carriers/CarrierBounceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Illuminate\Http\Resources\Json\JsonResource;

/**
* @mixin \App\Models\Carriers\Carrier
* @mixin \App\Models\Carriers\CarrierBounce
*/
class CarrierBounceResource extends JsonResource
{
Expand Down
44 changes: 22 additions & 22 deletions resources/js/Components/ui/switch.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import * as React from "react"
import * as SwitchPrimitives from "@radix-ui/react-switch"
import * as SwitchPrimitives from '@radix-ui/react-switch';
import * as React from 'react';

import { cn } from "@/lib/utils"
import { cn } from '@/lib/utils';

const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
React.ElementRef<typeof SwitchPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
className
)}
{...props}
ref={ref}
>
<SwitchPrimitives.Thumb
className={cn(
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
)}
/>
</SwitchPrimitives.Root>
))
Switch.displayName = SwitchPrimitives.Root.displayName
<SwitchPrimitives.Root
className={cn(
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
className,
)}
{...props}
ref={ref}
>
<SwitchPrimitives.Thumb
className={cn(
'pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
)}
/>
</SwitchPrimitives.Root>
));
Switch.displayName = SwitchPrimitives.Root.displayName;

export { Switch }
export { Switch };
108 changes: 68 additions & 40 deletions resources/js/Pages/Carriers/Partials/CarrierDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,31 @@ import {
SelectValue,
} from '@/Components/ui/select';
import { Skeleton } from '@/Components/ui/skeleton';
import { Switch } from '@/Components/ui/switch';
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/Components/ui/table';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/Components/ui/tabs';
import { useMediaQuery } from '@/hooks/useMediaQuery';
import { cn } from '@/lib/utils';
import { Carrier, CarrierBounce } from '@/types';
import { Contactable } from '@/types/enums';
import { Link, router } from '@inertiajs/react';
import { Check, CheckCircle2, ExternalLink, Pencil, X, XCircle } from 'lucide-react';
import {
Check,
CheckCircle2,
ExternalLink,
Pencil,
X,
XCircle,
} from 'lucide-react';
import { useEffect, useState } from 'react';
import CarrierDetailsGeneral from './CarrierDetailsGeneral';
import { Switch } from '@/Components/ui/switch';
import { cn } from '@/lib/utils';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/Components/ui/table';

export default function CarrierDetails({ carrier }: { carrier?: Carrier }) {
const [isEditing, setIsEditing] = useState(false);
Expand Down Expand Up @@ -210,13 +224,13 @@ export default function CarrierDetails({ carrier }: { carrier?: Carrier }) {
</div>
{carrier.billing_location
.address_line_2 && (
<div>
{
carrier.billing_location
.address_line_2
}
</div>
)}
<div>
{
carrier.billing_location
.address_line_2
}
</div>
)}
<div>
{
carrier.billing_location
Expand Down Expand Up @@ -332,15 +346,15 @@ export default function CarrierDetails({ carrier }: { carrier?: Carrier }) {
<div>
{carrier?.safer_report?.created_at
? new Date(
carrier.safer_report.created_at,
).toLocaleDateString(
'en-US',
{
year: 'numeric',
month: 'long',
day: 'numeric',
},
)
carrier.safer_report.created_at,
).toLocaleDateString(
'en-US',
{
year: 'numeric',
month: 'long',
day: 'numeric',
},
)
: '-'}
</div>
</div>
Expand Down Expand Up @@ -527,16 +541,22 @@ export default function CarrierDetails({ carrier }: { carrier?: Carrier }) {
<TabsContent value="shipments">
<Card>
<CardContent className="pt-6">

<div className="flex w-full justify-end items-center gap-2">
<div className="flex w-full items-center justify-end gap-2">
<Switch
checked={showBounces}
onCheckedChange={() => setShowBounces(!showBounces)}
onCheckedChange={() =>
setShowBounces(!showBounces)
}
/>
<label htmlFor="showBounces" className={cn(
!showBounces && 'text-muted-foreground',
'text-sm'
)}>Bounced Loads</label>
<label
htmlFor="showBounces"
className={cn(
!showBounces && 'text-muted-foreground',
'text-sm',
)}
>
Bounced Loads
</label>
</div>
{showBounces ? (
<BouncedLoadsList carrier={carrier} />
Expand All @@ -545,7 +565,8 @@ export default function CarrierDetails({ carrier }: { carrier?: Carrier }) {
requiredFilters={[
{
name: 'carrier_id',
value: carrier?.id?.toString() || '',
value:
carrier?.id?.toString() || '',
},
]}
/>
Expand All @@ -558,9 +579,7 @@ export default function CarrierDetails({ carrier }: { carrier?: Carrier }) {
);
}


function BouncedLoadsList({ carrier }: { carrier?: Carrier }) {

const [bouncedLoads, setBouncedLoads] = useState<CarrierBounce[]>([]);

useEffect(() => {
Expand All @@ -571,8 +590,6 @@ function BouncedLoadsList({ carrier }: { carrier?: Carrier }) {
});
}, [carrier?.id]);



return (
<div className="mt-1 md:mt-4">
<Table>
Expand All @@ -589,20 +606,31 @@ function BouncedLoadsList({ carrier }: { carrier?: Carrier }) {
{bouncedLoads.map((bounce) => (
<TableRow key={bounce.id}>
<TableCell>
{new Date(bounce.created_at).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
})}
{new Date(bounce.created_at).toLocaleDateString(
'en-US',
{
year: 'numeric',
month: 'long',
day: 'numeric',
},
)}
</TableCell>
<TableCell>
<Link href={route('shipments.show', bounce.shipment?.id)}>
{bounce.shipment?.shipment_number} <ExternalLink className="inline w-4 h-4" />
<Link
href={route(
'shipments.show',
bounce.shipment?.id,
)}
>
{bounce.shipment?.shipment_number}{' '}
<ExternalLink className="inline h-4 w-4" />
</Link>
</TableCell>
<TableCell>{bounce.bounce_type}</TableCell>
<TableCell>{bounce.reason}</TableCell>
<TableCell>{bounce.bounced_by_user?.name}</TableCell>
<TableCell>
{bounce.bounced_by_user?.name}
</TableCell>
</TableRow>
))}
</TableBody>
Expand Down
Loading

0 comments on commit 62cfe67

Please sign in to comment.