<commit_before>import * as FontAwesome from 'react-fontawesome';
import * as React from 'react';
import {
  Mutation,
  MutationComponentOptions,
  MutationFunction,
  useQuery,
} from 'react-apollo';
import {
  StyledProfileForm,
  StyledProfileLabel,
  StyledProfileLogValue,
  StyledProfileValue,
  ThemedMainContainer,
  ThemedSearchContainer,
} from 'components/StyledComponents';
import QUERY from 'queries/UserSavedSearchesQuery';
import { ThemedButton } from '../../LoginPage/StyledButton';
import { UserFragment } from 'types/UserFragment';
import { UserSavedSearchesQuery } from 'types/UserSavedSearchesQuery';


interface UserSavedSearchesProps {
  user: UserFragment | null;
}
interface UserSavedSearchesState {
  isEditing: boolean;
}



export default function UserSavedSearches(props: UserSavedSearchesProps) {
   const userId =  props.user?.id;


    const { data: savedSearch } = useQuery<UserSavedSearchesQuery>(QUERY, {
        variables: { userId },
      });
    console.log("UserSavedSearches -> savedSearches", savedSearch);

    const savedSearches= savedSearch?.savedSearch
      return (
          (savedSearches) ?  
          <div>{"savedSearches"}</div>
             
            :
            <StyledProfileLabel>
                No Saved Searches for user {props.user?.email}
            </StyledProfileLabel>
  
      );
}


/* 
  //! Map for user saved searches
  savedSearches.map( (search)=>(
    <>
  <StyledProfileLogValue>
    {
      
    }
    <ThemedButton
      style={{ fontSize: '12px', padding: '6px 8px', float: 'right' , margin: "1px 2px" }}
      onClick={() => console.log('Click FAVORITE ')}>
      <FontAwesome name="save" />
    </ThemedButton>
    <ThemedButton
      style={{ fontSize: '13px', padding: '5px 9px', float: 'right' , margin: "1px 2px" }}
      onClick={() => console.log('Click DELETE ')}>
      <FontAwesome name="trash" />
    </ThemedButton>
  </StyledProfileLogValue>
 </>
  )) */<commit_msg>Displays user saved searches on profile page<commit_after>import * as FontAwesome from 'react-fontawesome';
import * as React from 'react';
import {
  Mutation,
  MutationComponentOptions,
  MutationFunction,
  useQuery,
} from 'react-apollo';
import {
  StyledProfileForm,
  StyledProfileLabel,
  StyledProfileLogValue,
  StyledProfileValue,
  ThemedMainContainer,
  ThemedSearchContainer,
} from 'components/StyledComponents';
import QUERY from 'queries/UserSavedSearchesQuery';
import { ThemedButton } from '../../LoginPage/StyledButton';
import { UserFragment } from 'types/UserFragment';
import { UserSavedSearchesQuery } from 'types/UserSavedSearchesQuery';


interface UserSavedSearchesProps {
  user: UserFragment | null;
}
interface UserSavedSearchesState {
  isEditing: boolean;
}



export default function UserSavedSearches(props: UserSavedSearchesProps) {
  const userId =  props.user?.id;


    const { data: savedSearch } = useQuery<UserSavedSearchesQuery>(QUERY, {
        variables: { userId },
      });
      const savedSearches= savedSearch?.savedSearch

      return (
          (savedSearches) ?  
          <>{
          savedSearches.map( (search)=>(
          <StyledProfileLogValue>
            {
              search.nameLabel
            }
            <ThemedButton
              style={{ fontSize: '12px', padding: '6px 8px', float: 'right' , margin: "1px 2px" }}
              onClick={() => console.log('Click FAVORITE ')}>
              <FontAwesome name="save" />
            </ThemedButton>
            <ThemedButton
              style={{ fontSize: '13px', padding: '5px 9px', float: 'right' , margin: "1px 2px" }}
              onClick={() => console.log('Click DELETE ')}>
              <FontAwesome name="trash" />
            </ThemedButton>
          </StyledProfileLogValue>        
          ))
        } 
        </>
            :
            <StyledProfileLabel>
                No Saved Searches for user {props.user?.email}
            </StyledProfileLabel>
  
      );
}


//! return statement with the Buttons setup for delete and Edit name of saved search. 
/* 
  return (
          (savedSearches) ?  
          <>{
          savedSearches.map( (search)=>(
          <StyledProfileLogValue>
            {
              search.nameLabel
            }
            <ThemedButton
              style={{ fontSize: '12px', padding: '6px 8px', float: 'right' , margin: "1px 2px" }}
              onClick={() => console.log('Click FAVORITE ')}>
              <FontAwesome name="save" />
            </ThemedButton>
            <ThemedButton
              style={{ fontSize: '13px', padding: '5px 9px', float: 'right' , margin: "1px 2px" }}
              onClick={() => console.log('Click DELETE ')}>
              <FontAwesome name="trash" />
            </ThemedButton>
          </StyledProfileLogValue>        
          ))
        } 
        </>
            :
            <StyledProfileLabel>
                No Saved Searches for user {props.user?.email}
            </StyledProfileLabel>
  
      ); */
{'fraction_non_alphanumeric': 0.12185879537295573, 'fraction_numerical': 0.007179896290386917, 'mean_word_length': 2.4, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3139891', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1512, 'n_words': 317}