Skip to content

Commit

Permalink
fix: exam.examtype instead of exam.type
Browse files Browse the repository at this point in the history
  • Loading branch information
gasp committed Jul 17, 2024
1 parent c2a039a commit 5bceabd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/components/accessories/admin/exams/examForm/ExamForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ExamForm: FC<IExamProps> = ({
const validationSchema = object({
code: string().required(t("common.required")),
description: string().required(t("common.required")),
type: string().required(t("common.required")),
examtype: string().required(t("common.required")),
procedure: number()
.test({
name: "onetwothree",
Expand All @@ -99,8 +99,8 @@ const ExamForm: FC<IExamProps> = ({
enableReinitialize: true,
onSubmit: (values) => {
const formattedValues = formatAllFieldValues(fields, values);
formattedValues.type = examTypeState.data?.find(
(item) => item.code === values.type
formattedValues.examtype = examTypeState.data?.find(
(item) => item.code === values.examtype
);
onSubmit(formattedValues as any);
},
Expand Down Expand Up @@ -154,12 +154,12 @@ const ExamForm: FC<IExamProps> = ({
<div className="row start-sm center-xs">
<div className="examForm__item fullWidth">
<AutocompleteField
fieldName="type"
fieldValue={formik.values.type}
fieldName="examtype"
fieldValue={formik.values.examtype}
label={t("exam.examtype")}
isValid={isValid("type")}
errorText={getErrorText("type")}
onBlur={onBlurCallback("type")}
isValid={isValid("examtype")}
errorText={getErrorText("examtype")}
onBlur={onBlurCallback("examtype")}
options={examTypeStateOptions}
loading={examTypeState.status === "LOADING"}
disabled={isLoading}
Expand Down
2 changes: 1 addition & 1 deletion src/components/accessories/admin/exams/examForm/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getInitialFields: (
operation: ExamDTO | undefined
) => TFields<ExamProps> = (exam) => ({
code: { type: "text", value: exam?.code ?? "" },
type: { type: "text", value: exam?.examtype?.code ?? "" },
examtype: { type: "text", value: exam?.examtype?.code ?? "" },
description: { type: "text", value: exam?.description ?? "" },
procedure: { type: "number", value: exam?.procedure?.toString() ?? "" },
defaultResult: { type: "text", value: exam?.defaultResult ?? "" },
Expand Down
13 changes: 5 additions & 8 deletions src/components/accessories/admin/exams/examsTable/ExamsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ExamsTable = ({ onDelete, onEdit, headerActions }: IOwnProps) => {

const header: Array<ExamProps> = [
"code",
"type",
"examtype",
"description",
"procedure",
"defaultResult",
Expand Down Expand Up @@ -65,14 +65,14 @@ export const ExamsTable = ({ onDelete, onEdit, headerActions }: IOwnProps) => {

const label = {
code: t("exam.code"),
type: t("exam.examtype"),
examtype: t("exam.examtype"),
description: t("exam.description"),
procedure: t("exam.procedure"),
defaultResult: t("exam.defaultResult"),
};
const order: Array<ExamProps> = [
"code",
"type",
"examtype",
"description",
"procedure",
"defaultResult",
Expand All @@ -90,7 +90,7 @@ export const ExamsTable = ({ onDelete, onEdit, headerActions }: IOwnProps) => {
return data.map((item) => {
return {
code: item.code ?? "",
type: item.examtype?.description ?? "",
examtype: item.examtype?.description ?? "",
description: item.description ?? "",
procedure: item.procedure ?? "",
defaultResult: item.defaultResult ?? "",
Expand Down Expand Up @@ -132,10 +132,7 @@ export const ExamsTable = ({ onDelete, onEdit, headerActions }: IOwnProps) => {
onDelete={onDelete}
headerActions={headerActions}
filterColumns={filters}
rawData={(data ?? []).map((exam) => ({
...exam,
type: exam.examtype?.code,
}))}
rawData={data ?? []}
manualFilter={false}
rowKey="code"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/accessories/admin/exams/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type ExamProps =
| "code"
| "type"
| "examtype"
| "description"
| "procedure"
| "defaultResult";

0 comments on commit 5bceabd

Please sign in to comment.