feat: connecting the pinning thingy
This commit is contained in:
parent
c9de506c56
commit
8d4fcfba5c
|
@ -110,7 +110,7 @@ export const GeneralLayout = ({ children }: React.PropsWithChildren) => {
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button className="border rounded-full h-auto p-2 gap-x-2 text-ring font-semibold">
|
<Button className="border rounded-full h-auto p-2 gap-x-2 text-ring font-semibold">
|
||||||
<Avatar className="bg-ring h-7 w-7 rounded-full" />
|
<Avatar className="bg-ring h-7 w-7 rounded-full" />
|
||||||
{`${identity?.firstName} ${identity?.lastName}`}
|
{`${identity?.firstName} ${identity?.lastName}`}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useMemo } from "react";
|
import { useContext, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
Accordion,
|
Accordion,
|
||||||
AccordionContent,
|
AccordionContent,
|
||||||
|
@ -10,25 +10,33 @@ import { usePinning } from "~/hooks/usePinning";
|
||||||
import { Tabs, TabsTrigger, TabsList, TabsContent } from "./ui/tabs";
|
import { Tabs, TabsTrigger, TabsList, TabsContent } from "./ui/tabs";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import { Cross2Icon } from "@radix-ui/react-icons";
|
import { Cross2Icon } from "@radix-ui/react-icons";
|
||||||
import { PinningStatus } from "~/data/pinning";
|
import type { PinningStatus } from "~/data/pinning";
|
||||||
|
import { PinningContext } from "~/providers/PinningProvider";
|
||||||
|
|
||||||
export const PinningNetworkBanner = () => {
|
export const PinningNetworkBanner = () => {
|
||||||
|
// const context = useContext(PinningContext);
|
||||||
const { data } = usePinning();
|
const { data } = usePinning();
|
||||||
|
|
||||||
// TODO: Adapt to real API
|
// TODO: Adapt to real API
|
||||||
const itemsLeft = useMemo(
|
const itemsLeft = useMemo(
|
||||||
() => data?.items.filter((item: PinningStatus) => item.status.includes("inprogress")) || [],
|
() =>
|
||||||
|
data?.items.filter((item: PinningStatus) =>
|
||||||
|
item.status.includes("inprogress"),
|
||||||
|
) || [],
|
||||||
[data],
|
[data],
|
||||||
);
|
);
|
||||||
|
|
||||||
const completedItems = useMemo(
|
const completedItems = useMemo(
|
||||||
() => data?.items.filter((item: PinningStatus) => item.status.includes("completed")) || [],
|
() =>
|
||||||
|
data?.items.filter((item: PinningStatus) =>
|
||||||
|
item.status.includes("completed"),
|
||||||
|
) || [],
|
||||||
[data],
|
[data],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`border border-border rounded-lg absolute w-1/3 bottom-4 right-4 ${
|
className={`bg-background border border-border rounded-lg absolute w-1/3 bottom-4 right-4 ${
|
||||||
!data?.items.length ? "hidden" : "block"
|
!data?.items.length ? "hidden" : "block"
|
||||||
}`}>
|
}`}>
|
||||||
<Accordion type="single" defaultValue="item-1" collapsible>
|
<Accordion type="single" defaultValue="item-1" collapsible>
|
||||||
|
@ -73,29 +81,27 @@ export const PinningNetworkBanner = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const PinCidItem = ({ item }: { item: PinningStatus }) => {
|
const PinCidItem = ({ item }: { item: PinningStatus }) => {
|
||||||
const { mutate } = usePinning();
|
const { unpin } = usePinning();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-4 mb-4">
|
<div className="px-4 mb-4">
|
||||||
<div className="flex justify-between items-center rounded-lg h-10 py-2 px-4 hover:bg-primary/50 group">
|
<div className="relative flex flex-col items-center rounded-lg py-2 px-4 hover:bg-primary/50 group">
|
||||||
|
<div className="flex justify-between items-center w-full">
|
||||||
<span className="font-semibold">{item.id}</span>
|
<span className="font-semibold">{item.id}</span>
|
||||||
<span className="group-hover:hidden">{item.progress}%</span>
|
<span className="group-hover:hidden">{item.progress}%</span>
|
||||||
<div className="gap-x-2 hidden group-hover:flex">
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="p-2 rounded-full h-6"
|
className="absolute top-2 right-2 hidden group-hover:flex rounded-full h-3"
|
||||||
onClick={() => mutate({
|
onClick={() =>
|
||||||
|
unpin({
|
||||||
cid: item.id,
|
cid: item.id,
|
||||||
type: "unpin"
|
})
|
||||||
})}>
|
}>
|
||||||
<Cross2Icon />
|
<Cross2Icon />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
<Progress value={item.progress} className="h-2" />
|
||||||
</div>
|
</div>
|
||||||
<Progress
|
|
||||||
value={item.progress}
|
|
||||||
className="h-2 w-[calc(100%-1rem)] ml-2"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Navigate} from "@remix-run/react";
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
return (
|
return (
|
||||||
<Authenticated v3LegacyAuthProviderCompatible key={"index"} loading={
|
<Authenticated key={"index"} loading={
|
||||||
<>Checking Login Status</>
|
<>Checking Login Status</>
|
||||||
}>
|
}>
|
||||||
<Navigate to="/dashboard" replace/>
|
<Navigate to="/dashboard" replace/>
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { usePinning } from "~/hooks/usePinning";
|
||||||
|
|
||||||
export default function FileManager() {
|
export default function FileManager() {
|
||||||
return (
|
return (
|
||||||
<Authenticated key="dashboard" v3LegacyAuthProviderCompatible>
|
<Authenticated key="file-manager">
|
||||||
<GeneralLayout>
|
<GeneralLayout>
|
||||||
<Dialog>
|
<Dialog>
|
||||||
<h1 className="font-bold mb-4 text-lg">File Manager</h1>
|
<h1 className="font-bold mb-4 text-lg">File Manager</h1>
|
||||||
|
@ -98,6 +98,7 @@ const PinFilesForm = () => {
|
||||||
},
|
},
|
||||||
shouldValidate: "onSubmit",
|
shouldValidate: "onSubmit",
|
||||||
onSubmit(e, { submission }) {
|
onSubmit(e, { submission }) {
|
||||||
|
e.preventDefault();
|
||||||
if (submission?.status === "success") {
|
if (submission?.status === "success") {
|
||||||
const value = submission.value;
|
const value = submission.value;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue