MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / buildApplicationUpdatePayload

Function buildApplicationUpdatePayload

utils/application.ts:52–81  ·  view source on GitHub ↗
(body: applicationUpdatePayload)

Source from the content-addressed store, hash-verified

50const SOCIAL_LINK_KEYS = ["phoneNumber", "github", "instagram", "linkedin", "twitter", "peerlist", "behance", "dribbble"] as const;
51
52const buildApplicationUpdatePayload = (body: applicationUpdatePayload): Record<string, string | number | undefined> => {
53 const dataToUpdate: Record<string, string | number | undefined> = {};
54
55 Object.entries(FLAT_FIELD_MAP).forEach(([key, path]) => {
56 const value = body[key as keyof typeof FLAT_FIELD_MAP];
57 if (value != null) {
58 dataToUpdate[path] = value;
59 }
60 });
61
62 if (body.professional && typeof body.professional === "object") {
63 PROFESSIONAL_KEYS.forEach((key) => {
64 const value = body.professional![key];
65 if (value != null) {
66 dataToUpdate[`professional.${key}`] = value;
67 }
68 });
69 }
70
71 if (body.socialLink && typeof body.socialLink === "object") {
72 SOCIAL_LINK_KEYS.forEach((key) => {
73 const value = body.socialLink![key];
74 if (value != null) {
75 dataToUpdate[`socialLink.${key}`] = value;
76 }
77 });
78 }
79
80 return dataToUpdate;
81};
82
83module.exports = { getUserApplicationObject, buildApplicationUpdatePayload }

Callers 1

updateApplicationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected