Skip to content

Commit f2855b8

Browse files
authored
Merge pull request #237 from AppQuality/develop
Bug fixes
2 parents 92a52b1 + 77403aa commit f2855b8

File tree

21 files changed

+279
-97
lines changed

21 files changed

+279
-97
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.4.0",
44
"private": true,
55
"dependencies": {
6-
"@appquality/unguess-design-system": "2.11.18",
6+
"@appquality/unguess-design-system": "2.12.11",
77
"@headwayapp/react-widget": "^0.0.4",
88
"@reduxjs/toolkit": "^1.8.0",
99
"@rtk-query/codegen-openapi": "^1.0.0-alpha.1",

src/app/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { configureStore } from '@reduxjs/toolkit';
22
import { setupListeners } from '@reduxjs/toolkit/dist/query';
3+
import { unguessApiSlice } from 'src/features/api/apiTags';
34
import userReducer from '../features/user/userSlice';
45
import navigationReducer from '../features/navigation/navigationSlice';
56
import workspaceReducer from '../features/workspaces/workspaceSlice';
67
import filterReducer from '../features/campaignsFilter/campaignsFilterSlice';
78
import expressReducer from '../features/express/expressSlice';
8-
import { apiSlice } from '../features/api/api';
99
import { strapiSlice } from '../features/backoffice/strapi';
1010

1111
export const store = configureStore({
@@ -15,13 +15,13 @@ export const store = configureStore({
1515
workspaces: workspaceReducer,
1616
filters: filterReducer,
1717
express: expressReducer,
18-
[apiSlice.reducerPath]: apiSlice.reducer,
18+
[unguessApiSlice.reducerPath]: unguessApiSlice.reducer,
1919
[strapiSlice.reducerPath]: strapiSlice.reducer,
2020
},
2121

2222
middleware: (getDefaultMiddleware) =>
2323
getDefaultMiddleware()
24-
.concat(apiSlice.middleware)
24+
.concat(unguessApiSlice.middleware)
2525
.concat(strapiSlice.middleware),
2626
});
2727

src/features/api/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const apiSlice = createApi({
2020
},
2121
paramsSerializer: (params) => stringify(params, { encodeValuesOnly: true }),
2222
}),
23+
tagTypes: ['User', 'Workspaces', 'Projects', 'Campaigns', 'Templates'],
2324
endpoints: (build) => ({
2425
getWorkspacesByWid: build.query<
2526
GetWorkspacesByWidApiResponse,

src/features/api/apiTags.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { unguessApi } from '.';
2+
3+
unguessApi.enhanceEndpoints({
4+
endpoints: {
5+
getUsersMe: {
6+
providesTags: ['User'],
7+
},
8+
getWorkspaces: {
9+
providesTags: ['Workspaces'],
10+
},
11+
getWorkspacesByWid: {
12+
providesTags: ['Workspaces'],
13+
},
14+
getWorkspacesByWidCampaigns: {
15+
providesTags: ['Campaigns', 'Projects'],
16+
},
17+
getWorkspacesByWidProjects: {
18+
providesTags: ['Projects'],
19+
},
20+
getWorkspacesByWidProjectsAndPid: {
21+
providesTags: ['Projects'],
22+
},
23+
getWorkspacesByWidProjectsAndPidCampaigns: {
24+
providesTags: ['Campaigns', 'Projects'],
25+
},
26+
getProjectsByPidCampaigns: {
27+
providesTags: ['Campaigns', 'Projects'],
28+
},
29+
getProjectsByPid: {
30+
providesTags: ['Projects'],
31+
},
32+
patchProjectsByPid: {
33+
invalidatesTags: ['Projects'],
34+
},
35+
postCampaigns: {
36+
invalidatesTags: ['Campaigns'],
37+
},
38+
patchCampaignsByCid: {
39+
invalidatesTags: ['Campaigns'],
40+
},
41+
postProjects: {
42+
invalidatesTags: ['Projects'],
43+
},
44+
getWorkspacesByWidCoins: {
45+
providesTags: ['Workspaces'],
46+
},
47+
getTemplates: {
48+
providesTags: ['Templates'],
49+
},
50+
},
51+
});
52+
53+
export { unguessApi as unguessApiSlice };

src/features/api/index.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ const injectedRtkApi = api.injectEndpoints({
9090
>({
9191
query: (queryArg) => ({ url: `/projects/${queryArg.pid}` }),
9292
}),
93+
patchProjectsByPid: build.mutation<
94+
PatchProjectsByPidApiResponse,
95+
PatchProjectsByPidApiArg
96+
>({
97+
query: (queryArg) => ({
98+
url: `/projects/${queryArg.pid}`,
99+
method: 'PATCH',
100+
body: queryArg.body,
101+
}),
102+
}),
93103
postCampaigns: build.mutation<
94104
PostCampaignsApiResponse,
95105
PostCampaignsApiArg
@@ -100,6 +110,16 @@ const injectedRtkApi = api.injectEndpoints({
100110
body: queryArg.body,
101111
}),
102112
}),
113+
patchCampaignsByCid: build.mutation<
114+
PatchCampaignsByCidApiResponse,
115+
PatchCampaignsByCidApiArg
116+
>({
117+
query: (queryArg) => ({
118+
url: `/campaigns/${queryArg.cid}`,
119+
method: 'PATCH',
120+
body: queryArg.body,
121+
}),
122+
}),
103123
postProjects: build.mutation<PostProjectsApiResponse, PostProjectsApiArg>({
104124
query: (queryArg) => ({
105125
url: `/projects`,
@@ -250,6 +270,14 @@ export type GetProjectsByPidApiArg = {
250270
/** Project id */
251271
pid: number;
252272
};
273+
export type PatchProjectsByPidApiResponse = /** status 200 OK */ Project;
274+
export type PatchProjectsByPidApiArg = {
275+
/** Project id */
276+
pid: number;
277+
body: {
278+
display_name: string;
279+
};
280+
};
253281
export type PostCampaignsApiResponse = /** status 200 OK */ Campaign;
254282
export type PostCampaignsApiArg = {
255283
body: {
@@ -275,6 +303,14 @@ export type PostCampaignsApiArg = {
275303
use_cases?: UseCase[];
276304
};
277305
};
306+
export type PatchCampaignsByCidApiResponse = /** status 200 OK */ Campaign;
307+
export type PatchCampaignsByCidApiArg = {
308+
/** Campaign id */
309+
cid: number;
310+
body: {
311+
customer_title?: string;
312+
};
313+
};
278314
export type PostProjectsApiResponse = /** status 200 OK */ Project;
279315
export type PostProjectsApiArg = {
280316
body: {
@@ -439,7 +475,9 @@ export const {
439475
useGetWorkspacesByWidProjectsAndPidCampaignsQuery,
440476
useGetProjectsByPidCampaignsQuery,
441477
useGetProjectsByPidQuery,
478+
usePatchProjectsByPidMutation,
442479
usePostCampaignsMutation,
480+
usePatchCampaignsByCidMutation,
443481
usePostProjectsMutation,
444482
useGetWorkspacesByWidCoinsQuery,
445483
useGetTemplatesQuery,

src/features/navigation/Navigation.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
Content,
44
Sidebar,
55
ProfileModal,
6-
PageLoader,
76
theme,
87
} from '@appquality/unguess-design-system';
98
import { useTranslation } from 'react-i18next';
@@ -84,10 +83,6 @@ export const Navigation = ({
8483
wid: activeWorkspace?.id || 0,
8584
});
8685

87-
if (projects.isFetching || projects.isLoading) {
88-
return <PageLoader />;
89-
}
90-
9186
const projectsList =
9287
!projects.data || !projects.data.items
9388
? []
@@ -211,6 +206,8 @@ export const Navigation = ({
211206
dispatch(setProfileModalOpen(false));
212207
};
213208

209+
if (!activeWorkspace) return null;
210+
214211
return (
215212
<>
216213
<AppHeader
@@ -253,6 +250,8 @@ export const Navigation = ({
253250
projects={projectsList}
254251
isExpanded={isSidebarOpen}
255252
onToggleMenu={toggleSidebarState}
253+
defaultAccordionPanels={[0]}
254+
isLoading={projects.isFetching || projects.isLoading}
256255
dividerLabel={t('__APP_SIDEBAR_PROJECTS_DIVIDER_LABEL')}
257256
onNavToggle={navigateTo}
258257
currentRoute={

src/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"__EXPRESS_LABEL": "Express",
118118
"__EXPRESS_WIZARD_BACK_BUTTON_LABEL": "Back",
119119
"__EXPRESS_WIZARD_CONFIRM_BUTTON_LABEL": "Launch",
120-
"__EXPRESS_WIZARD_CONFIRM_CLOSE_MESSAGE": "If you close this modal, you will lose all the informations you have entered.",
120+
"__EXPRESS_WIZARD_CONFIRM_CLOSE_MESSAGE": "The campaign will be discarded.",
121121
"__EXPRESS_WIZARD_CONFIRM_DELETE_USE_CASE": "If you delete it, you will lose all the informations you have entered.",
122122
"__EXPRESS_WIZARD_CONFIRM_PLANNING_BUTTON_LABEL": "Plan",
123123
"__EXPRESS_WIZARD_NEXT_BUTTON_LABEL": "Next",
@@ -295,6 +295,7 @@
295295
"__PROFILE_MODAL_FEEDBACK_TITLE": "Give us your feedback",
296296
"__PROFILE_MODAL_LANGUAGES_TITLE": "Change Language",
297297
"__PROFILE_MODAL_LOGOUT_TITLE": "Log Out",
298+
"__PROJECT_PAGE_UPDATE_PROJECT_NAME_ERROR": "",
298299
"__SERVICE_DETAIL_PAGE_TAG_RESULTS_DAYS_LABEL": "First results in <1><0>{{hours}}</0></1>h",
299300
"__SIDEBAR_CAMPAIGNS_LABEL": "campaigns",
300301
"__TAILORED_LABEL": "Tailored",

src/locales/it/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"__EXPRESS_LABEL": "Express",
118118
"__EXPRESS_WIZARD_BACK_BUTTON_LABEL": "Indietro",
119119
"__EXPRESS_WIZARD_CONFIRM_BUTTON_LABEL": "Lancia",
120-
"__EXPRESS_WIZARD_CONFIRM_CLOSE_MESSAGE": "Se chiudi questa modale, perderai tutte le informazioni da te inserite.",
120+
"__EXPRESS_WIZARD_CONFIRM_CLOSE_MESSAGE": "La campagna verrà eliminata per sempre.",
121121
"__EXPRESS_WIZARD_CONFIRM_DELETE_USE_CASE": "Se lo elimini, perderai tutte le informazioni inserite.",
122122
"__EXPRESS_WIZARD_CONFIRM_PLANNING_BUTTON_LABEL": "Pianifica",
123123
"__EXPRESS_WIZARD_NEXT_BUTTON_LABEL": "Avanti",
@@ -295,6 +295,7 @@
295295
"__PROFILE_MODAL_FEEDBACK_TITLE": "Dacci il tuo feedback",
296296
"__PROFILE_MODAL_LANGUAGES_TITLE": "Cambia Lingua",
297297
"__PROFILE_MODAL_LOGOUT_TITLE": "Esci",
298+
"__PROJECT_PAGE_UPDATE_PROJECT_NAME_ERROR": "",
298299
"__SERVICE_DETAIL_PAGE_TAG_RESULTS_DAYS_LABEL": "Primi risultati in <1><0>{{hours}}</0></1>h",
299300
"__SIDEBAR_CAMPAIGNS_LABEL": "campagne",
300301
"__TAILORED_LABEL": "Tailored",

src/pages/Dashboard/Project.tsx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import {
88
projectFilterChanged,
99
resetFilters,
1010
} from 'src/features/campaignsFilter/campaignsFilterSlice';
11-
import { useGetProjectsByPidQuery } from 'src/features/api';
12-
import { DashboardHeaderContent } from './headerContent';
13-
import { CardRowLoading } from './CardRowLoading';
1411
import { ProjectItems } from './project-items';
12+
import { ProjectPageHeader } from './projectPageHeader';
1513

1614
const Project = () => {
1715
const { t } = useTranslation();
@@ -22,30 +20,20 @@ const Project = () => {
2220

2321
if (!projectId || Number.isNaN(Number(projectId))) {
2422
navigate(notFoundRoute, { replace: true });
25-
}
26-
27-
const project = useGetProjectsByPidQuery({
28-
pid: projectId ? parseInt(projectId, 10) : 0,
29-
});
30-
31-
if (project.isError) navigate(notFoundRoute, { replace: true });
32-
33-
if (project.isSuccess && project.data) {
23+
} else {
3424
dispatch(resetFilters());
35-
dispatch(projectFilterChanged(project.data.id));
25+
dispatch(projectFilterChanged(Number(projectId)));
3626
}
3727

38-
const isLoading = project.isFetching || project.isLoading;
39-
4028
return (
4129
<Page
4230
title={t('__PAGE_TITLE_PRIMARY_DASHBOARD_SINGLE_PROJECT')}
4331
route="projects"
44-
pageHeader={
45-
<DashboardHeaderContent pageTitle={project?.data?.name || 'Project'} />
46-
}
32+
pageHeader={<ProjectPageHeader projectId={Number(projectId) || 0} />}
4733
>
48-
<Grid>{isLoading ? <CardRowLoading /> : <ProjectItems />}</Grid>
34+
<Grid>
35+
<ProjectItems />
36+
</Grid>
4937
</Page>
5038
);
5139
};

src/pages/Dashboard/headerContent.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ export const DashboardHeaderContent = ({
2323

2424
return status === 'idle' || status === 'loading' ? null : (
2525
<PageHeader>
26-
<PageHeader.Main
27-
infoTitle={pageTitle || 'My Dashboard'}
28-
infoCounters={<Counters />}
29-
/>
26+
<PageHeader.Main infoTitle={pageTitle || 'My Dashboard'}>
27+
<PageHeader.Title>{pageTitle || 'My Dashboard'}</PageHeader.Title>
28+
<PageHeader.Counters>
29+
<Counters />
30+
</PageHeader.Counters>
31+
</PageHeader.Main>
3032
{hasButton && (
3133
<PageHeader.Buttons>
3234
<Button

0 commit comments

Comments
 (0)