Skip to content

Commit

Permalink
♻️ Add button for remove repos in local
Browse files Browse the repository at this point in the history
  • Loading branch information
Sstark97 committed Nov 24, 2024
1 parent b323bd2 commit 8923d20
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
24 changes: 24 additions & 0 deletions components/forms/DeleteAllReposButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {useFormStatus} from "react-dom";
import {Button} from "@/components/ui/button";
import {Loader2, Shuffle} from "lucide-react";
import {deleteAllRepositories} from "@/lib/infrastructure/server/actions";

export const DeleteAllReposButton = () => {
const { pending } = useFormStatus();
return (
<form action={deleteAllRepositories}>
<Button
className="w-full bg-gradient-to-r from-gray-700 to-[#39b3c2] hover:from-gray-600 hover:to-[#2a8a96] text-white font-bold py-3 rounded-full transition-all duration-300 transform hover:scale-105"
type="submit"
disabled={pending}
>
{pending ? (
<Loader2 className="mr-2 h-5 w-5 animate-spin" />
) : (
<Shuffle className="mr-2 h-5 w-5" />
)}
Eliminar todos los repos
</Button>
</form>
);
}
15 changes: 10 additions & 5 deletions components/forms/RealTimeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import {AnimatePresence, motion} from "framer-motion";
import {RepositorySubmitButton} from "@/components/forms/RepositorySubmitButton";
import {usePusherState} from "@/components/hooks/usePusherState";
import {usePusherState} from "@/hooks/usePusherState";
import {useTransition} from "react";
import {openAnonymousRandomRepository} from "@/lib/infrastructure/server/actions";
import { DeleteAllReposButton } from "@/components/forms/DeleteAllReposButton";

export const RealTimeForm = () => {
const repositories = usePusherState();
const [, startTransition] = useTransition();
const isLocal = process.env.NODE_ENV === 'development';

const handleSendToServer = async () => {
startTransition(async () => {
Expand All @@ -24,7 +26,7 @@ export const RealTimeForm = () => {
}
});
};

return (
<>
<div className="mb-6">
Expand Down Expand Up @@ -55,9 +57,12 @@ export const RealTimeForm = () => {
</AnimatePresence>
</div>
</div>
<form action={handleSendToServer}>
<RepositorySubmitButton repositories={repositories}/>
</form>
<section className="flex">
<form action={handleSendToServer} className="w-full">
<RepositorySubmitButton repositories={repositories}/>
</form>
{ isLocal ? <DeleteAllReposButton /> : <></>}
</section>
</>
)
}
File renamed without changes.

0 comments on commit 8923d20

Please sign in to comment.