Skip to content

Commit

Permalink
Extract some common components from update subscription page
Browse files Browse the repository at this point in the history
I am making a create subscription page and it will use these components
  • Loading branch information
kdeal committed Oct 22, 2024
1 parent 4b6714a commit 2218fcf
Show file tree
Hide file tree
Showing 4 changed files with 569 additions and 526 deletions.
31 changes: 31 additions & 0 deletions frontend/components/DisplayErrors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react";
import PropTypes from "prop-types";

const ErrorMessageShape = PropTypes.shape({
loc: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
),
msg: PropTypes.string.isRequired,
});

function DisplayErrorMessage({ errors }) {
return (
<div className="alert alert-danger mb-2" role="alert">
Error saving subscription.
<ul>
{errors.map((error) => (
<li key={JSON.stringify(error)}>
{error.loc && `${error.loc.join(".")}: `}
{error.msg}
</li>
))}
</ul>
</div>
);
}

DisplayErrorMessage.propTypes = {
errors: PropTypes.arrayOf(ErrorMessageShape).isRequired,
};

export default DisplayErrorMessage;
Loading

0 comments on commit 2218fcf

Please sign in to comment.