-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
467 additions
and
178 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,67 @@ | ||
import { OrganizationMoissoneurType } from "types/moissoneur"; | ||
import { useState } from "react"; | ||
import MoissoneurOrganizationItem from "./moissonneur-organization-item"; | ||
|
||
type MoissoneurOrganizationsProps = { | ||
organizations: OrganizationMoissoneurType[]; | ||
}; | ||
|
||
const MoissoneurOrganizations = ({ organizations }: MoissoneurOrganizationsProps) => { | ||
const getFilteredOrganizations = (showDeleted: boolean): OrganizationMoissoneurType[] => { | ||
if (showDeleted) { | ||
return organizations; | ||
} | ||
return organizations.filter((s) => !s._deleted); | ||
}; | ||
|
||
const [showDeleted, setShowDeleted] = useState<boolean>(false); | ||
const [organizationsFiltered, setOrganizationsFiltered] = useState< | ||
OrganizationMoissoneurType[] | ||
>(getFilteredOrganizations(showDeleted)); | ||
|
||
const toggleShowDelete = () => { | ||
const isShowDeleted = !showDeleted; | ||
setShowDeleted(isShowDeleted); | ||
setOrganizationsFiltered(getFilteredOrganizations(isShowDeleted)); | ||
}; | ||
|
||
return ( | ||
<div className="fr-container fr-py-12v"> | ||
<div className="fr-toggle"> | ||
<input | ||
type="checkbox" | ||
className="fr-toggle__input" | ||
aria-describedby="toggle-source-hint-text" | ||
id="toggle-source" | ||
checked={showDeleted} | ||
onChange={toggleShowDelete} | ||
/> | ||
<label className="fr-toggle__label" htmlFor="toggle-source"> | ||
Voir supprimé | ||
</label> | ||
</div> | ||
<div className="fr-table"> | ||
<table> | ||
<caption>Liste des sources moissonnées</caption> | ||
<thead> | ||
<tr> | ||
<th scope="col">Nom</th> | ||
<th scope="col">Page</th> | ||
<th scope="col">Actif</th> | ||
<th scope="col">Date de mise à jour</th> | ||
<th scope="col" /> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
{organizationsFiltered.map((organization) => ( | ||
<MoissoneurOrganizationItem key={organization._id} {...organization} /> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MoissoneurOrganizations; |
52 changes: 52 additions & 0 deletions
52
components/moissonneur-bal/organizations/moissonneur-organization-item.tsx
This file contains 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,52 @@ | ||
import Link from "next/link"; | ||
|
||
import Button from "@codegouvfr/react-dsfr/Button"; | ||
|
||
import { formatDate } from "@/lib/util/date"; | ||
import Badge from "@codegouvfr/react-dsfr/Badge"; | ||
import { OrganizationMoissoneurType } from "types/moissoneur"; | ||
|
||
const MoissoneurOrganizationItem = ({ | ||
_id, | ||
name, | ||
page, | ||
_deleted, | ||
_updated, | ||
}: OrganizationMoissoneurType) => ( | ||
<tr> | ||
<td className="fr-col fr-my-1v">{name}</td> | ||
<td className="fr-col fr-my-1v"> | ||
<Link href={page} target="_blank" > | ||
<Button>data.gouv</Button> | ||
</Link> | ||
</td> | ||
<td> | ||
{_deleted ? ( | ||
<Badge severity="error" style={{ marginRight: 2, marginBottom: 2 }}> | ||
Supprimé | ||
</Badge> | ||
) : ( | ||
<Badge severity="success" style={{ marginRight: 2, marginBottom: 2 }}> | ||
Actif | ||
</Badge> | ||
)} | ||
</td> | ||
<td className="fr-col fr-my-1v"> | ||
{_updated ? formatDate(_updated) : "inconnu"} | ||
</td> | ||
<td className="fr-col fr-my-1v"> | ||
<Link | ||
passHref | ||
href={{ | ||
pathname: `/moissonneur-bal/organizations/${_id}`, | ||
}} | ||
> | ||
<Button iconId="fr-icon-arrow-right-line" iconPosition="right"> | ||
Consulter | ||
</Button> | ||
</Link> | ||
</td> | ||
</tr> | ||
); | ||
|
||
export default MoissoneurOrganizationItem; |
This file contains 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,67 @@ | ||
import MoissoneurSourceItem from "@/components/moissonneur-bal/sources/moissonneur-source-item"; | ||
import { SourceMoissoneurType } from "types/moissoneur"; | ||
import { useState } from "react"; | ||
|
||
type MoissoneurSourcesProps = { | ||
sources: SourceMoissoneurType[]; | ||
}; | ||
|
||
const MoissoneurSources = ({ sources }: MoissoneurSourcesProps) => { | ||
const getFilteredSource = (showDeleted: boolean): SourceMoissoneurType[] => { | ||
if (showDeleted) { | ||
return sources; | ||
} | ||
return sources.filter((s) => !s._deleted); | ||
}; | ||
|
||
const [showDeleted, setShowDeleted] = useState<boolean>(false); | ||
const [sourcesFiltered, setSourcesFiltered] = useState< | ||
SourceMoissoneurType[] | ||
>(getFilteredSource(showDeleted)); | ||
|
||
const toggleShowDelete = () => { | ||
const isShowDeleted = !showDeleted; | ||
setShowDeleted(isShowDeleted); | ||
setSourcesFiltered(getFilteredSource(isShowDeleted)); | ||
}; | ||
|
||
return ( | ||
<div className="fr-container fr-py-12v"> | ||
<div className="fr-toggle"> | ||
<input | ||
type="checkbox" | ||
className="fr-toggle__input" | ||
aria-describedby="toggle-source-hint-text" | ||
id="toggle-source" | ||
checked={showDeleted} | ||
onChange={toggleShowDelete} | ||
/> | ||
<label className="fr-toggle__label" htmlFor="toggle-source"> | ||
Voir supprimé | ||
</label> | ||
</div> | ||
<div className="fr-table"> | ||
<table> | ||
<caption>Liste des sources moissonnées</caption> | ||
<thead> | ||
<tr> | ||
<th scope="col">Id</th> | ||
<th scope="col">Title</th> | ||
<th scope="col">Actif</th> | ||
<th scope="col">Date de mise à jour</th> | ||
<th scope="col" /> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
{sourcesFiltered.map((source) => ( | ||
<MoissoneurSourceItem key={source._id} {...source} /> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MoissoneurSources; |
This file contains 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
Oops, something went wrong.