Skip to content

Commit

Permalink
Merge pull request #184 from waldo-vision/ts/fix
Browse files Browse the repository at this point in the history
Attempting ts fix (again)
  • Loading branch information
ceriddenn authored Mar 27, 2023
2 parents bf18dc3 + a158a09 commit afd86e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/web/components/TurnstileWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const TurnstileWidget = (props: WidgetProps) => {
if (props.refreshState > 0) {
//@ts-ignore
ref.current?.reset();
//@ts-ignore
ref.current?.render();
}
}, [props.refreshState]);
const handleCallback = async (token: string, state: CallbackStates) => {
Expand Down
21 changes: 18 additions & 3 deletions apps/web/pages/submissions/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ export default function Review() {
};

const doClickLogic = async (action: 'yes' | 'no') => {
if (!reviewItem) return;
if (!reviewItem) {
setLoading(true);
setFinished(true);
return;
}
// force update turnstile widget
setIsRequestValid(false);
setRefreshState(refreshState + 1);
setLoading(true);

if (!isRequestValid) {
toast({
Expand All @@ -95,6 +99,7 @@ export default function Review() {
isGame: review,
tsToken: tsToken as string,
});
setLoading(true);
await refetch();
setReviewItem(reviewItemData);
setLoading(false);
Expand Down Expand Up @@ -146,7 +151,7 @@ export default function Review() {
<Center h={'100vh'} mt={{ base: 5 }}>
{loading || !reviewItemData || tsToken == '' || tsToken == undefined ? (
<Flex direction={'column'} alignItems={'center'}>
<Spinner color={'purple.500'} size={'xl'} mb={6} />
<Spinner size={'xl'} />
<TurnstileWidget
valid={(result, token) => {
setIsRequestValid(result);
Expand All @@ -162,6 +167,13 @@ export default function Review() {
) : (
<>
<Center mb={4} display={{ base: 'none', md: 'flex' }}></Center>
<TurnstileWidget
valid={(result, token) => {
setIsRequestValid(result);
setTsToken(token);
}}
refreshState={refreshState}
/>
<Box bgColor={'white'} p={6} borderRadius={12}>
<Flex direction={'row'}>
{/* User Icon */}
Expand All @@ -172,6 +184,7 @@ export default function Review() {
width={54}
height={54}
style={{ borderRadius: '100%' }}
onClick={() => setRefreshState(refreshState + 1)}
/>
</Box>
{/* Top titles */}
Expand Down Expand Up @@ -202,6 +215,8 @@ export default function Review() {
? 'Team Fortress 2'
: reviewItem?.gameplayType === 'COD'
? 'Call of Duty'
: reviewItem?.gameplayType === 'R6S'
? 'Raindbow Six Siege'
: 'a relevant First Person Shooter game?'}
</Text>
</Text>
Expand Down

0 comments on commit afd86e2

Please sign in to comment.