-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from KunalSin9h/commit
Commit
- Loading branch information
Showing
11 changed files
with
415 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,117 @@ | ||
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"; | ||
import { useEffect, useState } from "react"; | ||
import { | ||
Sheet, | ||
SheetContent, | ||
SheetDescription, | ||
SheetHeader, | ||
SheetTitle, | ||
SheetTrigger, | ||
} from "@/components/ui/sheet"; | ||
import { CommitIcon } from "@/lib/icons"; | ||
import { Button } from "../ui/button"; | ||
import { | ||
type StateMeta, | ||
getCommitStatus, | ||
commitSettings, | ||
} from "@/lib/settings"; | ||
|
||
export default function Commit() { | ||
return ( | ||
<Dialog> | ||
<DialogTrigger> | ||
<Sheet> | ||
<SheetTrigger> | ||
<div className="bg-white text-black hover:bg-black/10 px-3 py-2 rounded-md cursor-pointer flex items-center gap-2"> | ||
<CommitIcon /> | ||
<span>Commit</span> | ||
</div> | ||
</DialogTrigger> | ||
<DialogContent className="h-[80%] w-[80%] xl:w-[60%] "> | ||
<Button variant={"default"}>Commit</Button> | ||
<div className="m-2 p-2 xl:m-4 xl:p-4"> | ||
<ul> | ||
<li>A</li> | ||
<li>A</li> | ||
<li>A</li> | ||
</ul> | ||
</SheetTrigger> | ||
<SheetContent className=" w-2/3 xl:w-1/3"> | ||
<SheetHeader> | ||
<SheetTitle>Commit Settings!</SheetTitle> | ||
<SheetDescription> | ||
Commit takes snapshot of settings and configs, so that you can revet | ||
back and apply backups. | ||
</SheetDescription> | ||
</SheetHeader> | ||
<div className="px-2 xl:px-4 py-4 xl:py-8"> | ||
<Commits /> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
} | ||
|
||
function Commits() { | ||
const [commitStatus, setCommitStatus] = useState<StateMeta[]>(); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const status = await getCommitStatus(); | ||
setCommitStatus(status); | ||
})(); | ||
}, []); | ||
|
||
if (commitStatus === undefined) return <div>Loading...</div>; | ||
|
||
return ( | ||
<div> | ||
<div className="flex flex-col gap-4 px-4 xl:px-16"> | ||
<span className="text-md">{commitStatus[0].message}</span> | ||
<div className="flex gap-4 items-center"> | ||
<div | ||
className={`${ | ||
commitStatus[0].commit ? "bg-green-100" : "bg-green-300" | ||
} text-black ${ | ||
commitStatus[0].commit | ||
? "pointer-events-none cursor-not-allowed opacity-60" | ||
: "hover:bg-green-400/50" | ||
} px-3 py-2 rounded-md `} | ||
onClick={async (e) => { | ||
e.preventDefault(); | ||
await commitSettings("new commit it is"); | ||
const status = await getCommitStatus(); | ||
setCommitStatus(status); | ||
}} | ||
> | ||
<span className="text-xs uppercase font-bold"> | ||
{commitStatus[0].commit ? "All Good" : "Commit"} | ||
</span> | ||
</div> | ||
<span className="opacity-60 text-xs">{commitStatus[0].time}</span> | ||
</div> | ||
</div> | ||
|
||
<div className="py-4 xl:py-8"> | ||
{commitStatus.slice(1).map((item, index) => { | ||
return <CommitBox key={index} {...item} />; | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function CommitBox({ | ||
message, | ||
commit, | ||
time, | ||
}: { | ||
message: string; | ||
commit: boolean; | ||
time: string; | ||
}) { | ||
return ( | ||
<div className="flex flex-col gap-4 px-4 xl:px-16"> | ||
<span className="text-md">{message}</span> | ||
<div className="flex gap-4 items-center"> | ||
<div | ||
className={`${commit ? "bg-red-300" : "bg-green-300"} text-black ${ | ||
commit ? "hover:bg-red-400/80" : "hover:bg-green-400/50" | ||
} px-3 py-2 rounded-md cursor-pointer`} | ||
> | ||
<span className="text-xs uppercase font-bold"> | ||
{commit ? "Revert" : "Commit"} | ||
</span> | ||
</div> | ||
<span className="opacity-60 text-xs">{time}</span> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog"; | ||
Sheet, | ||
SheetContent, | ||
SheetDescription, | ||
SheetHeader, | ||
SheetTitle, | ||
SheetTrigger, | ||
} from "@/components/ui/sheet"; | ||
import { ExportIcon } from "@/lib/icons"; | ||
|
||
export default function Export() { | ||
export default function Commit() { | ||
return ( | ||
<Dialog> | ||
<DialogTrigger> | ||
<Sheet> | ||
<SheetTrigger> | ||
<div className="bg-white text-black hover:bg-black/10 px-3 py-2 rounded-md cursor-pointer flex items-center gap-2"> | ||
<ExportIcon /> | ||
<span>Export</span> | ||
</div> | ||
</DialogTrigger> | ||
<DialogContent className="h-[80%] w-[80%] xl:w-[60%]"> | ||
<DialogHeader className=""> | ||
<DialogTitle>Are you sure absolutely sure?</DialogTitle> | ||
<DialogDescription> | ||
</SheetTrigger> | ||
<SheetContent className="w-1/3"> | ||
<SheetHeader> | ||
<SheetTitle>Are you sure absolutely sure?</SheetTitle> | ||
<SheetDescription> | ||
This action cannot be undone. This will permanently delete your | ||
account and remove your data from our servers. | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
</SheetDescription> | ||
</SheetHeader> | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog"; | ||
Sheet, | ||
SheetContent, | ||
SheetDescription, | ||
SheetHeader, | ||
SheetTitle, | ||
SheetTrigger, | ||
} from "@/components/ui/sheet"; | ||
import { ImportIcon } from "@/lib/icons"; | ||
|
||
export default function Import() { | ||
export default function Commit() { | ||
return ( | ||
<Dialog> | ||
<DialogTrigger> | ||
<Sheet> | ||
<SheetTrigger> | ||
<div className="bg-white text-black hover:bg-black/10 px-3 py-2 rounded-md cursor-pointer flex items-center gap-2"> | ||
<ImportIcon /> | ||
<span>Import</span> | ||
</div> | ||
</DialogTrigger> | ||
<DialogContent className="h-[80%] w-[80%] xl:w-[60%]"> | ||
<DialogHeader className=""> | ||
<DialogTitle>Are you sure absolutely sure?</DialogTitle> | ||
<DialogDescription> | ||
</SheetTrigger> | ||
<SheetContent className="w-1/3"> | ||
<SheetHeader> | ||
<SheetTitle>Are you sure absolutely sure?</SheetTitle> | ||
<SheetDescription> | ||
This action cannot be undone. This will permanently delete your | ||
account and remove your data from our servers. | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
</SheetDescription> | ||
</SheetHeader> | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.