Accept buyer phone in grant API and enrich existing users

payment-router now forwards name/phone from the order. Store phone on
create; for existing users fill name (when it is an email placeholder)
and phone (when empty) without overwriting meaningful data. Also stop
dropping the parsed phone column in CSV import.
This commit is contained in:
2026-07-11 19:41:49 +05:00
parent 33c0d3cafd
commit 92fd88964e
2 changed files with 22 additions and 2 deletions
@@ -200,6 +200,7 @@ export async function applyImport(
data: {
name: row.name,
email: row.email,
phone: row.phone || null,
emailVerified: options.autoVerifyEmail,
role: "student",
},
@@ -231,10 +232,16 @@ export async function applyImport(
created++;
} else if (row.status === "update" && row.existingId) {
const existing = await prisma.user.findUnique({
where: { id: row.existingId },
select: { phone: true },
});
await prisma.user.update({
where: { id: row.existingId },
data: {
name: row.name || undefined,
// don't overwrite an already-filled phone
phone: existing?.phone ? undefined : row.phone || undefined,
},
});