Skip to content

Commit

Permalink
refactor(evallog): trim 시 undefined 전달 -> optional
Browse files Browse the repository at this point in the history
  • Loading branch information
yoopark committed Oct 12, 2023
1 parent d3eb822 commit 5273bd2
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions app/src/EvalLogSearch/utils/trimEvalLogSearchForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@ import type { EvalLogSearchForm } from '@/EvalLogSearch/components/EvalLogSearch
export const trimEvalLogSearchForm = (
form: EvalLogSearchForm,
): EvalLogSearchForm => {
const { projectName, corrector, corrected } = form;

return {
...form,
projectName: projectName?.trim() ?? undefined,
corrector: corrector?.trim() ?? undefined,
corrected: corrected?.trim() ?? undefined,
};
const { projectName, corrector, corrected, ...rest } = form;

const newForm: EvalLogSearchForm = { ...rest };

const trimmedProjectName = projectName?.trim();
if (projectName) {
newForm.projectName = trimmedProjectName;
}

const trimmedCorrector = corrector?.trim();
if (corrector) {
newForm.corrector = trimmedCorrector;
}

const trimmedCorrected = corrected?.trim();
if (corrected) {
newForm.corrected = trimmedCorrected;
}

return newForm;
};

0 comments on commit 5273bd2

Please sign in to comment.