Web: Client: Data Import: translate SelectUsersStep to ts in Nextcloud

This commit is contained in:
Vladimir Khvan 2024-06-11 16:32:40 +05:00
parent 9df3f21e9b
commit 77ad2dadc2
3 changed files with 34 additions and 26 deletions

View File

@ -30,7 +30,7 @@ import { Text } from "@docspace/shared/components/text";
import { HelpButton } from "@docspace/shared/components/help-button";
import SelectFileStep from "../../components/SelectFileStep";
import SelectUsersStep from "./SelectUsersStep";
import SelectUsersStep from "../../components/SelectUsersStep";
import AddEmailsStep from "./AddEmailsStep";
import SelectUsersTypeStep from "./SelectUsersTypeStep";
import ImportStep from "./ImportStep";
@ -61,13 +61,7 @@ export const getStepsData = (
{
title: t("Settings:SelectUsersWithEmail"),
description: t("Settings:SelectUsersDescriptionNextcloud"),
component: (
<SelectUsersStep
t={t}
incrementStep={incrementStep}
decrementStep={decrementStep}
/>
),
component: <SelectUsersStep t={t} />,
},
{
title: t("Settings:AddEmails"),

View File

@ -41,21 +41,21 @@ import {
import {
TWorkspaceService,
TSendWelcomeEmailData,
TMigrationUser,
TEnhancedMigrationUser,
TMigrationStatusResult,
} from "@docspace/shared/api/settings/types";
type TUsers = {
new: TMigrationUser[];
existing: TMigrationUser[];
withoutEmail: TMigrationUser[];
result: TMigrationUser[];
new: TEnhancedMigrationUser[];
existing: TEnhancedMigrationUser[];
withoutEmail: TEnhancedMigrationUser[];
result: TEnhancedMigrationUser[];
};
type TCheckedUsers = {
withEmail: TMigrationUser[];
withoutEmail: TMigrationUser[];
result: TMigrationUser[];
withEmail: TEnhancedMigrationUser[];
withoutEmail: TEnhancedMigrationUser[];
result: TEnhancedMigrationUser[];
};
type CheckedAccountTypes = "withEmail" | "withoutEmail" | "result";
@ -112,10 +112,7 @@ class ImportAccountsStore {
}
get withEmailUsers() {
return [
...this.users.existing.map((user) => ({ ...user, isDuplicate: true })),
...this.users.new.map((user) => ({ ...user, isDuplicate: false })),
];
return [...this.users.existing, ...this.users.new];
}
get finalUsers() {
@ -181,15 +178,30 @@ class ImportAccountsStore {
};
setUsers = (data: TMigrationStatusResult) => {
const newUsers = data.users.map((user) => ({
...user,
isDuplicate: false,
}));
const existingUsers = data.existUsers.map((user) => ({
...user,
isDuplicate: true,
}));
const withoutEmailUsers = data.withoutEmailUsers.map((user) => ({
...user,
isDuplicate: false,
}));
runInAction(() => {
this.users = {
new: data.users,
existing: data.existUsers,
withoutEmail: data.withoutEmailUsers,
new: newUsers,
existing: existingUsers,
withoutEmail: withoutEmailUsers,
result: [],
};
this.checkedUsers = {
withEmail: [...data.users],
withEmail: newUsers,
withoutEmail: [],
result: [],
};
@ -222,7 +234,7 @@ class ImportAccountsStore {
};
toggleAccount = (
account: TMigrationUser,
account: TEnhancedMigrationUser,
checkedAccountType: CheckedAccountTypes,
) => {
this.checkedUsers = this.checkedUsers[checkedAccountType].some(
@ -245,7 +257,7 @@ class ImportAccountsStore {
toggleAllAccounts = (
isChecked: boolean,
accounts: TMigrationUser[],
accounts: TEnhancedMigrationUser[],
checkedAccountType: CheckedAccountTypes,
) => {
this.checkedUsers = isChecked

View File

@ -272,6 +272,8 @@ export type TMigrationUser = {
shouldImport: boolean;
};
export type TEnhancedMigrationUser = TMigrationUser & { isDuplicate: boolean };
export type TMigrationStatusResult = {
migratorName: TWorkspaceService;
operation: MigrationOperation;