-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(data-science): 🎉 add new ds feature
- Loading branch information
1 parent
4475de7
commit ebb0cab
Showing
6 changed files
with
214 additions
and
37 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,55 @@ | ||
import { Fragment, ReactElement, useState } from "react"; | ||
import Button from "../Button/Button"; | ||
import StartStopModal from "../../modals/StartStopModal"; | ||
|
||
interface IStartStopCell { | ||
isRunning: boolean; | ||
loading?: boolean; | ||
disabled?: boolean; | ||
modalText?: string; | ||
handleStart: () => void; | ||
handleStop: () => void; | ||
} | ||
|
||
export default function StartStopCell({ | ||
isRunning, | ||
loading, | ||
disabled, | ||
modalText, | ||
handleStart, | ||
handleStop, | ||
}: IStartStopCell): ReactElement { | ||
const [isOpenModal, setIsOpenModal] = useState<boolean>(false); | ||
|
||
return ( | ||
<Fragment> | ||
{loading ? ( | ||
<img | ||
className="h-10 w-10" | ||
src="/svg/general/loading.svg" | ||
alt="loading" | ||
/> | ||
) : ( | ||
<Button | ||
className={`!h-9 ${ | ||
isRunning && | ||
"border border-primary-500 !bg-transparent !text-primary-500" | ||
}`} | ||
disabled={disabled} | ||
loading={disabled} | ||
text={isRunning ? "Stop" : "Start"} | ||
onClick={() => setIsOpenModal(true)} | ||
/> | ||
)} | ||
{isOpenModal && ( | ||
<StartStopModal | ||
isRunning={isRunning} | ||
handleStart={handleStart} | ||
handleStop={handleStop} | ||
handleCloseModal={() => setIsOpenModal(false)} | ||
text={modalText} | ||
/> | ||
)} | ||
</Fragment> | ||
); | ||
} |
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,48 @@ | ||
import { ReactElement } from "react"; | ||
import { Dialog } from "primereact/dialog"; | ||
import Button from "../components/Button/Button"; | ||
|
||
interface IStartStopModal { | ||
header?: string; | ||
text?: string; | ||
handleCloseModal: () => void; | ||
isRunning?: boolean; | ||
handleStart: () => void; | ||
handleStop: () => void; | ||
} | ||
|
||
export default function StartStopModal({ | ||
header, | ||
text, | ||
handleCloseModal, | ||
isRunning, | ||
handleStart, | ||
handleStop, | ||
}: IStartStopModal): ReactElement { | ||
return ( | ||
<Dialog | ||
header={`${header || ""} Service Log`} | ||
visible={true} | ||
className="w-[40vw]" | ||
onHide={() => handleCloseModal()} | ||
> | ||
<div className="flex flex-col gap-2"> | ||
<p className="text-sm">{text}</p> | ||
<div className="flex justify-end gap-4"> | ||
<Button | ||
className="!h-9 !w-28 border border-primary-500 !bg-transparent !text-primary-500" | ||
text="Cancel" | ||
onClick={() => handleCloseModal()} | ||
/> | ||
<Button | ||
className="!h-9 !w-28" | ||
text={isRunning ? "Stop" : "Start"} | ||
onClick={() => { | ||
isRunning ? handleStop() : handleStart(); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</Dialog> | ||
); | ||
} |