-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DangerZone.tsx): add toggle intake component to danger zone card, …
…closes #52 feat(ToggleIntake.tsx): add toggle intake component to allow pausing and resuming of project data intake feat(Overview.tsx): add project status to project overview refactor(docker-compose.yml): comment out test service refactor(projectActions.ts): remove unused function and simplify invalidateAllProjectCache function to invalidate all project cache and edit page cache after toggling project paused status
- Loading branch information
1 parent
f20f89a
commit b28a057
Showing
5 changed files
with
76 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use client'; | ||
|
||
import { toggleProjectPausedStatus } from '@/app/_actions'; | ||
import classNames from '@/lib/classNames'; | ||
import { Switch } from '@headlessui/react'; | ||
import { useEffect, useState, useTransition } from 'react'; | ||
|
||
export default function ToggleIntake({ projectId, isPaused }: { projectId: string; isPaused: boolean }) { | ||
const [enabled, setEnabled] = useState(!isPaused); | ||
const [isPending, startTransition] = useTransition(); | ||
|
||
useEffect(() => { | ||
setEnabled(!isPaused); | ||
}, [isPaused]); | ||
|
||
const handleToggle = async () => { | ||
const newEnabledStatus = !enabled; | ||
setEnabled(newEnabledStatus); | ||
startTransition(() => toggleProjectPausedStatus(projectId)); | ||
}; | ||
|
||
return ( | ||
<Switch.Group as="div" className="flex items-center"> | ||
<Switch | ||
checked={enabled} | ||
onChange={handleToggle} | ||
className={classNames( | ||
enabled ? 'bg-indigo-600' : 'bg-gray-200', | ||
'relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2' | ||
)} | ||
> | ||
<span | ||
aria-hidden="true" | ||
className={classNames( | ||
enabled ? 'translate-x-5' : 'translate-x-0', | ||
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out' | ||
)} | ||
/> | ||
</Switch> | ||
<Switch.Label as="span" className="ml-3 text-sm"> | ||
<span className="font-medium text-gray-200">Accept Data</span>{' '} | ||
<span className="text-gray-400">({enabled ? 'Active' : 'Paused'})</span> | ||
</Switch.Label> | ||
</Switch.Group> | ||
); | ||
} |
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