Skip to content

Commit

Permalink
add useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Nov 2, 2024
1 parent ba50762 commit cbe81df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/AddPeopleToTag/AddPeopleToTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { GridCellParams, GridColDef } from '@mui/x-data-grid';
import { DataGrid } from '@mui/x-data-grid';
import { USER_TAGS_MEMBERS_TO_ASSIGN_TO } from 'GraphQl/Queries/userTagQueries';
import type { ChangeEvent } from 'react';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Modal, Form, Button } from 'react-bootstrap';
import { useParams } from 'react-router-dom';
import type { InterfaceQueryUserTagsMembersToAssignTo } from 'utils/interfaces';
Expand Down Expand Up @@ -63,6 +63,7 @@ const AddPeopleToTag: React.FC<InterfaceAddPeopleToTagProps> = ({
data: userTagsMembersToAssignToData,
loading: userTagsMembersToAssignToLoading,
error: userTagsMembersToAssignToError,
refetch: userTagsMembersToAssignToRefetch,
fetchMore: fetchMoreMembersToAssignTo,
}: InterfaceTagUsersToAssignToQuery = useQuery(
USER_TAGS_MEMBERS_TO_ASSIGN_TO,
Expand All @@ -79,6 +80,12 @@ const AddPeopleToTag: React.FC<InterfaceAddPeopleToTagProps> = ({
},
);

useEffect(() => {
setMemberToAssignToSearchFirstName('');
setMemberToAssignToSearchLastName('');
userTagsMembersToAssignToRefetch();
}, [addPeopleToTagModalIsOpen]);

const loadMoreMembersToAssignTo = (): void => {
fetchMoreMembersToAssignTo({
variables: {
Expand Down
6 changes: 5 additions & 1 deletion src/screens/OrganizationTags/OrganizationTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Loader from 'components/Loader/Loader';
import IconComponent from 'components/IconComponent/IconComponent';
import { useNavigate, useParams, Link } from 'react-router-dom';
import type { ChangeEvent } from 'react';
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Form } from 'react-bootstrap';
import Button from 'react-bootstrap/Button';
import Dropdown from 'react-bootstrap/Dropdown';
Expand Down Expand Up @@ -121,6 +121,10 @@ function OrganizationTags(): JSX.Element {
});
};

useEffect(() => {
orgUserTagsRefetch();
}, []);

const [create, { loading: createUserTagLoading }] =
useMutation(CREATE_USER_TAG);

Expand Down

0 comments on commit cbe81df

Please sign in to comment.