From 50660677fca55f550f8ab56558046409aad13461 Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Wed, 26 May 2021 19:51:01 -0400
Subject: Finish tagging functionality

---
 src/components/common/TaggUserSelectionCell.tsx | 37 +++++++++++++------------
 1 file changed, 19 insertions(+), 18 deletions(-)

(limited to 'src/components/common/TaggUserSelectionCell.tsx')

diff --git a/src/components/common/TaggUserSelectionCell.tsx b/src/components/common/TaggUserSelectionCell.tsx
index 5424ab9b..72c98822 100644
--- a/src/components/common/TaggUserSelectionCell.tsx
+++ b/src/components/common/TaggUserSelectionCell.tsx
@@ -1,23 +1,20 @@
 import React, {useEffect, useState} from 'react';
 import {StyleSheet, View} from 'react-native';
-import {
-  TouchableOpacity,
-  TouchableWithoutFeedback,
-} from 'react-native-gesture-handler';
+import {TouchableWithoutFeedback} from 'react-native-gesture-handler';
 import {ProfilePreview} from '..';
-import {ProfilePreviewType, ScreenType} from '../../types';
+import {MomentTagType, ProfilePreviewType, ScreenType} from '../../types';
 import {SCREEN_WIDTH} from '../../utils';
 import TaggRadioButton from './TaggRadioButton';
 
 interface TaggUserSelectionCellProps {
   item: ProfilePreviewType;
-  selectedUsers: ProfilePreviewType[];
-  setSelectedUsers: Function;
+  tags: MomentTagType[];
+  setTags: (tags: MomentTagType[]) => void;
 }
 const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
   item,
-  selectedUsers,
-  setSelectedUsers,
+  tags,
+  setTags,
 }) => {
   const [pressed, setPressed] = useState<boolean>(false);
 
@@ -26,9 +23,7 @@ const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
    */
   useEffect(() => {
     const updatePressed = () => {
-      const userSelected = selectedUsers.findIndex(
-        (selectedUser) => item.id === selectedUser.id,
-      );
+      const userSelected = tags.findIndex((tag) => item.id === tag.user.id);
       setPressed(userSelected !== -1);
     };
     updatePressed();
@@ -41,14 +36,20 @@ const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
   const handlePress = () => {
     // Add to selected list of users
     if (pressed === false) {
-      setSelectedUsers([...selectedUsers, item]);
+      setTags([
+        ...tags,
+        {
+          id: '',
+          x: 50,
+          y: 50,
+          z: 1,
+          user: item,
+        },
+      ]);
     }
     // Remove item from selected list of users
     else {
-      const filteredSelection = selectedUsers.filter(
-        (user) => user.id !== item.id,
-      );
-      setSelectedUsers(filteredSelection);
+      setTags(tags.filter((tag) => tag.user.id !== item.id));
     }
   };
   return (
@@ -60,7 +61,7 @@ const TaggUserSelectionCell: React.FC<TaggUserSelectionCellProps> = ({
           screenType={ScreenType.Profile}
         />
       </View>
-      <TaggRadioButton pressed={pressed} onPress={handlePress} />
+      <TaggRadioButton pressed={pressed} onPress={() => null} />
     </TouchableWithoutFeedback>
   );
 };
-- 
cgit v1.2.3-70-g09d2

