-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add FollowOrganizationUnitCard and FollowSurveyCard
- Loading branch information
1 parent
5b8c1b0
commit f0e2d2d
Showing
11 changed files
with
269 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Typography } from "@mui/material"; | ||
|
||
export const FollowCampaignPage = () => { | ||
return <Typography>page suivre enquête</Typography>; | ||
}; |
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,5 @@ | ||
import { Typography } from "@mui/material"; | ||
|
||
export const FollowInterviewerPage = () => { | ||
return <Typography>page suivre enquêteur</Typography>; | ||
}; |
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,5 @@ | ||
import { Typography } from "@mui/material"; | ||
|
||
export const FollowOrganizationUnitPage = () => { | ||
return <Typography>page suivre site</Typography>; | ||
}; |
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,30 @@ | ||
import Stack from "@mui/material/Stack"; | ||
import Typography from "@mui/material/Typography"; | ||
import { useIntl } from "react-intl"; | ||
import { SearchField } from "./SearchField"; | ||
import { ChangeEvent } from "react"; | ||
|
||
type Props = { | ||
title: string; | ||
placeholder: string; | ||
onSearch: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void; | ||
}; | ||
|
||
export const FollowCardHeader = ({ title, placeholder, onSearch }: Props) => { | ||
const intl = useIntl(); | ||
|
||
const handleChange = (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => { | ||
onSearch(e); | ||
}; | ||
|
||
return ( | ||
<Stack gap={3}> | ||
<Typography variant="headlineLarge">{intl.formatMessage({ id: title })}</Typography> | ||
<SearchField | ||
onChange={handleChange} | ||
label={intl.formatMessage({ id: "toSearchLabel" })} | ||
placeholder={intl.formatMessage({ id: placeholder })} | ||
/> | ||
</Stack> | ||
); | ||
}; |
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,100 @@ | ||
import { useIntl } from "react-intl"; | ||
import { useDebouncedState } from "../hooks/useDebouncedState"; | ||
import Card from "@mui/material/Card"; | ||
import Stack from "@mui/material/Stack"; | ||
import TableContainer from "@mui/material/TableContainer"; | ||
import Table from "@mui/material/Table"; | ||
import TableHead from "@mui/material/TableHead"; | ||
import { TableBody, TableCell, TableRow } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { Link as RouterLink } from "react-router-dom"; | ||
import { Link } from "./Link"; | ||
import { FollowCardHeader } from "./FollowCardHeader"; | ||
|
||
const OUMock = [ | ||
{ | ||
id: "1", | ||
label: "Paris", | ||
}, | ||
{ | ||
id: "2", | ||
label: "Metz", | ||
}, | ||
{ | ||
id: "3", | ||
|
||
label: "Lille", | ||
}, | ||
{ | ||
id: "4", | ||
|
||
label: "Amiens", | ||
}, | ||
]; | ||
|
||
export const FollowOrganizationUnitCard = () => { | ||
const intl = useIntl(); | ||
const [search, setSearch] = useDebouncedState("", 500); | ||
const [page, setPage] = useState(0); | ||
Check failure on line 38 in src/ui/FollowOrganizationUnitCard.tsx GitHub Actions / test_lint
|
||
|
||
const handleChangePage = (_: React.MouseEvent<HTMLButtonElement> | null, newPage: number) => { | ||
Check failure on line 40 in src/ui/FollowOrganizationUnitCard.tsx GitHub Actions / test_lint
|
||
setPage(newPage); | ||
}; | ||
|
||
const filteredOU = filterOrganizationUnits({ organizationUnits: OUMock, search }); | ||
|
||
return ( | ||
<Card variant="general" sx={{ height: "calc(100vh - 140px)", py: 4, px: 3, overflow: "auto" }}> | ||
<Stack gap={3}> | ||
<FollowCardHeader | ||
title={"followOrganizationUnit"} | ||
onSearch={e => setSearch(e.target.value)} | ||
placeholder="searchOrganizationUnit" | ||
/> | ||
<TableContainer> | ||
<Table aria-label="organization unit list" size="small" sx={{ typography: "bodyMedium" }}> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell sx={{ color: "text.tertiary" }}> | ||
{intl.formatMessage({ id: "chooseOrganizationUnit" })} | ||
</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{filteredOU.map(OU => ( | ||
<TableRow key={OU.id}> | ||
<TableCell sx={{ py: 0.5 }}> | ||
<Link | ||
color="inherit" | ||
component={RouterLink} | ||
underline="none" | ||
to={`/follow/organization-unit/${OU.id}`} | ||
> | ||
{OU.label} | ||
</Link> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
{/* TODO use TableFooter */} | ||
</Table> | ||
</TableContainer> | ||
</Stack> | ||
</Card> | ||
); | ||
}; | ||
|
||
type FilterOUProps = { | ||
organizationUnits: { id: string; label: string }[]; | ||
search?: string; | ||
}; | ||
|
||
const filterOrganizationUnits = ({ organizationUnits, search }: FilterOUProps) => { | ||
if (search) { | ||
organizationUnits = organizationUnits.filter(item => | ||
item.label.toLowerCase().includes(search.toLowerCase()), | ||
); | ||
} | ||
|
||
return organizationUnits; | ||
}; |
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 { useIntl } from "react-intl"; | ||
import Card from "@mui/material/Card"; | ||
import Stack from "@mui/material/Stack"; | ||
import Typography from "@mui/material/Typography"; | ||
import Box from "@mui/material/Box"; | ||
import { Link } from "./Link"; | ||
import { Link as RouterLink } from "react-router-dom"; | ||
|
||
const surveysMock = [ | ||
{ | ||
id: "1", | ||
label: "Logement", | ||
}, | ||
{ | ||
id: "2", | ||
label: "Autonomie", | ||
}, | ||
{ | ||
id: "3", | ||
label: "TIC", | ||
}, | ||
]; | ||
|
||
export const FollowSurveyCard = () => { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<Card variant="general" sx={{ height: "calc(100vh - 140px)", py: 4, px: 3, overflow: "auto" }}> | ||
<Stack gap={3}> | ||
<Typography variant="headlineLarge">{intl.formatMessage({ id: "followSurvey" })}</Typography> | ||
|
||
<Stack gap={1.5} typography={"bodyMedium"}> | ||
<Box color={"text.tertiary"}>{intl.formatMessage({ id: "chooseSurvey" })}</Box> | ||
<Stack gap={0.5}> | ||
{surveysMock.map(survey => ( | ||
<Link | ||
key={survey.id} | ||
color="inherit" | ||
component={RouterLink} | ||
underline="none" | ||
to={`/follow/campaign/${survey.id}`} | ||
> | ||
{survey.label} | ||
</Link> | ||
))} | ||
</Stack> | ||
<Box>{intl.formatMessage({ id: "allSurveys" })}</Box> | ||
</Stack> | ||
</Stack> | ||
</Card> | ||
); | ||
}; |