Skip to content

add edit crew toggle #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2024
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
18 changes: 3 additions & 15 deletions src/components/crews/CrewManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { useRouter } from "next/navigation";
import { supabase } from "@/utils/supabase/client";
import { Button } from "@/components/ui/button";
import {
Circle,
CheckCircle,
Settings,
PlusIcon,
Trash2Icon,
UserIcon,
Expand All @@ -29,9 +28,7 @@ import { ChatBubbleIcon } from "@radix-ui/react-icons";

export function CrewManagement({
initialCrews,
onCrewSelect,
onCrewUpdate,
selectedCrew,
}: CrewManagementProps) {
const [crews, setCrews] = useState<Crew[]>(initialCrews);
const [isDialogOpen, setIsDialogOpen] = useState(false);
Expand Down Expand Up @@ -68,10 +65,6 @@ export function CrewManagement({
const updatedCrews = crews.filter((crew) => crew.id !== id);
setCrews(updatedCrews);

if (selectedCrew?.id === id) {
onCrewSelect(null);
}

onCrewUpdate(updatedCrews);
toast({
title: "Crew deleted",
Expand Down Expand Up @@ -171,15 +164,10 @@ export function CrewManagement({
<span className="font-medium text-sm">{crew.name}</span>
</div>
<Button
variant={selectedCrew?.id === crew.id ? "secondary" : "ghost"}
size="sm"
onClick={() => onCrewSelect(crew)}
onClick={() => router.push(`/crew/${crew.id}/manage`)}
>
{selectedCrew?.id === crew.id ? (
<CheckCircle className="h-4 w-4" />
) : (
<Circle className="h-4 w-4" />
)}
<Settings className="h-3 w-3" />
</Button>
</div>
<p className="text-xs text-muted-foreground line-clamp-2">
Expand Down
10 changes: 0 additions & 10 deletions src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function Dashboard() {
const [hasClonedAnalyzer, setHasClonedAnalyzer] = useState(false);
const [error, setError] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [selectedCrew, setSelectedCrew] = useState<Crew | null>(null);
const [isSheetOpen, setIsSheetOpen] = useState(false);

const fetchCrews = useCallback(async () => {
Expand Down Expand Up @@ -85,10 +84,6 @@ export default function Dashboard() {
initializeDashboard();
}, [fetchCrews, checkClonedAnalyzer]);

const handleCrewSelect = useCallback((crew: Crew | null) => {
setSelectedCrew(crew);
}, []);

const handleCloneComplete = useCallback(() => {
setHasClonedAnalyzer(true);
fetchCrews();
Expand All @@ -97,9 +92,6 @@ export default function Dashboard() {
const handleCrewsUpdated = useCallback(
(updatedCrews: Crew[]) => {
setCrews(updatedCrews);
if (updatedCrews.length === 0) {
setSelectedCrew(null);
}
checkClonedAnalyzer();
},
[checkClonedAnalyzer]
Expand Down Expand Up @@ -136,9 +128,7 @@ export default function Dashboard() {
) : (
<CrewManagement
initialCrews={crews}
onCrewSelect={handleCrewSelect}
onCrewUpdate={handleCrewsUpdated}
selectedCrew={selectedCrew}
/>
)}
</SheetContent>
Expand Down
2 changes: 0 additions & 2 deletions src/types/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export interface Crew {
// Interface for props of the CrewManagement component
export interface CrewManagementProps {
initialCrews: Crew[]
onCrewSelect: (crew: Crew | null) => void
onCrewUpdate: (updatedCrews: Crew[]) => void
selectedCrew: Crew | null
}

// Interface for props of the CrewForm component
Expand Down
Loading