Enhance License Key Management: Add loading state for license key validation, implement query to check for valid license keys, and improve UI feedback during license key checks.

This commit is contained in:
Mauricio Siu
2026-01-29 07:58:50 -06:00
parent 346216fc71
commit 2b52332e43
2 changed files with 170 additions and 143 deletions

View File

@@ -126,6 +126,23 @@ export const licenseKeyRouter = createTRPCRouter({
licenseKey: currentUser.licenseKey ?? "",
};
}),
haveValidLicenseKey: adminProcedure.query(async ({ ctx }) => {
const currentUserId = ctx.user.id;
const currentUser = await db.query.user.findFirst({
where: eq(user.id, currentUserId),
});
if (!currentUser?.enableEnterpriseFeatures) {
return false;
}
if (!currentUser.licenseKey) {
return false;
}
try {
return await validateLicenseKey(currentUser.licenseKey ?? "");
} catch (error) {
return false;
}
}),
updateEnterpriseSettings: adminProcedure
.input(