Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Post Form to React #10408

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

FinnIckler
Copy link
Member

Only a little jQuery deleted sadly.

image

image

TODO: That date picker how long something should be stickied for

@FinnIckler
Copy link
Member Author

Added the Datepicker!

Comment on lines +18 to +24
const [formPost, setFormPost] = useState(post);
const [formTitle, setFormTitle] = useInputState(formPost?.title ?? '');
const [formBody, setFormBody] = useInputState(formPost?.body ?? '');
const [formTags, setFormTags] = useState(formPost?.tags_array ?? []);
const [formIsStickied, setFormIsStickied] = useCheckboxState(formPost?.sticky ?? false);
const [formShowOnHomePage, setFormShowOnHomePage] = useCheckboxState(formPost?.show_on_homepage ?? true);
const [unstickAt, setUnstickAt] = useState(formPost?.unstick_at ?? null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird to have states for both the (form)post, and most of the properties of the post. Besides initializing the other states (which happens initially, so doesn't need formPost to be a state), formPost is only used to check whether we're creating or editing, get the id (if we're editing), and show the url at the end.

It seems like we could get rid of formPost and instead just have 2 more states for the post id and url; then update those 2 states in the onSuccess functions below.

Comment on lines +123 to +136
{ postCreated && (
<Message positive>
Post successfully created. View it
{' '}
<a href={formPost.url}>here</a>
</Message>
)}
{ postUpdated && (
<Message positive>
Post successfully updated. View it
{' '}
<a href={formPost.url}>here</a>
</Message>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you create a post then edit it, won't both messages be visible?

Side note: Formatting (indentation and spacing) seems to be off here, and I've noticed it in other PRs too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants