* flare tag line height * . * dropdown fix + actions bar fix * actions bar on mob * . * css commented out * . * button fix * preload adjustments * tags * Fixed listings modal to make it semantic HTML via <dialog />. * Refactor an a11y fix. * Removed test that is no longer needed. * Added missing global function for test.. * Fixed broken <ListingFiltersCategories /> tests. * Refactor of mobile dropdown for listing categories. * Updated a TODO. * Made the clear query button a crayons Preact button. * padding * Fixed listings modal for accessiblilty. * Removed rspecs that are no longer valid. * We're no longer using the <dialog /> element, at least for now, so CSS changes aren't necessary. * Wasn't supposed to be committed. Co-authored-by: Nick Taylor <nick@dev.to> Co-authored-by: rhymes <rhymes@hey.com> Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
77 lines
2 KiB
JavaScript
77 lines
2 KiB
JavaScript
import { h } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
import { Button } from '@crayons';
|
|
|
|
const MessageModal = ({
|
|
currentUserId,
|
|
message,
|
|
listing,
|
|
onSubmit,
|
|
onChangeDraftingMessage,
|
|
}) => {
|
|
const isCurrentUserOnListing = listing.user_id === currentUserId;
|
|
|
|
return (
|
|
<form
|
|
data-testid="listings-message-modal"
|
|
id="listings-message-form"
|
|
onSubmit={onSubmit}
|
|
>
|
|
<header className="mb-4">
|
|
<h2 className="fs-xl fw-bold lh-tight">Interested?</h2>
|
|
{isCurrentUserOnListing ? (
|
|
<p className="color-base-70">
|
|
This is your active listing. Any member can contact you via this
|
|
form.
|
|
</p>
|
|
) : (
|
|
<p className="color-base-70">Message {` ${listing.author.name} `}</p>
|
|
)}
|
|
</header>
|
|
<textarea
|
|
value={message}
|
|
onChange={onChangeDraftingMessage}
|
|
data-testid="listing-new-message"
|
|
id="new-message"
|
|
className="crayons-textfield mb-0"
|
|
placeholder="Enter your message here..."
|
|
/>
|
|
<p
|
|
className="mb-4 fs-s color-base-60"
|
|
>
|
|
{isCurrentUserOnListing &&
|
|
'Message must be relevant and on-topic with the listing.'}
|
|
All private interactions <b>must</b> abide by the{' '}
|
|
<a href="/code-of-conduct" className="crayons-link crayons-link--brand">
|
|
Code of Conduct
|
|
</a>
|
|
.
|
|
</p>
|
|
<div className="flex">
|
|
<Button
|
|
variant="primary"
|
|
className="mr-2"
|
|
tagName="button"
|
|
type="submit"
|
|
>
|
|
Send
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
);
|
|
};
|
|
|
|
MessageModal.propTypes = {
|
|
currentUserId: PropTypes.number.isRequired,
|
|
message: PropTypes.string.isRequired,
|
|
listing: PropTypes.shape({
|
|
author: PropTypes.shape({
|
|
name: PropTypes.string.isRequired,
|
|
}).isRequired,
|
|
user_id: PropTypes.number.isRequired,
|
|
}).isRequired,
|
|
onSubmit: PropTypes.func.isRequired,
|
|
onChangeDraftingMessage: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default MessageModal;
|