feat: add auto-lookup and duplicate check for WSDC registration

Enhanced WSDC registration flow with auto-lookup and account validation:

Backend changes:
- Add accountExists flag to WSDC lookup endpoint
- Check database for existing users with WSDC ID
- Fix Prisma binary target for Alpine Linux Docker containers

Frontend changes:
- Auto-lookup WSDC data after entering 4+ digits (500ms debounce)
- Show live preview dropdown with dancer information
- Display warning if account with WSDC ID already exists
- Block registration and suggest login for existing accounts
- Improve UX with real-time validation feedback
- Add CheckCircle, XCircle, AlertCircle icons for visual feedback

This prevents duplicate WSDC ID registrations and provides immediate
feedback to users, improving the registration experience.

Tested with:
- ID 26111 (Vince Yap) - new account allowed
- ID 26997 (Radoslaw) - existing account blocked
This commit is contained in:
Radosław Gierwiało
2025-11-13 16:11:04 +01:00
parent ac64afa851
commit 46224fca79
3 changed files with 137 additions and 49 deletions

View File

@@ -2,7 +2,8 @@
// Database: PostgreSQL 15
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {

View File

@@ -3,6 +3,7 @@
* Provides proxy endpoint for World Swing Dance Council (WSDC) dancer lookup
*/
const { prisma } = require('../utils/db');
const WSDC_API_BASE = 'https://points.worldsdc.com/lookup2020/find';
/**
@@ -61,9 +62,15 @@ exports.lookupDancer = async (req, res) => {
dominateRole: data.dominate_data?.short_dominate_role || null
};
// Check if user with this WSDC ID already exists in our database
const existingUser = await prisma.user.findUnique({
where: { wsdcId: String(data.dancer_wsdcid) }
});
return res.status(200).json({
success: true,
dancer: dancerData
dancer: dancerData,
accountExists: !!existingUser
});
} catch (error) {