Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
martinratinaud committed Feb 13, 2025
1 parent cadd216 commit c62c236
Show file tree
Hide file tree
Showing 9 changed files with 453 additions and 233 deletions.
12 changes: 10 additions & 2 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ You are thoughtful, precise, and focus on delivering high-quality, maintainable

<syntax-and-formatting>
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
- Avoid unnecessary comments
- Avoir replaceing `’` by `'` in texts
- Write declarative syntax.
</syntax-and-formatting>

Expand All @@ -47,6 +49,7 @@ You are thoughtful, precise, and focus on delivering high-quality, maintainable

<database-querying-and-data-model-creation>
- Use kysely to query the database.
- import kysely using `import { kdb, sql } from '@/server/db/kysely';`
- For data models, read the "in src/server/db/kysely/database.ts" file.
</database-querying-and-data-model-creation>

Expand All @@ -67,8 +70,13 @@ You are thoughtful, precise, and focus on delivering high-quality, maintainable
</next-15-and-react-19>

<creating-a-component>
- You always use "export default" for main component.
- You always use an object "props" as the first argument of your component
- Prefer the use of property "variant" and size in case it's needed
- Do not use Box as it's getting deprecated
- Do not use Text as it's getting deprecated
- Prefer creating it like src/components/ui/Component.tsx instead of src/components/Component/ui/Component/index.tsx
- If needed, use class-variance-authority like in src/components/ui/Section.tsx
- Always use `const ComponentName = ` and `export default ComponentName` for main component.
- Always use an object "props" as the first argument of your component

Example:

Expand Down
18 changes: 18 additions & 0 deletions prompts/refactor-AutocompleteAddress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Un nouveau AddressAutocoomplete a été créé
Voila les changements à faire


