Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "platine-management",
"private": true,
"version": "1.0.6",
"version": "1.0.7",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
3 changes: 0 additions & 3 deletions src/pages/Settings.tsx

This file was deleted.

72 changes: 72 additions & 0 deletions src/pages/SettingsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Box, Divider, Tabs } from "@mui/material";
import { PageTab } from "../ui/PageTab";
import { useState, SyntheticEvent } from "react";
import { SettingsHeader } from "../ui/Settings/SettingsHeader";
import { SettingsHabilitationsCard } from "../ui/Settings/SettingsHabilitationsCard";
import { Breadcrumbs } from "../ui/Breadcrumbs.tsx";

enum Tab {
Habilitations = "Habilitations",
Communications = "Communications",
NewSource = "NewSource",
}

const TabNames = {
[Tab.Habilitations]: "Gestion des habilitations",
[Tab.Communications]: "Communications",
[Tab.NewSource]: "Nouvelle Source",
};

export function SettingsPage() {
const [currentTab, setCurrentTab] = useState(Tab.Habilitations);
const handleChange = (_: SyntheticEvent, newValue: Tab) => {
setCurrentTab(newValue);
};
const breadcrumbs = [
{ href: "/", title: "Accueil" },
{ href: "/settings", title: "Réglages" },
TabNames[currentTab],
];
return (
<>
<SettingsHeader />
<Divider variant="fullWidth" />
<Tabs
value={currentTab}
onChange={handleChange}
sx={{
px: 5,
backgroundColor: "white",
}}
>
{Object.keys(Tab).map(k => (
<PageTab
sx={{
paddingX: 4,
paddingY: 3,
typography: "titleSmall",
letterSpacing: 0.4,
}}
key={k}
value={k}
label={TabNames[k]}
/>
))}
</Tabs>

<Breadcrumbs items={breadcrumbs} />

<Box px={4}>
<SettingsTab tab={currentTab} />
</Box>
</>
);
}

function SettingsTab({ tab }: { tab: Tab }) {
if (tab === Tab.Habilitations) {
return <SettingsHabilitationsCard />;
}

return;
}
4 changes: 2 additions & 2 deletions src/pages/SurveyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ export function SurveyPage() {
<Breadcrumbs items={breadcrumbs} />

<Box px={4}>
<SurveyUnitTab tab={currentTab} survey={survey} onSave={refetch} />
<SurveyTab tab={currentTab} survey={survey} onSave={refetch} />
</Box>
</>
);
}

function SurveyUnitTab({
function SurveyTab({
survey,
onSave,
tab,
Expand Down
4 changes: 2 additions & 2 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Layout } from "./ui/Layout";
import { PageError } from "./ui/PageError";
import { SurveyPage } from "./pages/SurveyPage";
import { ContactPage } from "./pages/ContactPage";
import { Settings } from "./pages/Settings";
import { SettingsPage } from "./pages/SettingsPage.tsx";
import { SearchContacts } from "./pages/Search/SearchContacts.tsx";
import { SearchSurveys } from "./pages/Search/SearchSurveys.tsx";
import { SearchSurveyUnits } from "./pages/Search/SearchSurveyUnits.tsx";
Expand All @@ -32,7 +32,7 @@ export const routes: RouteObject[] = [
},
{ path: "surveys/:id", element: <SurveyPage /> },
{ path: "contacts/:id", element: <ContactPage /> },
{ path: "reglages", element: <Settings /> },
{ path: "settings", element: <SettingsPage /> },
{ path: "", element: <Home /> },
],
},
Expand Down
25 changes: 23 additions & 2 deletions src/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ declare module "@mui/material/Paper" {
disabled: true;
}
}
declare module "@mui/material/Chip" {
interface ChipPropsVariantOverrides {
role: true;
}
}

