🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2021-10-13 0:34:14.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2021-10-13 0:34:14.0 +01:00:00
commit
162035b7b543c89c2a40f1a0fd160f9038dca9e6 [patch]
tree
121415ac9545f0bdc24f1d655b80c836dbe23b73
parent
864c1d46af66125b7e91f3fb01d77c8b261dbadf
download
162035b7b543c89c2a40f1a0fd160f9038dca9e6.tar.gz

Fix react errors on no published versions for crate



Diff

 chartered-frontend/src/pages/crate/CrateView.tsx | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/chartered-frontend/src/pages/crate/CrateView.tsx b/chartered-frontend/src/pages/crate/CrateView.tsx
index 7f60f1c..d109b8c 100644
--- a/chartered-frontend/src/pages/crate/CrateView.tsx
+++ a/chartered-frontend/src/pages/crate/CrateView.tsx
@@ -120,7 +120,7 @@
                    </Link>
                    {crate}
                  </h1>
                  <h2 className="text-secondary m-0">{crateVersion.vers}</h2>
                  <h2 className="text-secondary m-0">{crateVersion?.vers}</h2>
                </div>

                <p className="m-0">{crateInfo.description}</p>
@@ -227,14 +227,14 @@
              </div>

              <ul className="list-group list-group-flush mb-2">
                {crateVersion.deps.length === 0 ? (
                {(crateVersion?.deps || []).length === 0 ? (
                  <li className="list-group-item">
                    This crate has no dependencies
                  </li>
                ) : (
                  <></>
                )}
                {crateVersion.deps.map((dep) => (
                {crateVersion?.deps.map((dep) => (
                  <Dependency
                    key={`${dep.name}-${dep.req}`}
                    organisation={organisation}
@@ -315,7 +315,7 @@
  );

  if (error) {
    return <>{error}</>;
    return <div className="card-body">{error}</div>;
  } else if (!response) {
    return (
      <div className="d-flex justify-content-center align-items-center">
@@ -396,6 +396,10 @@
      ["B", "kB", "MB", "GB", "TB"][i]
    );
  };

  if (props.crate.versions.length === 0) {
    return <>There hasn't yet been any versions published for this crate</>;
  }

  return (
    <div>