Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/profile menu #27

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@zenika:registry=https://europe-west9-npm.pkg.dev/thezaurus/zenika-internal/
//europe-west9-npm.pkg.dev/thezaurus/zenika-internal/:always-auth=true


5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next

## Getting Started

This project uses the [zenika-internal-ui](https://github.com/Zenika/internal-ui) web components. This is deployed to a private npm registry hosted on GCP
in the thezaurus project. To install the dependencies you first need to download and log in to the [google cloud cli](https://cloud.google.com/sdk/docs/install).

Once this is done you can run `pnpm install` which should authenticate you against the registry and install the required packages.

First, run the development server:

```bash
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
"start": "NODE_OPTIONS='-r dotenv/config -r @newrelic/next' next start",
"lint": "next lint",
"docker-build": "docker build . -t europe-west1-docker.pkg.dev/thezaurus/thezaurus/thezaurus",
"gcp-push": "gcloud builds submit --tag europe-west1-docker.pkg.dev/thezaurus/thezaurus/thezaurus --project thezaurus"
"gcp-push": "gcloud builds submit --tag europe-west1-docker.pkg.dev/thezaurus/thezaurus/thezaurus --project thezaurus",
"setup-registry": "npx google-artifactregistry-auth --repo-config=./.npmrc --credential-config=$HOME/.npmrc",
"preinstall": "npm run setup-registry"
},
"dependencies": {
"@auth0/nextjs-auth0": "^2.6.2",
"@newrelic/next": "^0.5.2",
"@zenika/internal-ui-components": "^0.0.3",
"@zenika/internal-ui-components-react": "^1.0.4",
"autoprefixer": "10.4.14",
"dotenv": "^16.3.1",
"eslint": "8.38.0",
Expand Down
24 changes: 24 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/elements/Footer/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function () {
export default function Footer() {
return (
<footer className="text-xs text-center py-2 border-t">
<p>
Expand Down
30 changes: 21 additions & 9 deletions src/components/elements/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import Image from "next/image";
import Head from "next/head";
import Link from "next/link";
import IconLogout from "@/components/icons/Logout";
import { Nunito } from "next/font/google";
const nunito = Nunito({ subsets: ["latin"] });
import { ProfileMenu, ProfileLink } from "@zenika/internal-ui-components-react";

export default function () {
export default function Header({ user }) {
return (
<>
<Head>
<link rel="icon" type="image/svg+xml" href="/zenika.svg" />
<title>TheZaurus</title>
</Head>

<header className="py-1 grid grid-cols-[1fr_repeat(1,auto)_1fr] items-center">
<header className="py-1 grid grid-cols-[1fr_repeat(1,auto)_1fr] items-center mx-20">
<div className="col-start-2">
<h1 className={`text-4xl ${nunito.className} flex justify-center`}>
<span>The</span>
Expand All @@ -24,12 +23,25 @@ export default function () {
Librairie des médias disponibles
</p>
</div>
<Link
className="button connexion rounded-lg ml-auto p-1"
href="/api/auth/logout"
<div
style={{ maxHeight: "100%" }}
className="inline-grid justify-items-end z-10"
>
<IconLogout width={30} />
</Link>
<ProfileMenu
name={`${user.given_name} ${user.family_name}`}
agency="Zenika"
lastLoginDate={`${new Date(user.updated_at).toLocaleDateString(
"en-GB",
)}`}
image={user.picture}
>
<ProfileLink
icon="logout"
text="Logout"
href="/api/auth/logout"
></ProfileLink>
</ProfileMenu>
Comment on lines +30 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this component work in an open sourced thezaurus ?
Is the @zenika/internal-ui-components-react open-sourceable too ? 🤔

</div>
</header>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/TalkFooter/TalkFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from "./TalkFooter.module.css";
const nunito = Nunito({ subsets: ["latin"] });
const openSans = Open_Sans({ subsets: ["latin"] });

export default function ({ talk }) {
export default function TalkFooter({ talk }) {
return (
<footer
className={`${styles.card__footer} justify-between flex gap-8 ${openSans.className}`}
Expand Down
11 changes: 0 additions & 11 deletions src/components/icons/Logout.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/icons/PadLock.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function ({ width }) {
export default function PadLock({ width }) {
return (
<svg
width={width}
Expand Down
8 changes: 5 additions & 3 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@ import RedistributionNotice from "@/components/elements/RedistributionNotice/Red
import Header from "@/components/elements/Header/Header";
import Footer from "@/components/elements/Footer/Footer";
import { useRef } from "react";
import useLocalStorageOnce from "@/hooks/useLocalStorageOnce";
import { defineCustomElements } from "@zenika/internal-ui-components-react";
import "@zenika/internal-ui-components/dist/zenika-internal-ui/zenika-internal-ui.css";

const opensans = Open_Sans({ subsets: ["latin"] });

defineCustomElements();
export default function Index() {
const { user, error, isLoading } = useUser();
const dialog = useRef();

if (isLoading) return <div>Loading...</div>;
if (error) return <div>{error.message}</div>;
if (user) {
console.log(user);
return (
<>
<main
className={`${opensans.className} flex flex-col h-full px-2 h-auto`}
>
<RedistributionNotice dialogRef={dialog} />
<Header />
<Header user={user} />

<Talks />

<Footer />
</main>
</>
Expand Down