All files / src/components/Playbooks/task/source SelectSource.tsx

0% Statements 0/14
0% Branches 0/8
0% Functions 0/2
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                                                                       
import { useDispatch, useSelector } from "react-redux";
import { updateSource } from "../../../../store/features/playbook/playbookSlice.ts";
import useIsPrefetched from "../../../../hooks/playbooks/useIsPrefetched.ts";
import { InputTypes } from "../../../../types/inputs/inputTypes.ts";
import CustomInput from "../../../Inputs/CustomInput.tsx";
import useCurrentTask from "../../../../hooks/playbooks/task/useCurrentTask.ts";
import { commonKeySelector } from "../../../../store/features/common/commonSlice.ts";
 
type SelectSourceType = {
  id: string | undefined;
  showLabel?: boolean;
  options?: any[];
};
 
function SelectSource({
  id,
  showLabel = true,
  options = undefined,
}: SelectSourceType) {
  const { connectorOptions } = useSelector(commonKeySelector);
  const [task, currentStepId] = useCurrentTask(id);
  const dispatch = useDispatch();
  const isPrefetched = useIsPrefetched();
 
  function handleSourceChange(id) {
    dispatch(updateSource({ id: currentStepId, value: id }));
  }
 
  return (
    <div className="flex flex-col">
      <CustomInput
        label={showLabel ? "Data Source" : ""}
        options={options ?? connectorOptions}
        inputType={InputTypes.DROPDOWN}
        value={task?.source ?? ""}
        handleChange={handleSourceChange}
        disabled={!!isPrefetched}
      />
    </div>
  );
}
 
export default SelectSource;