Skip to content

Commit

Permalink
Les admins peuvent mettre à jour les référentiels
Browse files Browse the repository at this point in the history
  • Loading branch information
NerOcrO committed May 6, 2024
1 parent d935d38 commit d2222f2
Show file tree
Hide file tree
Showing 45 changed files with 3,713 additions and 545 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=ERROR

# EvalCarboneSIH
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
REFERENTIELS_URL=http://localhost:18080
EXPOSITION_DONNEES_ENTREES_URL=http://localhost:18081
# Debug de prisma
# DEBUG=*
Expand Down
22 changes: 21 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,25 @@
]
}],
"unused-imports/no-unused-imports": "error"
}
},
"overrides": [
{
"files": ["**/*.test.ts?(x)"],
"extends": [
"plugin:vitest/all"
],
"rules": {
"@typescript-eslint/unbound-method": "off",
"vitest/max-expects": "off",
"vitest/no-conditional-expect": "off",
"vitest/no-hooks": "off",
"vitest/require-hook": "off",
"vitest/prefer-expect-assertions": "off"
}
},
{
"files": ["**/*.test.tsx"],
"extends": ["plugin:testing-library/react"]
}
]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.next
.vscode
coverage
node_modules
tsconfig.tsbuildinfo
.env.local
Expand Down
517 changes: 259 additions & 258 deletions .yarn/releases/yarn-4.1.1.cjs → .yarn/releases/yarn-4.2.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.1.cjs
yarnPath: .yarn/releases/yarn-4.2.1.cjs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM node:20.12.2-alpine
WORKDIR /usr/src/app

