All files / src/components/Workflows/create/notifications SlackMessage.tsx

0% Statements 0/19
0% Branches 0/7
0% Functions 0/4
0% Lines 0/18

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 45 46 47 48 49 50 51                                                                                                     
import { CircularProgress } from "@mui/material";
import React from "react";
import { handleInput } from "../../utils/handleInputs.ts";
import { useSelector } from "react-redux";
import { currentWorkflowSelector } from "../../../../store/features/workflow/workflowSlice.ts";
import { useGetTriggerOptionsQuery } from "../../../../store/features/triggers/api/getTriggerOptionsApi.ts";
import AddNewIntegration from "./AddNewIntegration.tsx";
import CustomInput from "../../../Inputs/CustomInput.tsx";
import { InputTypes } from "../../../../types/inputs/inputTypes.ts";
import { LabelPosition } from "../../../../types/inputs/labelPosition.ts";
 
function SlackMessage() {
  const currentWorkflow = useSelector(currentWorkflowSelector);
  const { data: options, isFetching, refetch } = useGetTriggerOptionsQuery();
  const data = options?.active_channels;
  const channelOptions = data?.map((e) => {
    return {
      id: e.channel_id,
      label: e.channel_name,
      channel: e,
    };
  });
 
  return (
    <div className="flex items-center gap-2 mt-2">
      {isFetching && <CircularProgress size={20} />}
      <CustomInput
        label="Select Channel"
        labelPosition={LabelPosition.LEFT}
        inputType={InputTypes.DROPDOWN}
        options={channelOptions}
        placeholder="Select Channel"
        handleChange={(id) => {
          const val = channelOptions.find((d) => d.id === id);
          handleInput("channel", val.channel);
        }}
        value={
          currentWorkflow?.channel?.channel_id ||
          currentWorkflow?.trigger?.channel?.channel_id ||
          ""
        }
        error={currentWorkflow?.errors?.channel ?? false}
        searchable={true}
        suffix={<AddNewIntegration refetch={refetch} data={data} />}
      />
    </div>
  );
}
 
export default SlackMessage;