11import React , { useState } from "react" ;
22import { AntDesign } from "@expo/vector-icons" ;
33import { Button , Colors , Paragraph } from "react-native-paper" ;
4- import { gql , useMutation } from "@apollo/client" ;
4+ import { useMutation } from "@apollo/client" ;
55import {
66 Linking ,
77 Modal ,
@@ -10,7 +10,19 @@ import {
1010 StyleSheet ,
1111} from "react-native" ;
1212
13- export const Upvote = ( { idHero, heroCounter, twitterUsername } ) => {
13+ import { MUTATION_COUNTER } from "~/graphql/mutations" ;
14+
15+ interface UpvoteProps {
16+ idHero : string ;
17+ heroCounter : number ;
18+ twitterUsername : string ;
19+ }
20+
21+ export const Upvote = ( {
22+ idHero,
23+ heroCounter,
24+ twitterUsername,
25+ } : UpvoteProps ) => {
1426 const [ counter , setCounter ] = useState < number > ( heroCounter ) ;
1527 const [ hasUpvoted , setHasUpvoted ] = useState < boolean > ( false ) ;
1628 const [ addTodo ] = useMutation ( MUTATION_COUNTER ) ;
@@ -30,14 +42,14 @@ export const Upvote = ({ idHero, heroCounter, twitterUsername }) => {
3042 const style = hasUpvoted
3143 ? {
3244 borderColor : Colors . orange900 ,
33- backgroundColor : " white" ,
45+ backgroundColor : Colors . white ,
3446 borderWidth : 2 ,
3547 }
36- : { backgroundColor : " white" } ;
48+ : { backgroundColor : Colors . white } ;
3749
3850 const styleIcon = hasUpvoted
3951 ? { color : Colors . orange900 }
40- : { color : " black" } ;
52+ : { color : Colors . black } ;
4153
4254 return (
4355 < >
@@ -79,18 +91,6 @@ export const Upvote = ({ idHero, heroCounter, twitterUsername }) => {
7991 ) ;
8092} ;
8193
82- const MUTATION_COUNTER = gql `
83- mutation update_counter($id: Int!) {
84- update_heroes(where: { id: { _eq: $id } }, _inc: { counter: 1 }) {
85- affected_rows
86- returning {
87- id
88- counter
89- }
90- }
91- }
92- ` ;
93-
9494export const styles = StyleSheet . create ( {
9595 modalShareView : {
9696 margin : 20 ,
@@ -100,7 +100,7 @@ export const styles = StyleSheet.create({
100100 width : "70%" ,
101101 height : "20%" ,
102102 alignItems : "center" ,
103- shadowColor : "#000" ,
103+ shadowColor : Colors . black ,
104104 shadowOffset : {
105105 width : 0 ,
106106 height : 2 ,
0 commit comments