Skip to content
Merged

Un 2040 #1467

Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -6,7 +6,7 @@
"@analytics/google-tag-manager": "^0.6.0",
"@analytics/hubspot": "^0.5.1",
"@appquality/languages": "1.4.3",
"@appquality/unguess-design-system": "4.0.50",
"@appquality/unguess-design-system": "4.0.51",
"@atlaskit/pragmatic-drag-and-drop": "^1.7.4",
"@atlaskit/pragmatic-drag-and-drop-flourish": "^2.0.3",
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
Expand Down
177 changes: 164 additions & 13 deletions src/common/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ export interface paths {
};
"/buy": {
/**
* Stripe webhook destination, listen three event types:
* - charge.failed,
* - checkout.session.completed
* - checkout.session.expired
* Stripe webhook destination, listen following event types:
* - checkout.session.completed (Occurs when a Checkout Session has been successfully completed)
* - checkout.session.expired (Occurs when a Checkout Session is expired)
* - checkout.session.async_payment_failed (Occurs when a payment intent using a delayed payment method fails)
* - checkout.session.async_payment_succeeded (Occurs when a payment intent using a delayed payment method finally succeeds)
* - charge.refunded (Occurs whenever a charge is refunded, including partial refunds. Listen to refund.created for information about the refund)
*/
post: operations["post-buy"];
};
Expand Down Expand Up @@ -475,6 +477,10 @@ export interface paths {
};
};
};
"/users/me/watched/plans": {
get: operations["get-users-me-watched-plans"];
parameters: {};
};
"/users/roles": {
get: operations["get-users-roles"];
parameters: {};
Expand Down Expand Up @@ -622,6 +628,17 @@ export interface paths {
};
};
};
"/plans/{pid}/watchers": {
/** Returns all the watcher added to a plan. It always returns at least one item. */
get: operations["get-plans-pid-watchers"];
put: operations["put-plans-pid-watchers"];
post: operations["post-plans-pid-watchers"];
parameters: {
path: {
pid: string;
};
};
};
"/workspaces/{wid}/templates": {
get: operations["get-workspaces-templates"];
post: operations["post-workspaces-wid-templates"];
Expand Down Expand Up @@ -656,6 +673,15 @@ export interface paths {
};
};
};
"/plans/{pid}/watchers/{profile_id}": {
delete: operations["delete-plans-pid-watchers-profile_id"];
parameters: {
path: {
pid: string;
profile_id: string;
};
};
};
}

export interface components {
Expand Down Expand Up @@ -1332,8 +1358,7 @@ export interface components {
kind: "app";
os: {
ios?: string;
linux?: string;
windows?: string;
android?: string;
};
};
/** OutputModuleTouchpointsWebDesktop */
Expand Down Expand Up @@ -1442,7 +1467,8 @@ export interface components {
| "module_type"
| "number_of_testers"
| "number_of_tasks"
| "task_type";
| "task_type"
| "duplicate_touchpoint_form_factors";
/** Report */
Report: {
creation_date?: string;
Expand Down Expand Up @@ -1999,10 +2025,12 @@ export interface operations {
requestBody: components["requestBodies"]["Credentials"];
};
/**
* Stripe webhook destination, listen three event types:
* - charge.failed,
* - checkout.session.completed
* - checkout.session.expired
* Stripe webhook destination, listen following event types:
* - checkout.session.completed (Occurs when a Checkout Session has been successfully completed)
* - checkout.session.expired (Occurs when a Checkout Session is expired)
* - checkout.session.async_payment_failed (Occurs when a payment intent using a delayed payment method fails)
* - checkout.session.async_payment_succeeded (Occurs when a payment intent using a delayed payment method finally succeeds)
* - charge.refunded (Occurs whenever a charge is refunded, including partial refunds. Listen to refund.created for information about the refund)
*/
"post-buy": {
responses: {
Expand All @@ -2027,13 +2055,17 @@ export interface operations {
key: string;
tag: string;
};
/** @enum {string} */
payment_status?: "paid" | "unpaid";
};
};
/** @enum {undefined} */
type:
| "checkout.session.completed"
| "checkout.session.async_payment_succeeded"
| "checkout.session.async_payment_failed"
| "checkout.session.expired";
| "checkout.session.completed"
| "checkout.session.expired"
| "charge.refunded";
};
};
};
Expand Down Expand Up @@ -3864,6 +3896,31 @@ export interface operations {
};
};
};
"get-users-me-watched-plans": {
parameters: {};
responses: {
200: {
content: {
"application/json": {
items: {
id?: number;
name?: string;
project?: {
name?: string;
id?: number;
};
isLast?: boolean;
}[];
allItems: number;
};
};
};
400: components["responses"]["Error"];
403: components["responses"]["Error"];
404: components["responses"]["Error"];
500: components["responses"]["Error"];
};
};
"get-users-roles": {
parameters: {};
responses: {
Expand Down Expand Up @@ -4393,6 +4450,81 @@ export interface operations {
500: components["responses"]["Error"];
};
};
/** Returns all the watcher added to a plan. It always returns at least one item. */
"get-plans-pid-watchers": {
parameters: {
path: {
pid: string;
};
};
responses: {
/** OK */
200: {
content: {
"application/json": {
items: {
id: number;
name: string;
surname: string;
email: string;
image?: string;
isInternal: boolean;
}[];
};
};
};
403: components["responses"]["Error"];
404: components["responses"]["Error"];
500: components["responses"]["Error"];
};
};
"put-plans-pid-watchers": {
parameters: {
path: {
pid: string;
};
};
responses: {
/** OK */
200: unknown;
400: components["responses"]["Error"];
403: components["responses"]["Error"];
404: components["responses"]["Error"];
500: components["responses"]["Error"];
};
requestBody: {
content: {
"application/json": {
users: {
id: number;
}[];
};
};
};
};
"post-plans-pid-watchers": {
parameters: {
path: {
pid: string;
};
};
responses: {
/** OK */
200: unknown;
403: components["responses"]["Error"];
404: components["responses"]["Error"];
500: components["responses"]["Error"];
};
requestBody: {
content: {
"application/json": {
users: {
id: number;
}[];
};
};
};
};
"get-workspaces-templates": {
parameters: {
path: {
Expand Down Expand Up @@ -4596,6 +4728,25 @@ export interface operations {
};
};
};
"delete-plans-pid-watchers-profile_id": {
parameters: {
path: {
pid: string;
profile_id: string;
};
};
responses: {
/** OK */
200: {
content: {
"application/json": {
success?: boolean;
};
};
};
403: components["responses"]["Error"];
};
};
}

export interface external {}
5 changes: 4 additions & 1 deletion src/features/api/apiTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ unguessApi.enhanceEndpoints({
invalidatesTags: ['PlanWatchers'],
},
deletePlansByPidWatchersAndProfileId: {
invalidatesTags: ['PlanWatchers'],
invalidatesTags: ['PlanWatchers', 'Plans'],
},
getUsersMeWatchedPlans: {
providesTags: ['Plans', 'PlanWatchers'],
},
},
});
Expand Down
20 changes: 20 additions & 0 deletions src/features/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ const injectedRtkApi = api.injectEndpoints({
body: queryArg.body,
}),
}),
getUsersMeWatchedPlans: build.query<
GetUsersMeWatchedPlansApiResponse,
GetUsersMeWatchedPlansApiArg
>({
query: () => ({ url: `/users/me/watched/plans` }),
}),
getUsersRoles: build.query<GetUsersRolesApiResponse, GetUsersRolesApiArg>({
query: () => ({ url: `/users/roles` }),
}),
Expand Down Expand Up @@ -1816,6 +1822,19 @@ export type PutUsersMePreferencesBySlugApiArg = {
value: string;
};
};
export type GetUsersMeWatchedPlansApiResponse = /** status 200 */ {
items: {
id?: number;
name?: string;
project?: {
name?: string;
id?: number;
};
isLast?: boolean;
}[];
allItems: number;
};
export type GetUsersMeWatchedPlansApiArg = void;
export type GetUsersRolesApiResponse = /** status 200 OK */ {
id: number;
name: string;
Expand Down Expand Up @@ -3108,6 +3127,7 @@ export const {
usePatchUsersMeMutation,
useGetUsersMePreferencesQuery,
usePutUsersMePreferencesBySlugMutation,
useGetUsersMeWatchedPlansQuery,
useGetUsersRolesQuery,
useGetVideosByVidQuery,
useGetVideosByVidObservationsQuery,
Expand Down
51 changes: 1 addition & 50 deletions src/features/navigation/Navigation/NavigationProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import { useAppDispatch, useAppSelector } from 'src/app/hooks';
import { isDev } from 'src/common/isDevEnvironment';
import { prepareGravatar } from 'src/common/utils';
import WPAPI from 'src/common/wpapi';
import {
useGetUsersMePreferencesQuery,
useGetUsersMeQuery,
usePutUsersMePreferencesBySlugMutation,
} from 'src/features/api';
import { useGetUsersMeQuery } from 'src/features/api';
import { useActiveWorkspace } from 'src/hooks/useActiveWorkspace';
import { setProfileModalOpen } from '../navigationSlice';
import { usePathWithoutLocale } from '../usePathWithoutLocale';
Expand All @@ -31,41 +27,12 @@ export const NavigationProfileModal = () => {
const dispatch = useAppDispatch();
const navigate = useNavigate();

const { data: preferences } = useGetUsersMePreferencesQuery();

const notificationsPreference = preferences?.items?.find(
(preference) => preference?.name === 'notifications_enabled'
);
const pathWithoutLocale = usePathWithoutLocale();

const [updatePreference] = usePutUsersMePreferencesBySlugMutation();

const onProfileModalClose = () => {
dispatch(setProfileModalOpen(false));
};

const onSetSettings = async (value: string) => {
await updatePreference({
slug: `${notificationsPreference?.name}`,
body: { value },
})
.unwrap()
.then(() => {
addToast(
({ close }) => (
<Notification
onClose={close}
type="success"
message={t('__PROFILE_MODAL_NOTIFICATIONS_UPDATED')}
closeText={t('__TOAST_CLOSE_TEXT')}
isPrimary
/>
),
{ placement: 'top' }
);
});
};

if (dataError || !user || isLoading) return null;

const profileModal = {
Expand Down Expand Up @@ -114,22 +81,6 @@ export const NavigationProfileModal = () => {
title: t('__PROFILE_MODAL_PRIVACY_ITEM_LABEL'),
url: 'https://www.iubenda.com/privacy-policy/833252/full-legal',
},
settingValue: notificationsPreference?.value ?? '0',
i18n: {
settingsTitle: t('__PROFILE_MODAL_NOTIFICATIONS_TITLE'),
settingsIntroText: t('__PROFILE_MODAL_NOTIFICATIONS_INTRO'),
settingsOutroText: {
paragraph_1: t('__PROFILE_MODAL_NOTIFICATIONS_OUTRO_P_1'),
paragraph_2: t('__PROFILE_MODAL_NOTIFICATIONS_OUTRO_P_2'),
paragraph_3: t('__PROFILE_MODAL_NOTIFICATIONS_OUTRO_P_3'),
},
settingsToggle: {
title: t('__PROFILE_MODAL_NOTIFICATIONS_TOGGLE_TITLE'),
on: t('__PROFILE_MODAL_NOTIFICATIONS_TOGGLE_ON'),
off: t('__PROFILE_MODAL_NOTIFICATIONS_TOGGLE_OFF'),
},
},
onSetSettings,
onSelectLanguage: (lang: string) => {
if (pathWithoutLocale === false) return;
if (lang === i18n.language) return;
Expand Down
Loading
Loading