Fix live site
This commit is contained in:
parent
700875434f
commit
900833c06c
|
|
@ -12,7 +12,7 @@
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Orion Reed",
|
"author": "Jeff Emmett",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dimforge/rapier2d": "^0.11.2",
|
"@dimforge/rapier2d": "^0.11.2",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
|
||||||
return <rect x={0} y={0} width={shape.props.w} height={shape.props.h} />;
|
return <rect x={0} y={0} width={shape.props.w} height={shape.props.h} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
component(shape: IVideoChatShape) {
|
component() {
|
||||||
const [roomUrl, setRoomUrl] = useState(""); // Added roomUrl state
|
const [roomUrl, setRoomUrl] = useState(""); // Added roomUrl state
|
||||||
const [isInRoom, setIsInRoom] = useState(false);
|
const [isInRoom, setIsInRoom] = useState(false);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
@ -43,14 +43,35 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
|
||||||
setError("");
|
setError("");
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/get-or-create-room', { method: 'GET' });
|
const apiKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmFwcGVhci5pbiIsImF1ZCI6Imh0dHBzOi8vYXBpLmFwcGVhci5pbi92MSIsImV4cCI6OTAwNzE5OTI1NDc0MDk5MSwiaWF0IjoxNzI5MTkzOTE3LCJvcmdhbml6YXRpb25JZCI6MjY2MDk5LCJqdGkiOiI0MzI0MmUxMC1kZmRjLTRhYmEtYjlhOS01ZjcwNTFlMTYwZjAifQ.RaxXpZKYl_dOWyoATQZrzyMR2XRh3fHf02mALQiuTTs'; // Replace with your actual API key
|
||||||
const data: { roomUrl?: string; error?: string } = await response.json(); // Explicitly type 'data'
|
console.log(apiKey)
|
||||||
if (data.roomUrl) {
|
// Generate a room name based on a default slug or any logic you prefer
|
||||||
|
const roomNamePrefix = 'default-room'; // You can modify this logic as needed
|
||||||
|
|
||||||
|
const response = await fetch('https://cors-anywhere.herokuapp.com/https://api.whereby.dev/v1/meetings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${apiKey}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
isLocked: false,
|
||||||
|
roomNamePrefix: roomNamePrefix,
|
||||||
|
roomMode: 'normal',
|
||||||
|
endDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(), // 7 days from now
|
||||||
|
fields: ['hostRoomUrl'],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData: { message?: string } = await response.json(); // Explicitly type errorData
|
||||||
|
console.error('Whereby API error:', errorData);
|
||||||
|
throw new Error(`Whereby API error: ${errorData.message || 'Unknown error'}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data: { roomUrl: string } = await response.json(); // Explicitly type the response
|
||||||
setRoomUrl(data.roomUrl); // Set the room URL
|
setRoomUrl(data.roomUrl); // Set the room URL
|
||||||
setIsInRoom(true);
|
setIsInRoom(true);
|
||||||
} else {
|
|
||||||
setError(data.error || "Failed to join room. Please try again.");
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Error joining room:", e);
|
console.error("Error joining room:", e);
|
||||||
setError("An error occurred. Please try again.");
|
setError("An error occurred. Please try again.");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue