Use Boring Avatar to show user avatar

This commit is contained in:
Takeshi Kimata
2024-05-20 23:16:17 +09:00
parent c5ba3b9a00
commit c40a2440ba
20 changed files with 18 additions and 24 deletions

View File

@@ -3,5 +3,5 @@
"editor.formatOnSave": true, "editor.formatOnSave": true,
"prettier.useEditorConfig": false, "prettier.useEditorConfig": false,
"prettier.useTabs": false, "prettier.useTabs": false,
"prettier.configPath": ".prettierrc" "prettier.configPath": "./.prettierrc"
} }

View File

@@ -11,7 +11,7 @@ module.exports = function (sequelize) {
router.post('/signup', async (req, res) => { router.post('/signup', async (req, res) => {
try { try {
const { email, password, username, avatarPath } = req.body; const { email, password, username } = req.body;
const hashedPassword = await bcrypt.hash(password, 10); const hashedPassword = await bcrypt.hash(password, 10);
const userCount = await User.count(); const userCount = await User.count();
@@ -25,7 +25,6 @@ module.exports = function (sequelize) {
password: hashedPassword, password: hashedPassword,
username: username, username: username,
role: initialRole, role: initialRole,
avatarPath: avatarPath,
}); });
const accessToken = jwt.sign({ userId: user.id }, 'your-secret-key', { const accessToken = jwt.sign({ userId: user.id }, 'your-secret-key', {

View File

@@ -55,20 +55,4 @@ const testRunCaseStatus = [
{ uid: 'skipped', color: 'primary', chartColor: '#805aab' }, { uid: 'skipped', color: 'primary', chartColor: '#805aab' },
]; ];
const avatars = [ export { roles, priorities, testTypes, automationStatus, templates, testRunStatus, testRunCaseStatus };
'/avatar/bear.png',
'/avatar/cat.png',
'/avatar/cow.png',
'/avatar/dog.png',
'/avatar/giraffe.png',
'/avatar/koala.png',
'/avatar/lion.png',
'/avatar/owl.png',
'/avatar/panda.png',
'/avatar/penguin.png',
'/avatar/rhinoceros.png',
'/avatar/shark.png',
'/avatar/sloth.png',
];
export { roles, priorities, testTypes, automationStatus, templates, testRunStatus, testRunCaseStatus, avatars };

View File

@@ -16,6 +16,7 @@
"@types/react-dom": "18.2.7", "@types/react-dom": "18.2.7",
"apexcharts": "^3.49.0", "apexcharts": "^3.49.0",
"autoprefixer": "10.4.16", "autoprefixer": "10.4.16",
"boring-avatars": "^1.10.2",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
"eslint": "8.48.0", "eslint": "8.48.0",
@@ -3185,6 +3186,11 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/boring-avatars": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/boring-avatars/-/boring-avatars-1.10.2.tgz",
"integrity": "sha512-uQyvmNeW6loz4Yytj7aDo0IhhuByW/YyOHtqwb3kQ/x48hum22hROA2Wn3qzrLR5JsoZ+FHjPO6z6LrXrWjegg=="
},
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",

View File

@@ -17,6 +17,7 @@
"@types/react-dom": "18.2.7", "@types/react-dom": "18.2.7",
"apexcharts": "^3.49.0", "apexcharts": "^3.49.0",
"autoprefixer": "10.4.16", "autoprefixer": "10.4.16",
"boring-avatars": "^1.10.2",
"clsx": "^2.0.0", "clsx": "^2.0.0",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
"eslint": "8.48.0", "eslint": "8.48.0",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -1,7 +1,8 @@
'use client'; 'use client';
import { useContext } from 'react'; import { useContext } from 'react';
import { Avatar, Card, CardHeader, CardBody, Divider } from '@nextui-org/react'; import { Card, CardHeader, CardBody, Divider } from '@nextui-org/react';
import { TokenContext } from '../TokenProvider'; import { TokenContext } from '../TokenProvider';
import Avatar from 'boring-avatars';
type AccountPageMessages = { type AccountPageMessages = {
yourProjects: string; yourProjects: string;
@@ -20,7 +21,12 @@ export default function AccountPage({ messages, locale }: Props) {
{context.token && context.token.user && ( {context.token && context.token.user && (
<Card className="w-[600px] mt-16 mx-3"> <Card className="w-[600px] mt-16 mx-3">
<CardHeader className="flex gap-6"> <CardHeader className="flex gap-6">
<Avatar isBordered radius="full" className="w-16 h-16 text-large" src={context.token.user.avatarPath} /> <Avatar
size={48}
name={context.token.user.username}
variant="beam"
colors={['#0A0310', '#49007E', '#FF005B', '#FF7D10', '#FFB238']}
/>
<div className="flex flex-col"> <div className="flex flex-col">
<p className="text-2xl font-bold">{context.token.user.username}</p> <p className="text-2xl font-bold">{context.token.user.username}</p>
<p className="text-lg text-default-500">{context.token.user.email}</p> <p className="text-lg text-default-500">{context.token.user.email}</p>

View File

@@ -57,8 +57,6 @@ export default function AuthPage({ isSignup, messages, locale }: Props) {
} }
} }
const initialavatarPath = getRandomAvatarPath();
user.avatarPath = initialavatarPath;
await submit(); await submit();
}; };