diff --git a/targets/frontend/src/components/contributions/answers/Answer.tsx b/targets/frontend/src/components/contributions/answers/Answer.tsx index f40103c68..396c1e323 100644 --- a/targets/frontend/src/components/contributions/answers/Answer.tsx +++ b/targets/frontend/src/components/contributions/answers/Answer.tsx @@ -54,7 +54,7 @@ export const ContributionsAnswer = ({ values: answer, defaultValues: { content: "", - otherAnswer: "ANSWER", + contentType: "ANSWER", status: { status: "TODO", }, @@ -94,7 +94,7 @@ export const ContributionsAnswer = ({ await updateAnswer({ content: data.content, id: answer.id, - otherAnswer: data.otherAnswer, + contentType: data.contentType, status: newStatus, userId: user?.id, urlSp: data.urlSp, @@ -184,13 +184,13 @@ export const ContributionsAnswer = ({ disabled={isNotEditable(answer)} control={control} rules={{ - required: answer && answer.otherAnswer === "ANSWER", + required: answer && answer.contentType === "ANSWER", }} /> {answer && ( diff --git a/targets/frontend/src/components/contributions/answers/answer.mutation.ts b/targets/frontend/src/components/contributions/answers/answer.mutation.ts index bd24ac8e4..9db7d96bf 100644 --- a/targets/frontend/src/components/contributions/answers/answer.mutation.ts +++ b/targets/frontend/src/components/contributions/answers/answer.mutation.ts @@ -10,8 +10,8 @@ import { } from "./answerReferences"; export const contributionAnswerUpdateMutation = ` -mutation contributionAnswerUpdate($id: uuid!, $content: String, $otherAnswer: String, $status: statustype!, $userId: uuid!, $urlSp: String, $kaliReferences: [contribution_answer_kali_references_insert_input!]!, $legiReferences: [contribution_answer_legi_references_insert_input!]!, $otherReferences: [contribution_answer_other_references_insert_input!]!, $cdtnReferences: [contribution_answer_cdtn_references_insert_input!]!) { - update_contribution_answers_by_pk(pk_columns: {id: $id}, _set: {content: $content, other_answer: $otherAnswer, url_sp: $urlSp}) { +mutation contributionAnswerUpdate($id: uuid!, $content: String, $contentType: String, $status: statustype!, $userId: uuid!, $urlSp: String, $kaliReferences: [contribution_answer_kali_references_insert_input!]!, $legiReferences: [contribution_answer_legi_references_insert_input!]!, $otherReferences: [contribution_answer_other_references_insert_input!]!, $cdtnReferences: [contribution_answer_cdtn_references_insert_input!]!) { + update_contribution_answers_by_pk(pk_columns: {id: $id}, _set: {content: $content, content_type: $contentType, url_sp: $urlSp}) { __typename } insert_contribution_answer_statuses_one(object: {status: $status, user_id: $userId, answer_id: $id}) { @@ -48,7 +48,7 @@ mutation contributionAnswerUpdate($id: uuid!, $content: String, $otherAnswer: St export type MutationProps = Pick< Answer, | "id" - | "otherAnswer" + | "contentType" | "urlSp" | "content" | "kaliReferences" diff --git a/targets/frontend/src/components/contributions/answers/answer.query.ts b/targets/frontend/src/components/contributions/answers/answer.query.ts index 719d659c6..265d02100 100644 --- a/targets/frontend/src/components/contributions/answers/answer.query.ts +++ b/targets/frontend/src/components/contributions/answers/answer.query.ts @@ -12,7 +12,7 @@ query contribution_answer($id: uuid) { questionId: question_id agreementId: agreement_id content - otherAnswer: other_answer + contentType: content_type updatedAt: updated_at urlSp: url_sp question { diff --git a/targets/frontend/src/components/contributions/questions/Question.query.ts b/targets/frontend/src/components/contributions/questions/Question.query.ts index f441f3e45..e12834b7b 100644 --- a/targets/frontend/src/components/contributions/questions/Question.query.ts +++ b/targets/frontend/src/components/contributions/questions/Question.query.ts @@ -18,7 +18,7 @@ query SelectQuestion($questionId: uuid) { order_by: {agreement_id: asc} ) { id - otherAnswer: other_answer + contentType: content_type agreement { id name diff --git a/targets/frontend/src/components/contributions/type.ts b/targets/frontend/src/components/contributions/type.ts index 3da256dbf..fba7dfb91 100644 --- a/targets/frontend/src/components/contributions/type.ts +++ b/targets/frontend/src/components/contributions/type.ts @@ -90,13 +90,13 @@ export type CdtnReference = { document: Document; }; -export type OtherAnswer = "ANSWER" | "NOTHING" | "UNKNOWN" | "SP"; +export type ContentType = "ANSWER" | "NOTHING" | "UNKNOWN" | "SP"; export type Answer = { id: string; agreementId: string; questionId: string; - otherAnswer?: OtherAnswer; + contentType?: ContentType; urlSp?: string; agreement: Agreement; statuses: AnswerStatus[]; diff --git a/targets/hasura/metadata/databases/default/tables/contribution_answers.yaml b/targets/hasura/metadata/databases/default/tables/contribution_answers.yaml index 2796a921a..e79c9c874 100644 --- a/targets/hasura/metadata/databases/default/tables/contribution_answers.yaml +++ b/targets/hasura/metadata/databases/default/tables/contribution_answers.yaml @@ -60,7 +60,7 @@ select_permissions: - agreement_id - content - id - - other_answer + - content_type - question_id - updated_at - url_sp @@ -71,7 +71,7 @@ update_permissions: permission: columns: - content - - other_answer + - content_type - url_sp filter: {} check: null diff --git a/targets/hasura/migrations/default/1695651246643_alter_table_contribution_answers_alter_column_other_answer/down.sql b/targets/hasura/migrations/default/1695651246643_alter_table_contribution_answers_alter_column_other_answer/down.sql new file mode 100644 index 000000000..87b92c203 --- /dev/null +++ b/targets/hasura/migrations/default/1695651246643_alter_table_contribution_answers_alter_column_other_answer/down.sql @@ -0,0 +1 @@ +alter table "contribution"."answers" rename column "content_type" to "other_answer"; diff --git a/targets/hasura/migrations/default/1695651246643_alter_table_contribution_answers_alter_column_other_answer/up.sql b/targets/hasura/migrations/default/1695651246643_alter_table_contribution_answers_alter_column_other_answer/up.sql new file mode 100644 index 000000000..86370378f --- /dev/null +++ b/targets/hasura/migrations/default/1695651246643_alter_table_contribution_answers_alter_column_other_answer/up.sql @@ -0,0 +1 @@ +alter table "contribution"."answers" rename column "other_answer" to "content_type";