ENV YARN_CACHE_FOLDER=/cache/yarn
COPY .yarn/releases/yarn-4.1.1.cjs ./.yarn/releases/yarn-4.1.1.cjs
COPY .yarn/releases/yarn-4.2.1.cjs ./.yarn/releases/yarn-4.2.1.cjs
COPY yarn.lock package.json .yarnrc.yml ./
RUN --mount=type=cache,target=/cache/yarn \
corepack enable && corepack prepare yarn@stable --activate && yarn workspaces focus --all --production
Expand Down
24 changes: 19 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"license": "MIT",
"scripts": {
"amibroken": "yarn dedupe --check && yarn lint:css && yarn typecheck && yarn lint:typescript",
"amibroken": "yarn dedupe --check && yarn lint:css && yarn typecheck && yarn lint:typescript && yarn test",
"build": "yarn prisma:generate && next build",
"deadcode": "knip",
"depcheck": "depcheck",
Expand All @@ -21,14 +21,16 @@
"psql:local": "docker exec -it postgresdb psql -U postgres postgres",
"start": "next start",
"start:db": "docker compose down && docker compose up -d",
"test": "vitest --run",
"test:coverage": "yarn test --coverage",
"typecheck": "tsc"
},
"dependencies": {
"@prisma/client": "^5.12.1",
"@reach/alert": "^0.18.0",
"@reach/dialog": "^0.18.0",
"@reach/tooltip": "^0.18.0",
"@types/node": "^20.12.7",
"@types/node": "^20.12.8",
"@types/react": "^18.3.1",
"chart.js": "^4.4.2",
"next": "^14.1.3",
Expand All @@ -40,25 +42,37 @@
"typescript": "^5.4.5"
},
"devDependencies": {
"@types/react-dom": "^18.2.22",
"@testing-library/react": "^15.0.6",
"@testing-library/user-event": "^14.5.2",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-istanbul": "^1.5.3",
"depcheck": "^1.4.7",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.3",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-testing-library": "^6.2.2",
"eslint-plugin-unused-imports": "^3.1.0",
"eslint-plugin-vitest": "0.4.1",
"husky": "^9.0.11",
"jsdom": "^24.0.0",
"knip": "^5.9.4",
"stylelint": "^16.2.1",
"stylelint-config-standard": "^36.0.0",
"stylelint-order": "^6.0.4"
"stylelint-order": "^6.0.4",
"vitest": "^1.6.0",
"vitest-dom": "^0.1.1"
},
"engines": {
"node": "20.12.2"
},
"packageManager": "yarn@4.1.1",
"packageManager": "yarn@4.2.1",
"prisma": {
"schema": "src/schema.prisma"
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/(connecte)/creer-un-inventaire/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { ReactElement } from 'react'

import { getProfileAtih } from '../../../authentification'
import { getProfilAtih } from '../../../authentification'
import Breadcrumb from '../../../components/commun/Breadcrumb'
import CreerUnInventaire from '../../../components/CreerUnInventaire/CreerUnInventaire'

Expand All @@ -12,16 +12,16 @@ export const metadata: Metadata = {
}

export default async function Page(): Promise<ReactElement> {
const profile = await getProfileAtih()
const profil = await getProfilAtih()

if (profile.isAdmin) {
if (profil.isAdmin) {
notFound()
}

return (
<>
<Breadcrumb label={title} />
<CreerUnInventaire nomEtablissement={profile.nomEtablissement} />
<CreerUnInventaire nomEtablissement={profil.nomEtablissement} />
</>
)
}
6 changes: 3 additions & 3 deletions src/app/(connecte)/indicateurs-cles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { ReactElement } from 'react'

import { getProfileAtih } from '../../../authentification'
import { getProfilAtih } from '../../../authentification'
import Breadcrumb from '../../../components/commun/Breadcrumb'
import IndicateursCles from '../../../components/IndicateursCles/IndicateursCles'
import { recupererLesIndicateursImpactsEquipementsRepository, recupererLesIndicateursImpactsEquipementsSommesRepository } from '../../../gateways/indicateursRepository'
Expand All @@ -26,9 +26,9 @@ export default async function Page({ searchParams }: PageProps): Promise<ReactEl
notFound()
}

const profile = await getProfileAtih()
const profil = await getProfilAtih()

if (!profile.isAdmin && profile.nomEtablissement !== searchParams.nomEtablissement) {
if (!profil.isAdmin && profil.nomEtablissement !== searchParams.nomEtablissement) {
notFound()
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/(connecte)/inventaire/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { ReactElement } from 'react'

import { getProfileAtih } from '../../../authentification'
import { getProfilAtih } from '../../../authentification'
import Breadcrumb from '../../../components/commun/Breadcrumb'
import Inventaire from '../../../components/Inventaire/Inventaire'
import { recupererLesModelesRepository } from '../../../gateways/modelesRepository'
Expand All @@ -28,9 +28,9 @@ export default async function Page({ searchParams }: PageProps): Promise<ReactEl
notFound()
}

const profile = await getProfileAtih()
const profil = await getProfilAtih()

if (!profile.isAdmin && profile.nomEtablissement !== searchParams.nomEtablissement) {
if (!profil.isAdmin && profil.nomEtablissement !== searchParams.nomEtablissement) {
notFound()
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/(connecte)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PropsWithChildren, ReactElement } from 'react'

import { getProfileAtih } from '../../authentification'
import { getProfilAtih } from '../../authentification'
import AccesRapide from '../../components/commun/AccesRapide'
import EnTete from '../../components/commun/EnTete'
import PiedDePage from '../../components/commun/PiedDePage'

export default async function Layout({ children }: PropsWithChildren): Promise<ReactElement> {
const session = await getProfileAtih()
const session = await getProfilAtih()

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions src/app/(connecte)/liste-equipements/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { ReactElement } from 'react'

import { getProfileAtih } from '../../../authentification'
import { getProfilAtih } from '../../../authentification'
import Breadcrumb from '../../../components/commun/Breadcrumb'
import ListeEquipements from '../../../components/ListeEquipements/ListeEquipements'
import { recupererLesModelesRepository } from '../../../gateways/modelesRepository'
Expand All @@ -26,9 +26,9 @@ export default async function Page({ searchParams }: PageProps): Promise<ReactEl
notFound()
}

const profile = await getProfileAtih()
const profil = await getProfilAtih()

if (!profile.isAdmin && profile.nomEtablissement !== searchParams.nomEtablissement) {
if (!profil.isAdmin && profil.nomEtablissement !== searchParams.nomEtablissement) {
notFound()
}

Expand Down
23 changes: 23 additions & 0 deletions src/app/(connecte)/modifier-un-referentiel/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { ReactElement } from 'react'

import { getProfilAtih } from '../../../authentification'
import ModifierUnReferentiel from '../../../components/ModifierUnReferentiel/ModifierUnReferentiel'

const title = 'Modifier un référentiel'
export const metadata: Metadata = {
title,
}

export default async function PageModifierUnReferentiel(): Promise<ReactElement> {
const profil = await getProfilAtih()

if (!profil.isAdmin) {
notFound()
}

return (
<ModifierUnReferentiel />
)
}
10 changes: 5 additions & 5 deletions src/app/(connecte)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metadata } from 'next'
import { ReactElement } from 'react'

import { getProfileAtih } from '../../authentification'
import { getProfilAtih } from '../../authentification'
import InventairesLayout from '../../components/Inventaires/InventairesLayout'
import { recupererLesInventairesRepository } from '../../gateways/inventairesRepository'
import { inventairesPresenter } from '../../presenters/inventairesPresenter'
Expand All @@ -10,14 +10,14 @@ export const metadata: Metadata = {
title: 'Accueil',
}

export default async function Page(): Promise<ReactElement> {
const profile = await getProfileAtih()
export default async function PageInventaires(): Promise<ReactElement> {
const profil = await getProfilAtih()

const inventairesModel = await recupererLesInventairesRepository(profile.nomEtablissement, profile.isAdmin)
const inventairesModel = await recupererLesInventairesRepository(profil.nomEtablissement)

return (
<InventairesLayout
presenter={inventairesPresenter(inventairesModel, profile)}
presenter={inventairesPresenter(inventairesModel, profil)}
/>
)
}
2 changes: 1 addition & 1 deletion src/app/(deconnecte)/connexion/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const metadata: Metadata = {
title: 'Se connecter à EvalCarboneSIH',
}

export default async function Page(): Promise<ReactElement> {
export default async function PageConnexion(): Promise<ReactElement> {
await isConnected()

const providers = await getProviders()
Expand Down
4 changes: 2 additions & 2 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from 'next'
import Link from 'next/link'
import { ReactElement } from 'react'

import { getProfileAtih } from '../authentification'
import { getProfilAtih } from '../authentification'
import AccesRapide from '../components/commun/AccesRapide'
import EnTete from '../components/commun/EnTete'
import PiedDePage from '../components/commun/PiedDePage'
Expand All @@ -12,7 +12,7 @@ export const metadata: Metadata = {
}

export default async function NotFound(): Promise<ReactElement> {
const session = await getProfileAtih()
const session = await getProfilAtih()

return (
<>
Expand Down
Loading

0 comments on commit d2222f2

Please sign in to comment.