declare module "@mui/material/Tab" {
interface TabPropsClassesOverrides {
Expand Down Expand Up @@ -382,11 +387,27 @@ export const theme = createTheme({
},
MuiInputLabel: {
styleOverrides: {
sizeSmall: {
...typography.bodyMedium,
root: {
...typography.bodyLarge,
},
},
},
MuiChip: {
variants: [
{
props: { variant: "role" },
style: {
fontWeight: 600,
lineHeight: "18px",
letterSpacing: "0.1px",
fontSize: "14px",
Comment on lines +417 to +420
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essaie d'utiliser une typography déjà existante

textTransform: "capitalize",
backgroundColor: "#EBEBEB",
height: "34px",
},
},
],
},
MuiInputBase: {
styleOverrides: {
root: {
Expand Down
30 changes: 20 additions & 10 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ export type APISchemas = {
/* Format: date-time */
timestamp?: string
}
UserDto: { identifier: string; role?: string }
UserDto: {
identifier: string
role?: string
name?: string
firstName?: string
organization?: string
accreditedSources?: Array<string>
/* Format: date-time */
creationDate?: string
creationAuthor?: string
}
SurveyDto: {
id: string
sourceId: string
Expand Down Expand Up @@ -340,17 +350,17 @@ export type APISchemas = {
}
OnGoingDto: { ongoing?: boolean }
PageableObject: {
/* Format: int64 */
offset?: number
sort?: APISchemas["SortObject"]
/* Format: int32 */
pageNumber?: number
/* Format: int32 */
pageSize?: number
unpaged?: boolean
/* Format: int64 */
offset?: number
sort?: APISchemas["SortObject"]
paged?: boolean
unpaged?: boolean
}
SortObject: { empty?: boolean; sorted?: boolean; unsorted?: boolean }
SortObject: { sorted?: boolean; empty?: boolean; unsorted?: boolean }
UserPage: {
content?: Array<APISchemas["UserDto"]>
pageable?: APISchemas["PageableObject"]
Expand Down Expand Up @@ -608,7 +618,7 @@ export type APISchemas = {
empty?: boolean
}
PeriodDto: { value?: string; label?: string; period?: string }
PeriodicityDto: { value: string; label: string }
PeriodicityDto: { value?: string; label?: string }
EligibleDto: { eligible?: string }
OwnerPage: {
content?: Array<APISchemas["OwnerDto"]>
Expand Down Expand Up @@ -748,6 +758,7 @@ export type APISchemas = {
totalPages?: number
first?: boolean
last?: boolean
pageable?: APISchemas["PageableObject"]
/* Format: int32 */
size?: number
content?: Array<APISchemas["MoogSearchDto"]>
Expand All @@ -756,7 +767,6 @@ export type APISchemas = {
sort?: APISchemas["SortObject"]
/* Format: int32 */
numberOfElements?: number
pageable?: APISchemas["PageableObject"]
empty?: boolean
}
HealthcheckDto: { status?: string }
Expand All @@ -779,7 +789,7 @@ export type APISchemas = {
empty?: boolean
}
ContactFirstLoginDto: {
identifier: string
identifier?: string
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identifier is required

externalId?: string
civility?: "Female" | "Male" | "Undefined"
lastName?: string
Expand Down Expand Up @@ -1107,7 +1117,7 @@ export type APIEndpoints = {
}
}
"/api/contacts/{id}": {
responses: { get: APISchemas["ContactFirstLoginDto"]; put: APISchemas["ContactDto"]; delete: null }
responses: { get: null; put: APISchemas["ContactDto"]; delete: null }
Comment on lines -1110 to +1120
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La réponse du get m'étonne

Copy link
Copy Markdown
Contributor Author

@EricThuaud EricThuaud Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arf, c'est à nouveau le modéle openapi qui met du null. Tu avais remplacé avec du ContactFirstLoginDto à la mano...ennuyeux de devoir reprendre à chaque mise à jour des types/api..je corrigerai l'api en retour de congés

requests:
| { method?: "get"; urlParams: { id: string } }
| {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Header() {
</Row>
<Box>
{preferred_username}
<IconButton component={RouterLink} to="/reglages">
<IconButton component={RouterLink} to="/settings">
<SettingsOutlinedIcon />
</IconButton>
<IconButton
Expand Down
27 changes: 27 additions & 0 deletions src/ui/Settings/RoleChip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Chip } from "@mui/material";

type Props = {
role: string;
};

export const roleColorsWidth = [
{ role: "administrateur", color: "#442F99", width: "145px" },
{ role: "responsable", color: "#0C8C87", width: "127px" },
{ role: "gestionnaire", color: "#3C75A2", width: "129px" },
{ role: "assistance", color: "#5A1741", width: "113px" },
];

export const RoleChip = ({ role }: Props) => {
const color = role ? roleColorsWidth.find(r => r.role === role.toLowerCase())?.color : "black";
const width = role ? roleColorsWidth.find(r => r.role === role.toLowerCase())?.width : undefined;
return (
<Chip
label={role}
variant={"role"}
style={{
color: color,
width: width,
}}
/>
);
};
Loading