Skip to content

Commit

Permalink
used useCampaign() hook for specifying selected specialty type
Browse files Browse the repository at this point in the history
  • Loading branch information
srp-pawar committed Mar 13, 2024
1 parent 0070ec0 commit 4c629cd
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions packages/twenty-front/src/pages/campaigns/Specialty.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-restricted-imports */
import { useState } from 'react';
import { useQuery } from '@apollo/client';
import styled from '@emotion/styled';
import { IconArrowLeft } from '@tabler/icons-react';
Expand Down Expand Up @@ -67,13 +66,13 @@ const StyledTitle = styled.h3`
font-weight: ${({ theme }) => theme.font.weight.medium};
font-size: ${({ theme }) => theme.font.size.md};
`;

export const Specialty = () => {
const { setCurrentStep, currentStep } = useCampaign();
const { setCurrentStep, campaignData, setCampaignData, currentStep } =
useCampaign();

let Specialty: any = [];
const SpecialtyTypes: any = {};
const [specialty, setSpecialty] = useState('');
const [subSpecialty, setSubSpecialty] = useState('');
const { loading: queryLoading, data: queryData } = useQuery(GET_SPECIALTY);

if (!queryLoading) {
Expand Down Expand Up @@ -110,13 +109,6 @@ export const Specialty = () => {
);
}

const handleSpecialtySelectChange = (selectedValue: any) => {
setSpecialty(selectedValue);
};

const handleSubSpecialtySelectChange = (selectedValue: any) => {
setSubSpecialty(selectedValue);
};
return (
<>
<StyledCard>
Expand All @@ -132,12 +124,17 @@ export const Specialty = () => {
<Select
fullWidth
dropdownId="Specialty Type"
value={specialty}
value={campaignData?.specialtyType}
options={Specialty}
onChange={handleSpecialtySelectChange}
onChange={(e) => {
setCampaignData({
...campaignData,
specialtyType: e,
});
}}
/>
</Section>
{specialty && (
{campaignData?.specialtyType && (
<Section>
<H2Title
title="Subspecialty Type"
Expand All @@ -147,9 +144,14 @@ export const Specialty = () => {
<Select
fullWidth
dropdownId="Sub Specialty Type"
value={subSpecialty}
options={SpecialtyTypes[specialty]}
onChange={handleSubSpecialtySelectChange}
value={campaignData?.subSpecialtyType}
options={SpecialtyTypes[campaignData.specialtyType]}
onChange={(e) => {
setCampaignData({
...campaignData,
subSpecialtyType: e,
});
}}
/>
</Section>
)}
Expand Down

0 comments on commit 4c629cd

Please sign in to comment.