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:
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user