{"version":3,"file":"BookMatchPercentage-D846y89G.js","sources":["../../../app/javascript/queries/user_books/fragments/UserBookStatusFragmentCompiled.ts","../../../app/javascript/hooks/fragments/userUserBookStatus.ts","../../../app/javascript/components/match/BookMatchPercentage/BookMatchPercentage.tsx"],"sourcesContent":["import { gql } from \"graphql-tag\";\nimport UserBookStatusFragment from \"./UserBookStatusFragment\";\n\nexport default gql(UserBookStatusFragment);\n","import { useEffect, useState } from \"react\";\nimport UserBookStatusFragmentCompiled from \"queries/user_books/fragments/UserBookStatusFragmentCompiled\";\nimport { UserBookStatusType } from \"types/UserBookType\";\nimport { useFragment } from \"lib/apollo/client\";\nimport useCurrentUserId from \"hooks/user/useCurrentUserId\";\n\nexport default function useUserBookStatus(bookId: number) {\n const userId = useCurrentUserId();\n const [userBook, setUserBook] = useState({\n userId,\n bookId,\n statusId: 0,\n });\n const { data } = useFragment({\n fragment: UserBookStatusFragmentCompiled,\n fragmentName: \"UserBookStatusFragment\",\n from: {\n __typename: \"user_books\",\n bookId,\n userId: userId || 0,\n },\n });\n\n useEffect(() => {\n setUserBook(\n data?.userId\n ? data\n : {\n userId,\n bookId,\n statusId: 0,\n }\n );\n }, [userId, data, bookId]);\n\n return userBook;\n}\n","import { slugIdConstants } from \"types/UserBookStatusType\";\nimport useUserBookStatus from \"hooks/fragments/userUserBookStatus\";\n\nimport BookMatchPercentageForUser from \"./BookMatchPercentageForUser\";\n\nexport interface Props {\n bookId: number;\n size?: \"sm\" | \"md\" | \"lg\";\n}\n\nexport default function BookMatchPercentage({ bookId, size = \"sm\" }: Props) {\n const { userId, statusId } = useUserBookStatus(bookId);\n // Don't show match percentage if:\n // Not logged in\n // Already read\n if (!userId || statusId === slugIdConstants.read) {\n return <>;\n }\n return (\n \n );\n}\n"],"names":["UserBookStatusFragmentCompiled","gql","UserBookStatusFragment","useUserBookStatus","bookId","userId","useCurrentUserId","userBook","setUserBook","useState","data","useFragment","useEffect","BookMatchPercentage","size","statusId","slugIdConstants","jsx","Fragment","BookMatchPercentageForUser"],"mappings":"qTAGA,MAAeA,EAAAC,EAAIC,CAAsB,ECGzC,SAAwBC,EAAkBC,EAAgB,CACxD,MAAMC,EAASC,IACT,CAACC,EAAUC,CAAW,EAAIC,WAA6B,CAC3D,OAAAJ,EACA,OAAAD,EACA,SAAU,CAAA,CACX,EACK,CAAE,KAAAM,CAAK,EAAIC,EAAY,CAC3B,SAAUX,EACV,aAAc,yBACd,KAAM,CACJ,WAAY,aACZ,OAAAI,EACA,OAAQC,GAAU,CACpB,CAAA,CACD,EAEDO,OAAAA,EAAAA,UAAU,IAAM,CACdJ,EACEE,GAAA,MAAAA,EAAM,OACFA,EACA,CACE,OAAAL,EACA,OAAAD,EACA,SAAU,CACZ,CAAA,CAEL,EAAA,CAACC,EAAQK,EAAMN,CAAM,CAAC,EAElBG,CACT,CC1BA,SAAwBM,EAAoB,CAAE,OAAAT,EAAQ,KAAAU,EAAO,MAAe,CAC1E,KAAM,CAAE,OAAAT,EAAQ,SAAAU,CAAS,EAAIZ,EAAkBC,CAAM,EAIrD,MAAI,CAACC,GAAUU,IAAaC,EAAgB,KACjCC,EAAA,IAAAC,WAAA,CAAA,CAAA,EAGPD,EAAA,IAACE,EAA2B,CAAA,OAAAf,EAAgB,KAAAU,CAAY,CAAA,CAE9D"}