Skip to content

Commit becc12a

Browse files
committed
chore(dev): Add greeting component to admin dashboard
1 parent b2498b4 commit becc12a

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2+
import { default as default_2c1e1c35da30a80d88551f9fcc61be66 } from 'src/payload/components/Greeting'
23

34
export const importMap = {
4-
"payload-authjs/components#SignInWithAuthjsButton": SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
5+
"payload-authjs/components#SignInWithAuthjsButton": SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e,
6+
"/Greeting#default": default_2c1e1c35da30a80d88551f9fcc61be66
57
}

‎packages/dev/src/payload.config.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export default buildConfig({
2626
admin: {
2727
user: Users.slug,
2828
importMap: {
29-
baseDir: path.resolve(dirname),
29+
baseDir: path.resolve(dirname, "payload", "components"),
30+
},
31+
components: {
32+
beforeDashboard: ["/Greeting"],
3033
},
3134
},
3235
collections: [Users, Examples],
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
3+
import { Banner, useAuth } from "@payloadcms/ui";
4+
import { User } from "payload/generated-types";
5+
6+
/**
7+
* Greeting banner that displays the current user
8+
*/
9+
const Greeting = () => {
10+
const { user } = useAuth<User>();
11+
12+
if (!user) return null;
13+
14+
return (
15+
<Banner type="success">
16+
Hi, {user.name} ({user.email})
17+
</Banner>
18+
);
19+
};
20+
21+
export default Greeting;

0 commit comments

Comments
 (0)