
* run `yarn lint --fix`
* Revert "Revert "add linting to ci""
This reverts commit 0bbbbee4be
.
* Fixed some errors
* remove unused code - not sure why this was here?
* assert env var
* more type fixes
* fix typings og gcal callback - needs testing
* rename `md5.ts` to `md5.js`
it is js.
* fix types
* fix types
* fix lint errors
* fix last lint error
Co-authored-by: Alex van Andel <me@alexvanandel.com>
37 lines
800 B
TypeScript
37 lines
800 B
TypeScript
import { useState } from "react";
|
|
import md5 from "../lib/md5";
|
|
|
|
export default function Avatar({
|
|
user,
|
|
className = "",
|
|
fallback,
|
|
imageSrc = "",
|
|
}: {
|
|
user: any;
|
|
className?: string;
|
|
fallback?: JSX.Element;
|
|
imageSrc?: string;
|
|
}) {
|
|
const [gravatarAvailable, setGravatarAvailable] = useState(true);
|
|
|
|
if (imageSrc) {
|
|
return <img src={imageSrc} alt="Avatar" className={className} />;
|
|
}
|
|
|
|
if (user.avatar) {
|
|
return <img src={user.avatar} alt="Avatar" className={className} />;
|
|
}
|
|
|
|
if (gravatarAvailable) {
|
|
return (
|
|
<img
|
|
onError={() => setGravatarAvailable(false)}
|
|
src={`https://www.gravatar.com/avatar/${md5(user.email)}?s=160&d=identicon&r=PG`}
|
|
alt="Avatar"
|
|
className={className}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return fallback || null;
|
|
}
|