Skip to content

Commit

Permalink
Availability Component UI
Browse files Browse the repository at this point in the history
  • Loading branch information
minfeishen2024 authored and WillieCubed committed Feb 22, 2024
1 parent 1aea12a commit 6f33b4f
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.513.0",
"@material-tailwind/react": "^2.1.8",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
Expand Down
172 changes: 170 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/components/ClientOnly.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use client';

import {useEffect, useState} from "react";

interface ClientOnlyProps {
children: React.ReactNode;
}

const ClientOnly:React.FC<ClientOnlyProps> = ({
children
}) => {
const [hasMounted, setHasMounted] = useState(false);

useEffect(() => {
setHasMounted(true);
}, []);

if (!hasMounted) {
return null;
}

return(
<>
{children}
</>
)
}

export default ClientOnly;
62 changes: 62 additions & 0 deletions src/components/appbar/AgentStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use client';

import React, {useState} from 'react';
import {Chip} from "@material-tailwind/react";
import {Button} from "../ui/button";

const AgentStatus:React.FC = () => {

const [isAvailable, setIsAvailable] = useState(false);

const toggleAvailability = async () => {
const newAvailability = !isAvailable;
setIsAvailable(newAvailability);
}

return(
<div className="flex gap-2 justify-center items-center">
<Button
variant="outline"
onClick={toggleAvailability}>
{isAvailable? 'Go Unavailable' : 'Go Available'}
</Button>
<div className="flex gap-2 border border-gray-300 p-2 m-4 bg-gray-100 rounded">



<div>Status</div>

<div>
{isAvailable?
<>
<Chip
variant="ghost"
color="green"
size="sm"
value="Available"
icon={
<span className="mx-auto mt-1 block h-2 w-2 rounded-full bg-green-900 content-['']" />
}
/></>

:
<>
<Chip
variant="ghost"
color="red"
size="sm"
value="Unavailable"
icon={
<span className="mx-auto mt-1 block h-2 w-2 rounded-full bg-red-900 content-['']" />
}
/>
</> }

</div>

</div>
</div>
)
}

export default AgentStatus
Loading

0 comments on commit 6f33b4f

Please sign in to comment.