Nishil Faldu
Nishil Faldu
CCConvex Community
Created by Shane on 6/13/2024 in #support-community
clerk and convex user not found
Why do you have a .tsx file in convex?
24 replies
CCConvex Community
Created by Gorka Cesium on 4/4/2024 in #support-community
intermitent failure Clerk: `const identity = await ctx.auth.getUserIdentity();`
for me https://docs.convex.dev/auth/clerk#under-the-hood this link on convex docs was very helpful for my understanding (of how things work) and I didn't actually know that <Authenticated/> and other Auth components exist lol - so it was great knowing about those! After that it made sense that the auth takes some time to load and I must use some loading indicator before I render the component with queries - hence the solution
93 replies
CCConvex Community
Created by Gorka Cesium on 4/4/2024 in #support-community
intermitent failure Clerk: `const identity = await ctx.auth.getUserIdentity();`
Components with queries and mutations wrapped with <Authenticated/> and a custom skeleton wrapped in <AuthLoading/> has been working great for me so far!
93 replies
CCConvex Community
Created by Gorka Cesium on 4/4/2024 in #support-community
intermitent failure Clerk: `const identity = await ctx.auth.getUserIdentity();`
There were some really good points made in this conversation and helped me decide the next steps. Thank you all!
93 replies
CCConvex Community
Created by Gorka Cesium on 4/4/2024 in #support-community
intermitent failure Clerk: `const identity = await ctx.auth.getUserIdentity();`
I have also been facing this issue and have been using a workaround (probably not the best one) and would like someone to comment on this if they have a nice solution 😃
93 replies
CCConvex Community
Created by Nishil Faldu on 4/1/2024 in #support-community
Lost Typings on the client side (Next + Convex Project)
It kept flickering after that change, like sometimes it would show the error, sometimes it wouldn't so I explicitly set types for all action-handlers. Thank you so much for your help! I really appreciate it!
17 replies
CCConvex Community
Created by Nishil Faldu on 4/1/2024 in #support-community
Lost Typings on the client side (Next + Convex Project)
And I am assuming such a thing has side effects like losing type safety?
17 replies
CCConvex Community
Created by Nishil Faldu on 4/1/2024 in #support-community
Lost Typings on the client side (Next + Convex Project)
export const storeStripeCustomerId = action({
args: {},
handler: async ctx => {
const stripe = new Stripe(
process.env.STRIPE_SECRET_KEY! ?? "",
{
apiVersion: "2023-10-16",
typescript: true,
}
);

const user = await ctx.runQuery(internal.users.getUserInternalQuery);
if (!user) {
throw new Error("User not found");
}

if(!user.stripeId) {
const customer = await stripe.customers.create({
email: user.email,
name: user.firstName + " " + user.lastName,
});

const stripeId : string
= await ctx.runMutation(internal.users.storeStripeId, { userId: user._id, stripeId: customer.id });

return stripeId;
}

return user.stripeId;
},
});
export const storeStripeCustomerId = action({
args: {},
handler: async ctx => {
const stripe = new Stripe(
process.env.STRIPE_SECRET_KEY! ?? "",
{
apiVersion: "2023-10-16",
typescript: true,
}
);

const user = await ctx.runQuery(internal.users.getUserInternalQuery);
if (!user) {
throw new Error("User not found");
}

if(!user.stripeId) {
const customer = await stripe.customers.create({
email: user.email,
name: user.firstName + " " + user.lastName,
});

const stripeId : string
= await ctx.runMutation(internal.users.storeStripeId, { userId: user._id, stripeId: customer.id });

return stripeId;
}

return user.stripeId;
},
});
here's the whole thing boss
17 replies
CCConvex Community
Created by Nishil Faldu on 4/1/2024 in #support-community
Lost Typings on the client side (Next + Convex Project)
No description
17 replies
CCConvex Community
Created by Nishil Faldu on 3/20/2024 in #support-community
Action, Internal, Query and Mutation
I am running the above in a hook like this on the client side
export default function useStoreStripeCustomerEffect() {
// const { isAuthenticated } = useConvexAuth();
const [stripeCustomerId, setStripeCustomerId] = useState<string | null>(null);

const storeStripeCustomerId = useAction(api.stripe.storeStripeCustomerId);

useEffect(() => {
// if (!isAuthenticated) { return; }

async function createStoreStripeCustomer() {
const id = await storeStripeCustomerId();
setStripeCustomerId(id);
console.log("blaa 1");
}

createStoreStripeCustomer();

return () => setStripeCustomerId(null);
}, [storeStripeCustomerId]);

return stripeCustomerId;
}
export default function useStoreStripeCustomerEffect() {
// const { isAuthenticated } = useConvexAuth();
const [stripeCustomerId, setStripeCustomerId] = useState<string | null>(null);

const storeStripeCustomerId = useAction(api.stripe.storeStripeCustomerId);

useEffect(() => {
// if (!isAuthenticated) { return; }

async function createStoreStripeCustomer() {
const id = await storeStripeCustomerId();
setStripeCustomerId(id);
console.log("blaa 1");
}

createStoreStripeCustomer();

return () => setStripeCustomerId(null);
}, [storeStripeCustomerId]);

return stripeCustomerId;
}
4 replies