mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-22 02:14:41 -05:00
* Initial * Calendar initial * Extract EventCalendar * Events list initial * Winners * SQL fixes * List events by series * Leaderboards * Series leaderboard * Own entry peek * Edit page skeleton * RHF initial test * RHF stuff * Form etc. progress * Fix tournament series description * Fix tabs layout * Fix socials insert * Check for not removing admin * Adding series * TODOs * Allow updating org with no series * FormFieldset * Allow series without events * TextAreaFormfield accepting array syntax * Input form array field * ToggleFormField * SelectFormField * UserSearchFormField * Fetch badgeOptions * Badge editing * Progress * Use native preventScrollReset * Rename func * Fix sticky scroll * Fix translation * i18n errors * handle,meta in edit * Add ref to user search * TODOs * Done
22 lines
492 B
TypeScript
22 lines
492 B
TypeScript
export function valueArrayToDBFormat<T>(arr: Array<{ value?: T }>) {
|
|
const unwrapped = arr
|
|
.map((item) => {
|
|
if (typeof item.value === "string" && item.value === "") {
|
|
return null;
|
|
}
|
|
|
|
return item.value;
|
|
})
|
|
.filter((item) => item !== null && item !== undefined);
|
|
|
|
return unwrapped.length === 0 ? null : unwrapped;
|
|
}
|
|
|
|
export function wrapToValueStringArrayWithDefault(arr?: Array<string> | null) {
|
|
return (
|
|
arr?.map((value) => ({
|
|
value,
|
|
})) ?? [{ value: "" }]
|
|
);
|
|
}
|