Skip to content

Commit

Permalink
Merge pull request #15 from fabmob/1.21.0
Browse files Browse the repository at this point in the history
Programme Mon Compte Mobilité - Version 1.21.0
  • Loading branch information
TTalex authored Mar 27, 2023
2 parents c66fd68 + 6972868 commit de5e258
Show file tree
Hide file tree
Showing 434 changed files with 27,843 additions and 16,644 deletions.
Binary file added MOB-CME_Archi_technique_detaillee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion administration/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "administration",
"version": "1.16.0",
"version": "1.21.0",
"author": "Mon Compte Mobilité",
"private": true,
"dependencies": {
Expand Down
48 changes: 30 additions & 18 deletions administration/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
/* eslint-disable */
import { Admin, Resource, resolveBrowserLocale } from 'react-admin';
import {
Admin,
Resource,
resolveBrowserLocale
} from 'react-admin';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import frenchMessages from 'ra-language-french';
import { QueryClient, QueryClientProvider } from 'react-query';
import {
Person,
PeopleTwoTone,
BusinessCenter,
NoteOutlined,
Map,
} from '@material-ui/icons';

import dataProvider from './api/provider/dataProvider';
import AuthProvider from './modules/Auth/authProvider';
import { KeycloakProviderInit } from './components/Keycloak/KeycloakProviderInit';
import LogoutButton from './components/LoginForm/LogoutButton';
import Dashboard from './components/Dashboard/Dashboard';
import AccessRole from './components/Access/AccessRole';
import EntrepriseForm from './components/Entreprises';
import CollectiviteForm from './components/Collectivites/CollectiviteForm';
import CollectiviteList from './components/Collectivites/CollectiviteList';
import CommunateForm from './components/Communautes';
import Aide from './components/Aide';
import UtilisateurForm from './components/utilisateurs';
import customTheme from './components/customTheme/customTheme';
import TerritoryForm from './components/Territories';
import FunderForm from './components/Funders';
import CommunityForm from './components/Communities';

const queryClient = new QueryClient();

Expand All @@ -44,31 +53,34 @@ function App(): JSX.Element {
theme={customTheme}
>
<Resource
name="collectivites"
options={{ label: 'Collectivités' }}
list={CollectiviteList}
create={CollectiviteForm}
name="territoires"
options={{ label: 'Territoires' }}
icon={Map}
{...TerritoryForm}
/>
<Resource
name="entreprises"
options={{ label: 'Entreprises' }}
{...EntrepriseForm}
name="financeurs"
options={{ label: 'Financeurs' }}
icon={BusinessCenter}
{...FunderForm}
/>
<Resource name="aides" options={{ label: 'Aides' }} {...Aide} />
<Resource
name="communautes"
options={{ label: 'Communautés' }}
{...CommunateForm}
icon={PeopleTwoTone}
{...CommunityForm}
/>
<Resource
name="utilisateurs"
options={{ label: 'Utilisateurs financeur' }}
options={{ label: 'Utilisateurs financeurs' }}
icon={Person}
{...UtilisateurForm}
/>
<Resource
name="territoires"
options={{ label: 'Territoires' }}
{...TerritoryForm}
name="aides"
options={{ label: 'Aides' }}
icon={NoteOutlined}
{...Aide}
/>
</Admin>
</AccessRole>
Expand Down
13 changes: 13 additions & 0 deletions administration/src/api/clients.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios';
import { URL_API } from '../utils/constant';
import { getAuthHeader } from '../utils/httpHeaders';

export const getClients = async (): Promise<{
clientId: string;
id: string;
}> => {
const { data } = await axios.get(`${await URL_API()}/clients`, {
headers: getAuthHeader(),
});
return data;
};
15 changes: 15 additions & 0 deletions administration/src/api/communities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';
import { URL_API } from '../utils/constant';
import { getAuthHeader } from '../utils/httpHeaders';

export const getFunderCommunityList = async (
funderId: string
): Promise<{ id: string; name: string; funderId: string }[]> => {
const { data } = await axios.get(
`${await URL_API()}/funders/${funderId}/communities`,
{
headers: getAuthHeader(),
}
);
return data;
};
15 changes: 15 additions & 0 deletions administration/src/api/funders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';
import { IFunders, URL_API } from '../utils/constant';
import { getAuthHeader } from '../utils/httpHeaders';

export const getFunders = async (): Promise<IFunders[]> => {
const filter = { order: 'name ASC' };
return (
await axios.get(
`${await URL_API()}/funders?filter=${JSON.stringify(filter)}`,
{
headers: getAuthHeader(),
}
)
).data;
};
71 changes: 66 additions & 5 deletions administration/src/api/provider/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ export default async (type: string, resource: string, params: any) => {
const data = await URL_API();
const dataProvider = lb4Provider(data, getAuthHeader);
const url: string = resourceConverter(type, resource);
return dataProvider(type, url, params);
const convertedParams: any = paramConverter(type, params, resource);
return dataProvider(type, url, convertedParams);
};

const resourceConverter = (type: string, resource: string): string => {
switch (resource) {
case 'collectivites':
return 'collectivities';
case 'entreprises':
return 'enterprises';
case 'financeurs':
return 'funders';
case 'aides':
return 'incentives';
case 'communautes':
Expand All @@ -40,3 +39,65 @@ const resourceConverter = (type: string, resource: string): string => {
return resource;
}
};

const paramConverter = (type: string, params: any, resource: string): any => {

switch (type) {
case 'GET_MANY':
const flattenArray = [].concat(...params.ids);
return { ids: Array.from(new Set(flattenArray)) };
case 'GET_LIST':
if (
resource === 'territoires' &&
params?.filter?.name &&
!params.filter.name.like
) {
return {
...params,
filter: {
name: { like: params.filter.name, options: 'i' },
},
};
}
if (
resource === 'aides' &&
params?.filter?.title &&
!params.filter?.title.like
) {
return {
...params,
filter: {
title: { like: params.filter.title, options: 'i' },
},
};
}
if (
resource === 'financeurs' &&
params?.filter?.name &&
!params.filter?.name.like
) {
return {
...params,
filter: {
name: { like: params.filter.name, options: 'i' },
},
};
}
if (
resource === 'utilisateurs' &&
params?.filter?.lastName &&
!params.filter?.lastName.like
) {
return {
...params,
filter: {
lastName: { like: params.filter.lastName, options: 'i' },
},
};
}

return params;
default:
return params;
}
};
6 changes: 2 additions & 4 deletions administration/src/api/territories.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import axios from 'axios';
import { URL_API } from '../utils/constant';
import { getAuthHeader } from '../utils/httpHeaders';
import { Territory } from '../utils/helpers';

export const getTerritories = async (): Promise<{
name: string;
id: string;
}> => {
export const getTerritories = async (): Promise<Territory[]> => {
const { data } = await axios.get(`${await URL_API()}/territories`, {
headers: getAuthHeader(),
});
Expand Down
8 changes: 5 additions & 3 deletions administration/src/components/Aide/AideCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ const AideCreate: FC<CreateProps> = (props) => {
};

const transform = (data): Record => {
delete data.emailDomainNames;
delete data.hasManualAffiliation;

if (data.eligibilityChecks && data.eligibilityChecks.length > 0) {
return getFormData(data);
}

if (data.specificFields && !data.specificFields.length ) {
delete data.specificFields
if (data.specificFields && !data.specificFields.length) {
delete data.specificFields;
}

return { ...data };
Expand Down
Loading

0 comments on commit de5e258

Please sign in to comment.