diff --git a/api/app/graphql/mutations/create_question.rb b/api/app/graphql/mutations/create_question.rb index 91965b96..2d13b306 100644 --- a/api/app/graphql/mutations/create_question.rb +++ b/api/app/graphql/mutations/create_question.rb @@ -4,7 +4,7 @@ module Mutations class CreateQuestion < Mutations::BaseMutation class CreateQuestionInput < Types::BaseInputObject argument :body, String, required: true - argument :tag_ids, [ID], required: true + argument :tag_ids, [ID], required: false def prepare to_h diff --git a/api/config/credentials.yml.enc b/api/config/credentials.yml.enc index cbd20ba5..0dca3114 100644 --- a/api/config/credentials.yml.enc +++ b/api/config/credentials.yml.enc @@ -1 +1 @@ -TWWkF7e+LzqcrrttF7VdMWVoYMJfoe6hOYoi3Cr29Wto4gtgAmcYIUNFOkd4ERbnezlHCGfTzHOgGzmAKpuMAhYpmYUQmr6VwVjwElOlMQfkviR68ZnCvB8Qn627piM2elNF0Zh77XegD10G75WINfgV6J2QBkAGAC2n4j1z5oW+YiKvzY7X8YAYPTOvy6UsfeWgbfeZppSSTWZ96Bm3TenUsWrHWTmPSQy9Acc2ESkWn1jwVUtMow1pflMV8reXPQ9E7Ka9wR/Fb89/lEJnaU7NzpCok+QqD0kKzUyQet67ure9Qf0TUJWdcFdGyK+c/r6Wvubujnj+lZTDjoI/FCIoU6bfSiLwO/zwMiMK/TfrTWupxlrtVgbb+/V5KpZHJRECJsrO6TH0WIIXJUh+CgMbeG2NHzZSMNub--3xEx9GVjYV1rq1bS--Jsp02/gJHo5LhqmkQj1jrQ== \ No newline at end of file +wGpXtNQvWFLteuK79pX1cB5+UIyrZAaXjtFgNwM6qin8lCF1hGZncTKjW4z3nZJveekR8GwHzXIJloGXb3le02jiLSMdTZcw2fqx/Fc7O7HDcERbqOtiCg8sYF8fBW9MDmhsUL5VYTN7SRNIxGzAYpQS3YkUfOR5xMbEIFrhG8uHN/4+B8tmpcbXqmLqCPcCwdLjXM5RrYbYR41i7AA6mu2XP9A5vVv9sROtxK8+D+jO+zWqn1FVm8HsiW0UIJObgKN39iD9fR70CW7hO2ga26rIkgDCxRDrQASx2pljV/PHM9SyxDxirV9FwBGKDILjx3i7xatnDsLtOHbLV6j4KACLTH4Q8WQvWpLOjRYdRJQoAvwhqQBJ1cz7vg4WGpGrDjgvHHkn76ZdDZ/QIAj4x6Ct7JYaF04Khaj+--i5NqeGsOAvoOkm3g--GG70z+7MR5KXPqM8aQ1kFg== \ No newline at end of file diff --git a/api/db/seeds.rb b/api/db/seeds.rb index 9a95b10e..50e892b9 100644 --- a/api/db/seeds.rb +++ b/api/db/seeds.rb @@ -32,16 +32,14 @@ user.build_profile user.save! 20.times do - user.articles.build( + user.questions.build( body: Faker::Lorem.paragraph(sentence_count: 10), - description: Faker::Lorem.sentence, - title: Faker::Lorem.sentence - ) do |article| - article.save! - article.tags << Tag.offset(rand(Tag.count)).first + ) do |question| + question.save! + question.tags << Tag.offset(rand(Tag.count)).first 5.times do User.offset(rand(User.count)).first.comments.create( - article: article, + question: question, body: Faker::Lorem.sentence ) end diff --git a/realworld.code-workspace b/realworld.code-workspace index 6bc1d322..5578dd66 100644 --- a/realworld.code-workspace +++ b/realworld.code-workspace @@ -7,5 +7,8 @@ "path": "./web" } ], - "settings": {} + "settings": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + } } diff --git a/web/.storybook/main.js b/web/.storybook/main.js index 0054b3b0..405d87c7 100644 --- a/web/.storybook/main.js +++ b/web/.storybook/main.js @@ -1,6 +1,7 @@ module.exports = { stories: ['../src/**/*.stories.js'], addons: [ + '@storybook/addon-essentials', '@storybook/addon-actions', '@storybook/addon-links', 'storybook-addon-apollo-client', diff --git a/web/.storybook/preview-head.html b/web/.storybook/preview-head.html index 866f5806..0f9c5ece 100644 --- a/web/.storybook/preview-head.html +++ b/web/.storybook/preview-head.html @@ -3,11 +3,8 @@ rel="stylesheet" type="text/css" > - + + { + event.preventDefault(); + event.stopPropagation(); + + const { name, value } = event.currentTarget; + + setForm({ [name]: value }); + }; + + const handleSubmit = event => { + event.preventDefault(); + createQuestion({ variables: { input: form } }).then(() => + setForm(DEFAULT_FORM) + ); + }; + + return ( +
+
+ +