mirror of
https://github.com/BreizhHardware/Site-comptage-heure.git
synced 2026-01-18 16:17:28 +01:00
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -2,7 +2,7 @@ name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches: [main, dev]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:22-alpine
|
||||
FROM node:25-alpine
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
COPY pnpm-lock.yaml ./
|
||||
|
||||
@@ -110,7 +110,10 @@ export default function AdminPage() {
|
||||
}, [session, status, router]);
|
||||
|
||||
useEffect(() => {
|
||||
if (session?.user?.role === 'SUPER_ADMIN') {
|
||||
if (
|
||||
session?.user?.role === 'SUPER_ADMIN' ||
|
||||
session?.user?.role === 'ADMIN'
|
||||
) {
|
||||
fetchUsers();
|
||||
}
|
||||
}, [session]);
|
||||
@@ -508,37 +511,45 @@ export default function AdminPage() {
|
||||
<TableCell>{userMap[userId]?.name}</TableCell>
|
||||
<TableCell>{formatHours(total)}</TableCell>
|
||||
<TableCell>
|
||||
{userMap[userId]?.role === 'SUPER_ADMIN' ? (
|
||||
'Super Admin'
|
||||
{isSuperAdmin ? (
|
||||
userMap[userId]?.role === 'SUPER_ADMIN' ? (
|
||||
'Super Admin'
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setSelectedUser({
|
||||
id: userId,
|
||||
name: userMap[userId]?.name,
|
||||
});
|
||||
setForceDelete(false);
|
||||
setDialogOpen(true);
|
||||
}}
|
||||
variant="destructive"
|
||||
className="mr-2"
|
||||
>
|
||||
Supprimer
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setSelectedUserForReset({
|
||||
id: userId,
|
||||
name: userMap[userId]?.name,
|
||||
});
|
||||
setResetPasswordDialog(true);
|
||||
}}
|
||||
variant="outline"
|
||||
>
|
||||
Réinitialiser le mot de passe
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
) : userMap[userId]?.role === 'SUPER_ADMIN' ? (
|
||||
'Gestionnaire'
|
||||
) : userMap[userId]?.role === 'ADMIN' ? (
|
||||
'Bureau'
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setSelectedUser({
|
||||
id: userId,
|
||||
name: userMap[userId]?.name,
|
||||
});
|
||||
setForceDelete(false);
|
||||
setDialogOpen(true);
|
||||
}}
|
||||
variant="destructive"
|
||||
className="mr-2"
|
||||
>
|
||||
Supprimer
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setSelectedUserForReset({
|
||||
id: userId,
|
||||
name: userMap[userId]?.name,
|
||||
});
|
||||
setResetPasswordDialog(true);
|
||||
}}
|
||||
variant="outline"
|
||||
>
|
||||
Réinitialiser le mot de passe
|
||||
</Button>
|
||||
</>
|
||||
'Membre'
|
||||
)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
@@ -7,7 +7,10 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session || session.user.role !== 'SUPER_ADMIN') {
|
||||
if (
|
||||
!session ||
|
||||
(session.user.role !== 'ADMIN' && session.user.role !== 'SUPER_ADMIN')
|
||||
) {
|
||||
return NextResponse.json({ error: 'Accès refusé' }, { status: 403 });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
describe('Login', () => {
|
||||
it('should login successfully', () => {
|
||||
cy.visit('/login')
|
||||
cy.get('input[id="email"]').type('test@example.com')
|
||||
cy.get('input[id="password"]').type('password')
|
||||
cy.get('button[type="submit"]').click()
|
||||
cy.url().should('include', '/dashboard')
|
||||
})
|
||||
})
|
||||
cy.visit('/login');
|
||||
cy.get('input[id="email"]').type('test@example.com');
|
||||
cy.get('input[id="password"]').type('password');
|
||||
cy.get('button[type="submit"]').click();
|
||||
cy.url().should('include', '/dashboard');
|
||||
});
|
||||
});
|
||||
|
||||
16
package.json
16
package.json
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
"build": "next build --webpack",
|
||||
"start": "next start",
|
||||
"format": "prettier --write .",
|
||||
"cypress:open": "cypress open",
|
||||
@@ -29,7 +29,7 @@
|
||||
"exceljs": "^4.4.0",
|
||||
"lucide-react": "^0.546.0",
|
||||
"mime-types": "^3.0.1",
|
||||
"next": "15.5.6",
|
||||
"next": "16.0.0",
|
||||
"next-auth": "^4.24.11",
|
||||
"next-themes": "^0.4.6",
|
||||
"prisma": "^6.17.1",
|
||||
@@ -45,13 +45,19 @@
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/mime-types": "^3.0.1",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@types/node": "^24",
|
||||
"@types/react": "19.2.2",
|
||||
"@types/react-dom": "19.2.2",
|
||||
"cypress": "^15.5.0",
|
||||
"prettier": "^3.6.2",
|
||||
"tailwindcss": "^4",
|
||||
"tw-animate-css": "^1.4.0",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"@types/react": "19.2.2",
|
||||
"@types/react-dom": "19.2.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3059
pnpm-lock.yaml
generated
3059
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
@@ -22,6 +22,13 @@
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
".next\\dev/types/**/*.ts",
|
||||
".next\\dev/types/**/*.ts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user