- import AddressAutocomplete from '@/components/addressAutocomplete'; est remplacé par import AddressAutocomplete, { type AddressAutocompleteInputProps } from '@/components/form/dsfr/AddressAutocompleteInput';
- <AddressAutocomplete placeholder="Tapez ici votre adresse" onAddressSelected={handleAddressSelected} /> est remplacé par <AddressAutocomplete nativeInputProps={{ placeholder: 'Tapez ici votre adresse' }} onSelect={handleAddressSelected} />
- la fonction
```
const handleAddressSelected = useCallback(
async (address: string, geoAddress?: SuggestionItem): Promise<void> => {
```
est remplacée par
````
const handleAddressSelected: AddressAutocompleteInputProps['onSelect'] = useCallback(
async (geoAddress?: SuggestionItem): Promise<void> => {
const address = geoAddress?.properties?.label;
```
8 changes: 5 additions & 3 deletions src/components/GenericContent/AvantagesChauffageUrbain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import Text from '@/components/ui/Text';
const AvantagesChauffageUrbain = ({ title }: { title?: string }) => {
return (
<Box className="fr-container">
<Heading as="h2" center>
{title ? title : 'Les avantages du chauffage urbain'}
</Heading>
{title && (
<Heading as="h2" center>
{title}
</Heading>
)}
<Box className="fr-grid-row fr-grid-row--gutters" mt="10w">
<Box display="flex" flexDirection="column" alignItems="center" className="fr-col-12 fr-col-lg-6 fr-col-xl-3">
<Image src="/img/copro_avantages_1.webp" alt="" width={160} height={125} priority className="img-object-contain" />
Expand Down
11 changes: 6 additions & 5 deletions src/components/HeadSliceForm/HeadSliceForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useRouter } from 'next/router';
import React, { useCallback, useEffect, useMemo, useState } from 'react';

import AddressAutocomplete from '@/components/addressAutocomplete';
import { EligibilityFormContact, EligibilityFormMessageConfirmation, type EnergyInputsLabelsType } from '@/components/EligibilityForm';
import { CheckEligibilityFormLabel, SelectEnergy } from '@/components/EligibilityForm/components';
import { energyInputsDefaultLabels } from '@/components/EligibilityForm/EligibilityFormAddress';
import AddressAutocomplete from '@/components/form/dsfr/AddressAutocompleteInput';
import MarkdownWrapper from '@/components/MarkdownWrapper';
import Slice from '@/components/Slice';
import Box from '@/components/ui/Box';
Expand Down Expand Up @@ -167,10 +167,11 @@ const HeadSliceForm = ({
/>
</CheckEligibilityFormLabel>
<AddressAutocomplete
placeholder="Tapez ici votre adresse"
onAddressSelected={(address, suggestionItem) => {
setAddress(address);
setGeoAddress(suggestionItem);
nativeInputProps={{ placeholder: 'Tapez ici votre adresse' }}
onSelect={(geoAddress?: SuggestionItem) => {
const address = geoAddress?.properties?.label;
setAddress(address ?? '');
setGeoAddress(geoAddress);
}}
/>

Expand Down
91 changes: 43 additions & 48 deletions src/components/Partners/Partners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import ButtonsGroup from '@codegouvfr/react-dsfr/ButtonsGroup';
import { useCallback, useEffect, useState } from 'react';

import Box from '@/components/ui/Box';
import Heading from '@/components/ui/Heading';
import Icon from '@/components/ui/Icon';
import Text from '@/components/ui/Text';
import Section, { SectionSubtitle, SectionTitle, type SectionProps } from '@/components/ui/Section';
import { partenaires } from '@/data/partenaires/partnerData';
import { shuffleArray } from '@/utils/array';

import { Arrow, PartnerImage, PartnerImages, PartnerLink } from './Partners.style';

const Partners = () => {
const Partners: React.FC<SectionProps> = (props) => {
const [firstLogo, setFirstLogo] = useState(0);
const [logos, setLogos] = useState(partenaires);

Expand All @@ -31,55 +30,51 @@ const Partners = () => {
}, [setNextLogo]);

return (
<Box py="10w" id="partenaires">
<Box className="fr-container">
<Heading as="h2" center>
Notre réseau de partenaires
</Heading>
<Text textAlign="center" maxWidth="80w" className="fr-m-md-auto">
Plusieurs acteurs soutiennent France Chaleur Urbaine : ils contribuent au développement du service, apportent des données,
utilisent le service ou s’en font le relais.
</Text>
<Section id="partenaires" {...props}>
<SectionTitle>Notre réseau de partenaires</SectionTitle>
<SectionSubtitle>
Plusieurs acteurs soutiennent France Chaleur Urbaine : ils contribuent au développement du service, apportent des données, utilisent
le service ou s’en font le relais.
</SectionSubtitle>

<Box display="flex" alignItems="center" gap="16px" mt="8w">
<Arrow onClick={() => setNextLogo(-1)}>
<Icon name="ri-arrow-left-circle-line" size="lg" />
</Arrow>
<PartnerImages>
{logos.map(({ image, title, link }, index) => (
<PartnerLink show={index >= firstLogo} href={link} target="_blank" rel="noreferrer noopener" key={title}>
<PartnerImage src={image} alt={title} loading="lazy" className="max-w-none" />
</PartnerLink>
))}
</PartnerImages>
<Arrow onClick={() => setNextLogo(1)}>
<Icon name="ri-arrow-right-circle-line" size="lg" />
</Arrow>
</Box>
<Box display="flex" alignItems="center" gap="16px" mt="8w">
<Arrow onClick={() => setNextLogo(-1)}>
<Icon name="ri-arrow-left-circle-line" size="lg" />
</Arrow>
<PartnerImages>
{logos.map(({ image, title, link }, index) => (
<PartnerLink show={index >= firstLogo} href={link} target="_blank" rel="noreferrer noopener" key={title}>
<PartnerImage src={image} alt={title} loading="lazy" className="max-w-none" />
</PartnerLink>
))}
</PartnerImages>
<Arrow onClick={() => setNextLogo(1)}>
<Icon name="ri-arrow-right-circle-line" size="lg" />
</Arrow>
</Box>

<ButtonsGroup
className="fr-mt-8w"
inlineLayoutWhen="sm and up"
alignment="center"
buttons={[
{
children: 'Rejoindre notre réseau',
linkProps: {
href: '/contact',
},
<ButtonsGroup
className="fr-mt-8w"
inlineLayoutWhen="sm and up"
alignment="center"
buttons={[
{
children: 'Rejoindre notre réseau',
linkProps: {
href: '/contact',
},
{
children: 'Notre dossier de présentation',
priority: 'secondary',
linkProps: {
href: '/documentation/dossier-presse.pdf',
target: '_blank',
},
},
{
children: 'Notre dossier de présentation',
priority: 'secondary',
linkProps: {
href: '/documentation/dossier-presse.pdf',
target: '_blank',
},
]}
/>
</Box>
</Box>
},
]}
/>
</Section>
);
};

Expand Down
138 changes: 48 additions & 90 deletions src/components/shared/page/SimplePage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { fr } from '@codegouvfr/react-dsfr';
import { Footer } from '@codegouvfr/react-dsfr/Footer';
import UnstyledMainNavigation, { type MainNavigationProps } from '@codegouvfr/react-dsfr/MainNavigation';
import { signOut, useSession } from 'next-auth/react';
import Image from 'next/image';
import { useRouter } from 'next/router';
import { signOut, useSession } from 'next-auth/react';
import React from 'react';
import styled, { css } from 'styled-components';

Expand Down Expand Up @@ -161,7 +161,53 @@ const publicNavigationMenu: MainNavigationProps.Item[] = [
},
],
},

{
text: 'Professionnels',
menuLinks: [
{
text: 'Nos services pour les professionnels',
linkProps: {
href: '/professionnels',
},
},
{
text: 'Les avantages du chauffage urbain',
linkProps: {
href: '/professionnels#avantages-du-chauffage-urbain',
},
},
{
text: 'Testez une liste d’adresses',
linkProps: {
href: '/professionnels#test-liste',
},
},
{
text: 'Les coûts du chauffage urbain',
linkProps: {
href: '/professionnels#simulateur-aide',
},
},
{
text: 'Le décret tertiaire',
linkProps: {
href: '/professionnels#decrettertiaire',
},
},
{
text: 'Les obligations de raccordement',
linkProps: {
href: '/professionnels#obligations-de-raccordement',
},
},
{
text: 'Simulateur d’émissions de CO2',
linkProps: {
href: '/professionnels#simulateur-co2',
},
},
],
},
{
text: 'Notre service',
menuLinks: [
Expand All @@ -185,94 +231,6 @@ const publicNavigationMenu: MainNavigationProps.Item[] = [
},
],
},
// {
// text: 'Professionnels',
// menuLinks: [
// {
// text: 'Nos services pour les professionnels',
// linkProps: {
// href: '/professionnels',
// },
// },
// {
// text: 'Les avantages du chauffage urbain',
// linkProps: {
// href: '/professionnels#avantages-du-chauffage-urbain',
// },
// },
// {
// text: 'Testez une liste d’adresses',
// linkProps: {
// href: '/professionnels#test-liste',
// },
// },
// {
// text: 'Les coûts du chauffage urbain',
// linkProps: {
// href: '/professionnels#simulateur-aide',
// },
// },
// {
// text: 'Le décret tertiaire',
// linkProps: {
// href: '/professionnels#decrettertiaire',
// },
// },
// {
// text: 'Les obligations de raccordement',
// linkProps: {
// href: '/professionnels#obligations-de-raccordement',
// },
// },
// {
// text: 'Simulateur d’émissions de CO2',
// linkProps: {
// href: '/professionnels#simulateur-co2',
// },
// },
// ],
// },
// {
// text: 'Copropriétaires',
// menuLinks: [
// {
// text: 'Testez votre adresse',
// linkProps: {
// href: '/',
// },
// },
// {
// text: 'Comprendre le chauffage urbain',
// linkProps: {
// href: '/#comprendre-le-chauffage-urbain',
// },
// },
// {
// text: 'Les avantages du chauffage urbain',
// linkProps: {
// href: '/#avantages-du-chauffage-urbain',
// },
// },
// {
// text: 'Les coûts du chauffage urbain',
// linkProps: {
// href: '/#couts-du-chauffage-urbain',
// },
// },
// {
// text: 'Les obligations de raccordement',
// linkProps: {
// href: '/#obligations-de-raccordement',
// },
// },
// {
// text: 'Comment se raccorder ?',
// linkProps: {
// href: '/#comment-se-raccorder',
// },
// },
// ],
// },
];

const authenticatedNavigationMenu: MainNavigationProps.Item[] = [
Expand Down
Loading

0 comments on commit c62c236

Please sign in to comment.