Skip to content

Commit

Permalink
fix(contributions): rename otherAnswer field by contentType (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolineBda authored Sep 26, 2023
1 parent e6cfbc0 commit a590140
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
10 changes: 5 additions & 5 deletions targets/frontend/src/components/contributions/answers/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const ContributionsAnswer = ({
values: answer,
defaultValues: {
content: "",
otherAnswer: "ANSWER",
contentType: "ANSWER",
status: {
status: "TODO",
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -184,13 +184,13 @@ export const ContributionsAnswer = ({
disabled={isNotEditable(answer)}
control={control}
rules={{
required: answer && answer.otherAnswer === "ANSWER",
required: answer && answer.contentType === "ANSWER",
}}
/>
</FormControl>
{answer && (
<FormRadioGroup
name="otherAnswer"
name="contentType"
label="Type de réponse"
control={control}
disabled={isNotEditable(answer)}
Expand All @@ -213,7 +213,7 @@ export const ContributionsAnswer = ({
disabled={isNotEditable(answer)}
control={control}
rules={{
required: answer && answer.otherAnswer === "SP",
required: answer && answer.contentType === "SP",
}}
/>
</FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down Expand Up @@ -48,7 +48,7 @@ mutation contributionAnswerUpdate($id: uuid!, $content: String, $otherAnswer: St
export type MutationProps = Pick<
Answer,
| "id"
| "otherAnswer"
| "contentType"
| "urlSp"
| "content"
| "kaliReferences"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ query SelectQuestion($questionId: uuid) {
order_by: {agreement_id: asc}
) {
id
otherAnswer: other_answer
contentType: content_type
agreement {
id
name
Expand Down
4 changes: 2 additions & 2 deletions targets/frontend/src/components/contributions/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,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[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ select_permissions:
- agreement_id
- content
- id
- other_answer
- content_type
- question_id
- updated_at
- url_sp
Expand All @@ -71,7 +71,7 @@ update_permissions:
permission:
columns:
- content
- other_answer
- content_type
- url_sp
filter: {}
check: null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "contribution"."answers" rename column "content_type" to "other_answer";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "contribution"."answers" rename column "other_answer" to "content_type";

0 comments on commit a590140

Please sign in to comment.