wedman
wedman
Explore posts from servers
DDeno
Created by wedman on 5/28/2024 in #help
Is it possible to change a fresh.js project to build ahead-of-time
No description
4 replies
DDeno
Created by wedman on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
Hi there! I recently found this plugin for Tailwind: https://github.com/jamiebuilds/tailwindcss-animate, which is supposed to help to define even more properties on the tailwind animations. For example
animate-hover delay-20
animate-hover delay-20
if I have understood everything correctly. However I have really struggled to import it. How would one go about importing this into a fresh fresh.js project. I'm using Fresh.1.5.2, Thanks in advance;)
13 replies
DDeno
Created by wedman on 2/12/2024 in #help
Problem rerender a island when updating the value of a signal!
No description
8 replies
DDeno
Created by wedman on 12/13/2023 in #help
How can I make sure the code gets run on the client-side??!
No description
13 replies
DDeno
Created by wedman on 11/4/2023 in #help
Making Post Request To HubSpot Api
Hi there I'm trying to make a post request to the HubSpot Api. However the request results in a "HubSpot API responded with status: 401" ´401 Unauthorized is returned when the authentication provided is invalid.´ https://developers.hubspot.com/docs/api/crm/contacts Selected scopes on the HubSpot app: crm.objects.companies.read crm.objects.contacts.read crm.objects.contacts.write crm.objects.companies.write
const body = {
"properties": {
"email": data.email,
"phone": "(877) 929-0687",
"company": "Biglytics",
"website": "biglytics.net",
"lastname": data.lastname,
"firstname": data.firstname
}
};

// Make the POST request to HubSpot
const response = await fetch('https://api.hubapi.com/crm/v3/objects/contacts', {
method: 'POST',
headers: {
'content-type': 'application/json',
'authorization': `Bearer ${HUBSPOT_ACCESS_TOKEN}`
},
body: JSON.stringify(body)
});

if (response.ok) {
const result = await response.json();
console.log(result);
} else {
throw new Error(`HubSpot API responded with status: ${response.status}`);
}
const body = {
"properties": {
"email": data.email,
"phone": "(877) 929-0687",
"company": "Biglytics",
"website": "biglytics.net",
"lastname": data.lastname,
"firstname": data.firstname
}
};

// Make the POST request to HubSpot
const response = await fetch('https://api.hubapi.com/crm/v3/objects/contacts', {
method: 'POST',
headers: {
'content-type': 'application/json',
'authorization': `Bearer ${HUBSPOT_ACCESS_TOKEN}`
},
body: JSON.stringify(body)
});

if (response.ok) {
const result = await response.json();
console.log(result);
} else {
throw new Error(`HubSpot API responded with status: ${response.status}`);
}
All help is super appreciative! Thank you in advance!
4 replies
DDeno
Created by wedman on 10/24/2023 in #help
How do I import the stripe SDK into my fresh.js project
Hi there! How do I import the stripe SDK into my fresh.js project? Im struggling with my deno.json file and how to initialize the SDK in a typescript file
4 replies
DDeno
Created by wedman on 10/13/2023 in #help
Struggling with interactive FreshCharts
Hi there I'm trying to display charts in my fresh js project. i want to have them as islands according to the github repo https://github.com/denoland/fresh_charts the /islands/chart.tsx should look like this
import { Chart as default } from "$fresh_charts/island.tsx";
import { Chart as default } from "$fresh_charts/island.tsx";
So i import the library in deno.json
"@fresh-charts/island": "https://deno.land/x/fresh_charts@0.3.1/island.tsx"
"@fresh-charts/island": "https://deno.land/x/fresh_charts@0.3.1/island.tsx"
and bellow is my /island/chart.tsx
import { Chart as default } from "@fresh-charts/island";
import { Chart as default } from "@fresh-charts/island";
But i get a error: Identifier expected. they have little showcase here https://fresh-charts.deno.dev/ What am I doing wrong?? 🙂
11 replies
DDeno
Created by wedman on 10/11/2023 in #help
How do I rerender my island after a signal change?
Hi there im trying to rerender this sidebar navigation when you toggle it, making it change size and changing the button but nothing really happens! Thx in advance for your input!
import { useSignal } from '@preact/signals';

interface SidebarNavProps {
loggedIn: boolean;
}

