Skip to content

Commit ca4d97f

Browse files
feat: add wallet connection prompt in TaskRawData component (#80)
* feat: add wallet connection prompt in TaskRawData component * feat: enhance CopyButton integration in JsonBlock component
1 parent 839a774 commit ca4d97f

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/components/CopyButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const CopyButton = ({
6262
}}
6363
onMouseEnter={handleMouseEnter}
6464
onMouseLeave={handleMouseLeave}
65-
className="hover:before:bg-muted active:before:bg-secondary relative z-0 -mx-1 -my-1 items-center gap-1 px-1 py-1 transition-colors before:absolute before:inset-0 before:-z-10 before:rounded-lg before:duration-200 active:before:scale-x-[0.98] active:before:scale-y-[0.94]"
65+
className="hover:before:bg-muted active:before:bg-secondary relative z-0 -mx-1 -my-1 flex items-center gap-1 px-1 py-1 transition-colors before:absolute before:inset-0 before:-z-10 before:rounded-lg before:duration-200 active:before:scale-x-[0.98] active:before:scale-y-[0.94]"
6666
>
6767
{buttonText && <span className="mr-1 text-sm">{buttonText}</span>}
6868
<Copy className="size-4 flex-none" />

src/modules/JsonBlock.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ const JsonBlock = ({
4646
displayObjectSize={false}
4747
enableClipboard={false}
4848
collapsed={collapsed}
49+
shortenTextAfterLength={100}
4950
style={defaultJsonViewStyle}
5051
/>
5152
</div>
52-
{enableClipboard && <CopyButton textToCopy={rawToCopy} />}
53+
{enableClipboard && (
54+
<CopyButton buttonText="Copy Json" textToCopy={rawToCopy} />
55+
)}
5356
</div>
5457
);
5558
};

src/modules/tasks/task/TaskRawData.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { TABLE_REFETCH_INTERVAL } from '@/config';
22
import { useQuery } from '@tanstack/react-query';
3+
import { Button } from '@/components/ui/button';
34
import { getIExec } from '@/externals/iexecSdkClient';
5+
import { useLoginLogout } from '@/hooks/useLoginLogout';
46
import { ErrorAlert } from '@/modules/ErrorAlert';
57
import JsonBlock from '@/modules/JsonBlock';
68
import useUserStore from '@/stores/useUser.store';
@@ -59,6 +61,8 @@ export function TaskRawData({
5961
hasPastError,
6062
isLoading,
6163
} = useTaskRawData({ taskWorkerpoolId, taskId });
64+
const { address: userAddress } = useUserStore();
65+
const { login } = useLoginLogout();
6266

6367
return hasPastError && (!tasks || !tasks.length) ? (
6468
<ErrorAlert
@@ -67,11 +71,23 @@ export function TaskRawData({
6771
}
6872
/>
6973
) : (
70-
<div className="dark:bg-tooltip min-h-40 rounded-3xl border bg-[#fafaff] p-6">
71-
{isLoading ? (
74+
<div className="dark:bg-tooltip flex max-h-none min-h-60 rounded-3xl border bg-[#fafaff] p-6">
75+
{!userAddress ? (
76+
<div className="flex flex-1 flex-col items-center justify-center gap-6 text-center">
77+
<h1 className="text-2xl font-bold">You are not connected</h1>
78+
<p className="text-muted-foreground max-w-sm">
79+
To access task raw data please connect your wallet.
80+
</p>
81+
<div className="flex gap-4">
82+
<Button onClick={login}>Connect wallet</Button>
83+
</div>
84+
</div>
85+
) : isLoading ? (
7286
<p>Loading...</p>
7387
) : (
74-
<JsonBlock collapsed={5}>{tasks}</JsonBlock>
88+
<JsonBlock className="w-full" collapsed={5}>
89+
{tasks}
90+
</JsonBlock>
7591
)}
7692
</div>
7793
);

0 commit comments

Comments
 (0)