generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 11
fix: hide total for now #458
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
Open
slamer59
wants to merge
6
commits into
main
Choose a base branch
from
fix/front/maps-proposal-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f14dff6
fix(front): display comparison table when only one community has data…
slamer59 bb0a970
feat(front): hide Y-axis in MP/Subventions comparison and evolution c…
slamer59 edad995
fix(front): correct number formatting for contract and subvention counts
slamer59 5e4a522
fix: UI desktop for maps
slamer59 26c82a1
fix: hide total for now
slamer59 131e847
fix: hide total for now
slamer59 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,25 +6,27 @@ export async function GET(request: NextRequest) { | |||||
try { | ||||||
const searchParams = request.nextUrl.searchParams; | ||||||
const codes = searchParams.getAll('codes'); | ||||||
const year = searchParams.get('year') || '2024'; | ||||||
|
||||||
if (!codes || codes.length === 0) { | ||||||
return NextResponse.json({ error: 'No commune codes provided' }, { status: 400 }); | ||||||
} | ||||||
|
||||||
const values = [...codes, year]; | ||||||
const placeholders = codes.map((_, index) => `$${index + 1}`).join(','); | ||||||
const query = ` | ||||||
SELECT | ||||||
SELECT | ||||||
c.*, | ||||||
b.subventions_score, | ||||||
b.mp_score | ||||||
FROM collectivites c | ||||||
LEFT JOIN bareme b | ||||||
ON c.siren = b.siren AND b.annee = 2024 | ||||||
ON c.siren = b.siren AND b.annee = $${values.length} | ||||||
WHERE c.code_insee IN (${placeholders}) | ||||||
AND c.type = 'COM' | ||||||
`; | ||||||
|
||||||
const communes = await getQueryFromPool(query, codes); | ||||||
const communes = await getQueryFromPool(query, values); | ||||||
|
||||||
return NextResponse.json({ communes }); | ||||||
} catch (error) { | ||||||
|
@@ -37,7 +39,7 @@ export async function GET(request: NextRequest) { | |||||
export async function POST(request: NextRequest) { | ||||||
try { | ||||||
const body = await request.json(); | ||||||
const { codes } = body; | ||||||
const { codes, year = 2024 } = body; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if (!codes || !Array.isArray(codes) || codes.length === 0) { | ||||||
return NextResponse.json( | ||||||
|
@@ -48,20 +50,21 @@ export async function POST(request: NextRequest) { | |||||
|
||||||
console.log(`Received POST request for ${codes.length} communes`); | ||||||
|
||||||
const values = [...codes, year]; | ||||||
const placeholders = codes.map((_, index) => `$${index + 1}`).join(','); | ||||||
const query = ` | ||||||
SELECT | ||||||
SELECT | ||||||
c.*, | ||||||
b.subventions_score, | ||||||
b.mp_score | ||||||
FROM collectivites c | ||||||
LEFT JOIN bareme b | ||||||
ON c.siren = b.siren AND b.annee = 2024 | ||||||
ON c.siren = b.siren AND b.annee = $${values.length} | ||||||
WHERE c.code_insee IN (${placeholders}) | ||||||
AND c.type = 'COM' | ||||||
`; | ||||||
|
||||||
const communes = await getQueryFromPool(query, codes); | ||||||
const communes = await getQueryFromPool(query, values); | ||||||
|
||||||
return NextResponse.json({ communes }); | ||||||
} catch (error) { | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,25 +6,27 @@ export async function GET(request: NextRequest) { | |||||
try { | ||||||
const searchParams = request.nextUrl.searchParams; | ||||||
const codes = searchParams.getAll('codes'); | ||||||
const year = searchParams.get('year') || '2024'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if (!codes || codes.length === 0) { | ||||||
return NextResponse.json({ error: 'No commune codes provided' }, { status: 400 }); | ||||||
} | ||||||
|
||||||
const values = [...codes, year]; | ||||||
const placeholders = codes.map((_, index) => `$${index + 1}`).join(','); | ||||||
const query = ` | ||||||
SELECT | ||||||
SELECT | ||||||
c.*, | ||||||
b.subventions_score, | ||||||
b.mp_score | ||||||
FROM collectivites c | ||||||
LEFT JOIN bareme b | ||||||
ON c.siren = b.siren AND b.annee = 2024 | ||||||
ON c.siren = b.siren AND b.annee = $${values.length} | ||||||
WHERE c.code_insee IN (${placeholders}) | ||||||
AND c.type = 'DEP' | ||||||
`; | ||||||
|
||||||
const departements = await getQueryFromPool(query, codes); | ||||||
const departements = await getQueryFromPool(query, values); | ||||||
return NextResponse.json({ departements }); | ||||||
} catch (error) { | ||||||
console.error('Database error:', error); | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,24 +6,27 @@ export async function GET(request: NextRequest) { | |||||
try { | ||||||
const searchParams = request.nextUrl.searchParams; | ||||||
const codes = searchParams.getAll('codes'); | ||||||
const year = searchParams.get('year') || '2024'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if (!codes || codes.length === 0) { | ||||||
return NextResponse.json({ error: 'No region codes provided' }, { status: 400 }); | ||||||
} | ||||||
|
||||||
const values = [...codes, year]; | ||||||
const placeholders = codes.map((_, index) => `$${index + 1}`).join(','); | ||||||
const query = ` | ||||||
SELECT | ||||||
SELECT | ||||||
c.*, | ||||||
b.subventions_score, | ||||||
b.mp_score | ||||||
FROM collectivites c | ||||||
LEFT JOIN bareme b | ||||||
ON c.siren = b.siren AND b.annee = 2024 | ||||||
ON c.siren = b.siren AND b.annee = $${values.length} | ||||||
WHERE c.code_insee_region IN (${placeholders}) | ||||||
AND c.type = 'REG' | ||||||
`; | ||||||
|
||||||
const regions = await getQueryFromPool(query, codes); | ||||||
const regions = await getQueryFromPool(query, values); | ||||||
return NextResponse.json({ regions }); | ||||||
} catch (error) { | ||||||
console.error('Database error:', error); | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use client'; | ||
|
||
export type AdminLevel = 'regions' | 'departements' | 'communes'; | ||
|
||
interface AdminLevelControlProps { | ||
selectedLevel: AdminLevel; | ||
onSelectLevel: (level: AdminLevel) => void; | ||
} | ||
|
||
const levels: { value: AdminLevel; label: string }[] = [ | ||
{ value: 'regions', label: 'Régions' }, | ||
{ value: 'departements', label: 'Départements' }, | ||
{ value: 'communes', label: 'Communes' }, | ||
]; | ||
|
||
export default function AdminLevelControl({ | ||
selectedLevel, | ||
onSelectLevel, | ||
}: AdminLevelControlProps) { | ||
return ( | ||
<div className='mb-4 mb-8 lg:mb-8'> | ||
<div className='mb-2 mb-4 flex items-center lg:mb-4'> | ||
<span className='mr-2 flex h-7 w-7 items-center justify-center rounded-full bg-primary font-kanit-bold text-sm font-bold text-white'> | ||
5 | ||
</span> | ||
<h4 className='text-sm text-primary lg:text-base'>Niveau d'affichage</h4> | ||
</div> | ||
|
||
{/* Three buttons for level selection */} | ||
<div className='flex flex-col gap-2'> | ||
{levels.map((level) => ( | ||
<button | ||
key={level.value} | ||
type='button' | ||
onClick={() => onSelectLevel(level.value)} | ||
className={`rounded-tl-br-lg border border-black px-4 py-2 font-kanit-bold text-sm transition ${ | ||
selectedLevel === level.value ? 'bg-[#062aad] text-white' : 'bg-white text-[#062aad]' | ||
}`} | ||
> | ||
{level.label} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Les derniers scores de transparence ont été calculés sur 2023 et pas 2024. C'est pour ça qu'on a que des E sur les régions et départements (ce qui n'est pas le cas en 2023 même si ça reste pas élevé...)