-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7ac101
commit 393d831
Showing
31 changed files
with
433 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Share2 } from 'lucide-react'; | ||
import React, { useState } from 'react'; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; | ||
|
||
const ExperimentShare = ({ experimentID }: { experimentID: string }) => { | ||
const [copied, setCopied] = useState(false); | ||
const currentPageLink = `${process.env.NEXT_PUBLIC_FRONTEND_URL}/experiments/${experimentID}`; | ||
|
||
const copyLinkToClipboard = async () => { | ||
await navigator.clipboard.writeText(currentPageLink); | ||
setCopied(true); | ||
setTimeout(() => { | ||
setCopied(false); | ||
}, 2000); | ||
}; | ||
|
||
return ( | ||
<TooltipProvider> | ||
<Tooltip open={copied}> | ||
<TooltipTrigger asChild> | ||
<Button variant="outline" className="text-sm" onClick={copyLinkToClipboard}> | ||
<Share2 className="w-4 h-4 mr-2" /> Share | ||
</Button> | ||
</TooltipTrigger> | ||
<TooltipContent side="right">Copied!</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
); | ||
}; | ||
|
||
export default ExperimentShare; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { getAccessToken } from "@privy-io/react-auth"; | ||
import backendUrl from "lib/backendUrl"; | ||
|
||
export const updateFlow = async (flowId: string): Promise<any> => { | ||
let authToken; | ||
try { | ||
authToken = await getAccessToken() | ||
} catch (error) { | ||
console.log('Failed to get access token: ', error) | ||
throw new Error("Authentication failed"); | ||
} | ||
|
||
const requestUrl = `${backendUrl()}/flows/${flowId}`; | ||
const requestOptions = { | ||
method: 'PUT', | ||
headers: { | ||
'Authorization': `Bearer ${authToken}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
}; | ||
|
||
try { | ||
const response = await fetch(requestUrl, requestOptions); | ||
if (!response.ok) { | ||
throw new Error(`Failed to update Flow: ${response.statusText}`); | ||
} | ||
const result = await response.json(); | ||
return result; | ||
} catch (error) { | ||
console.error('Failed to update Flow:', error); | ||
throw new Error('Failed to update Flow'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './selectors' | ||
export * from './slice' | ||
export * from './thunks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { ReduxState } from '@/lib/redux' | ||
|
||
export const selectFlowUpdateLoading = (state: ReduxState) => state.flowUpdate.loading; | ||
export const selectFlowUpdateError = (state: ReduxState) => state.flowUpdate.error; | ||
export const selectFlowUpdateSuccess = (state: ReduxState) => state.flowUpdate.success; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
|
||
export interface FlowUpdateSliceState { | ||
loading: boolean; | ||
error: string | null; | ||
success: boolean; | ||
} | ||
|
||
const initialState: FlowUpdateSliceState = { | ||
loading: false, | ||
error: null, | ||
success: false, | ||
}; | ||
|
||
export const flowUpdateSlice = createSlice({ | ||
name: "FlowUpdate", | ||
initialState, | ||
reducers: { | ||
setFlowUpdateLoading: (state, action: PayloadAction<boolean>) => { | ||
state.loading = action.payload; | ||
}, | ||
setFlowUpdateError: (state, action: PayloadAction<string | null>) => { | ||
state.error = action.payload; | ||
}, | ||
setFlowUpdateSuccess: (state, action: PayloadAction<boolean>) => { | ||
state.success = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { | ||
setFlowUpdateLoading, | ||
setFlowUpdateError, | ||
setFlowUpdateSuccess, | ||
} = flowUpdateSlice.actions; | ||
|
||
export default flowUpdateSlice.reducer; |
Oops, something went wrong.