@c-rex/components 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@c-rex/components",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "files": [
5
5
  "src"
6
6
  ],
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
7
10
  "sideEffects": false,
8
11
  "exports": {
9
12
  "./autocomplete": {
@@ -27,8 +30,8 @@
27
30
  "import": "./src/empty.tsx"
28
31
  },
29
32
  "./navbar": {
30
- "types": "./src/navbar.tsx",
31
- "import": "./src/navbar.tsx"
33
+ "types": "./src/navbar/navbar.tsx",
34
+ "import": "./src/navbar/navbar.tsx"
32
35
  },
33
36
  "./providers/search-state-wrapper": {
34
37
  "types": "./src/providers/search-state-wrapper.tsx",
@@ -85,6 +88,7 @@
85
88
  "@c-rex/ui": "*",
86
89
  "@c-rex/utils": "*",
87
90
  "@c-rex/config": "*",
91
+ "@c-rex/constants": "*",
88
92
  "next": "^14",
89
93
  "react": "^18",
90
94
  "react-dom": "^18",
@@ -1,15 +1,22 @@
1
- import { FC } from "react";
2
-
1
+ import React, { FC } from "react";
3
2
  import Link from "next/link";
4
- import { Button } from "@c-rex/ui/button";
5
3
  import Image from "next/image";
4
+ import { SingOut, SingInBtn } from "./sing-in-out-btns";
5
+ import { getServerSession } from "next-auth";
6
+ import { getFromMemory } from "@c-rex/utils";
7
+ import { SDK_CONFIG_KEY } from "@c-rex/constants";
8
+ import { ConfigInterface } from "@c-rex/interfaces";
9
+
6
10
 
7
11
  interface NavBarProps {
8
12
  scroll?: boolean;
9
13
  large?: boolean;
10
14
  }
11
15
 
12
- export const NavBar: FC<NavBarProps> = () => {
16
+ export const NavBar: FC<NavBarProps> = async () => {
17
+ const session = await getServerSession()
18
+ const configs: ConfigInterface = await getFromMemory(SDK_CONFIG_KEY)
19
+
13
20
  return (
14
21
  <header className="sticky top-0 z-40 flex w-full bg-background/60 backdrop-blur-xl transition-all bg-transparent border-b justify-center py-4">
15
22
  <div className="container flex justify-between">
@@ -50,16 +57,18 @@ export const NavBar: FC<NavBarProps> = () => {
50
57
  </nav>
51
58
  </div>
52
59
 
53
- <div className="flex items-center space-x-3">
54
- <Button
55
- className="hidden gap-2 px-5 md:flex"
56
- variant="default"
57
- size="sm"
58
- rounded="full"
59
- >
60
- <span>Sign In</span>
61
- </Button>
62
- </div>
60
+ {configs.OIDC.user.enabled && (
61
+ <div className="flex items-center space-x-3">
62
+ {session ? (
63
+ <>
64
+ <span>Welcome, {session.user?.name}</span>
65
+ <SingOut />
66
+ </>
67
+ ) : (
68
+ <SingInBtn />
69
+ )}
70
+ </div>
71
+ )}
63
72
  </div>
64
73
  </header>
65
74
  );
@@ -0,0 +1,29 @@
1
+ "use client"
2
+
3
+ import React from "react";
4
+ import { signOut, signIn } from "next-auth/react";
5
+ import { Button } from "@c-rex/ui/button";
6
+
7
+ export const SingInBtn = () => (
8
+ <Button
9
+ className="hidden gap-2 px-5 md:flex"
10
+ variant="default"
11
+ size="sm"
12
+ rounded="full"
13
+ onClick={() => signIn("crex", { callbackUrl: "/" })}
14
+ >
15
+ <span>Sign In</span>
16
+ </Button>
17
+ );
18
+
19
+ export const SingOut = () => (
20
+ <Button
21
+ className="hidden gap-2 px-5 md:flex"
22
+ variant="default"
23
+ size="sm"
24
+ rounded="full"
25
+ onClick={() => signOut()}
26
+ >
27
+ <span>Sign out</span>
28
+ </Button>
29
+ );
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { NavBar } from '../navbar';
2
+ import { NavBar } from '../navbar/navbar';
3
3
 
4
4
  const meta: Meta = {
5
5
  title: 'Components/NavBar',