export default function SidebarNav({ loggedIn }: SidebarNavProps) {
const isSidebarOpen = useSignal(false);
const toggleSidebar = () => {
isSidebarOpen.value = !isSidebarOpen.value;
console.log(isSidebarOpen.value);
};

return (
<div class={`relative ${isSidebarOpen ? 'w-64' : 'w-16'} transition-all ease-in-out duration-300 overflow-hidden z-10 h-screen`}>
<button onClick={toggleSidebar} class={`absolute top-1/2 text-black rounded-full focus:outline-none z-20`}>
{isSidebarOpen ? '←' : '→'}
</button>

<div class={`absolute top-0 left-0 h-full p-4 bg-gray shadow-lg rounded-r-md ${isSidebarOpen ? 'block' : 'hidden'}`}>
{loggedIn ? (
<>
<a href="/dashboard" class="block p-2 text-blue-500">Dashboard</a>
<a href="/logout" class="block p-2 text-blue-500">Logout</a>
</>
) : (
<>
<a href="/login" class="block p-2 text-blue-500">Login</a>
<a href="/register" class="block p-2 text-blue-500">Register</a>
</>
)}
</div>
</div>
);
}
import { useSignal } from '@preact/signals';

interface SidebarNavProps {
loggedIn: boolean;
}

export default function SidebarNav({ loggedIn }: SidebarNavProps) {
const isSidebarOpen = useSignal(false);
const toggleSidebar = () => {
isSidebarOpen.value = !isSidebarOpen.value;
console.log(isSidebarOpen.value);
};

return (
<div class={`relative ${isSidebarOpen ? 'w-64' : 'w-16'} transition-all ease-in-out duration-300 overflow-hidden z-10 h-screen`}>
<button onClick={toggleSidebar} class={`absolute top-1/2 text-black rounded-full focus:outline-none z-20`}>
{isSidebarOpen ? '←' : '→'}
</button>

<div class={`absolute top-0 left-0 h-full p-4 bg-gray shadow-lg rounded-r-md ${isSidebarOpen ? 'block' : 'hidden'}`}>
{loggedIn ? (
<>
<a href="/dashboard" class="block p-2 text-blue-500">Dashboard</a>
<a href="/logout" class="block p-2 text-blue-500">Logout</a>
</>
) : (
<>
<a href="/login" class="block p-2 text-blue-500">Login</a>
<a href="/register" class="block p-2 text-blue-500">Register</a>
</>
)}
</div>
</div>
);
}
3 replies
DDeno
Created by wedman on 10/9/2023 in #help
Preact hooks doesn't get executed!
im having a little problem, the hooks from preact doesn't seem to run, canst see any errors in the terminal and the dependency is imported. Would love to get help:) import { useEffect } from "preact/hooks"; export default function MyPage() { useEffect(()=> { console.log("this message will not be executed:(") }, []); return ( blah blah blah ) }
15 replies
CC#
Created by wedman on 1/24/2023 in #help
❔ Async function seems to continue running after returning.
Hi there I'm doing a post request to a REST API. I can see that the callback is running in the console when its printing the Debug.Log. So I would assume that the function would return a User that isn't null but it doesn't. I'm a bit new to asynchronous code and would love to know if I got all of this wrong and if you know a solution to my problem.
public static async Task<User> SignInAnonymous() {
RestClient.Post<ExchangeRefreshTokenResponse>(currentRequest).Then(response => {
Debug.Log(("IDTOKEN: " + response.id_token, "REFRESHTOKEN: " + response.refresh_token, "USERID: " + response.user_id));
IdToken = response.id_token;
LocalId = response.user_id;
RefreshToken = response.refresh_token;
RefreshTokenChanged.Invoke(RefreshToken);
return new User("Anonymous", response.user_id, response.id_token);

}).Catch(error => {
Debug.Log(error.Message);
});
await Task.Delay(REQUEST_TIMEOUT);
return null;
}
public static async Task<User> SignInAnonymous() {
RestClient.Post<ExchangeRefreshTokenResponse>(currentRequest).Then(response => {
Debug.Log(("IDTOKEN: " + response.id_token, "REFRESHTOKEN: " + response.refresh_token, "USERID: " + response.user_id));
IdToken = response.id_token;
LocalId = response.user_id;
RefreshToken = response.refresh_token;
RefreshTokenChanged.Invoke(RefreshToken);
return new User("Anonymous", response.user_id, response.id_token);

}).Catch(error => {
Debug.Log(error.Message);
});
await Task.Delay(REQUEST_TIMEOUT);
return null;
}
7 replies