fix: merge errors

This commit is contained in:
Koosha Lahouti
2025-08-16 11:21:30 +03:30
parent 696d8fc06b
commit f7207b8545
57 changed files with 451 additions and 688 deletions

View File

@@ -11,13 +11,16 @@ import { useTranslation } from 'react-i18next';
import { CardContainer } from '@/components/CardContainer';
import { PageWrapper } from '../PageWrapper';
import { PasswordDialog } from './PasswordDialog';
import { regex } from '@/utils/regex';
import { useManualApi } from '@/hooks/useApi';
import { useApi } from '@/hooks/useApi';
import {
addPassword,
changePassword,
fetchProfile,
} from '../../api/settingsApi';
import { containsNumber } from '@/utils/regexes/containsNumber';
import { least8Chars } from '@/utils/regexes/least8Chars';
import { hasUpperAndLowerLetter } from '@/utils/regexes/hasUpperAndLowerLetter';
import { containsSymbol } from '@/utils/regexes/containsSymbol';
export function PasswordSecurity() {
const theme = useTheme();
@@ -29,36 +32,36 @@ export function PasswordSecurity() {
const [confirmPassword, setConfirmPassword] = useState('');
const [currentPassword, setCurrentPassword] = useState('');
const [showValidation, setShowValidation] = useState(false);
const [showPasswordAlert, setShowPasswordAlert] = useState(false);
const [changePasswordUI, setChangePasswordUI] = useState(false);
const { validPassword } = regex(password);
const hasNumber = containsNumber(password);
const hasMinLength = least8Chars(password);
const hasUpperAndLower = hasUpperAndLowerLetter(password);
const hasSpecialChar = containsSymbol(password);
const validPassword =
hasNumber && hasMinLength && hasUpperAndLower && hasSpecialChar;
const matchPassword = password === confirmPassword;
const {
data: profileData,
loading: isFetching,
error: fetchError,
execute: executeFetchProfile,
} = useManualApi(fetchProfile);
} = useApi(fetchProfile, { immediate: true });
const {
data: addData,
loading: isAdding,
error: addError,
execute: executeAddPassword,
} = useManualApi(addPassword);
} = useApi(addPassword);
const {
data: changeData,
loading: isChanging,
error: changeError,
execute: executeChangePassword,
} = useManualApi(changePassword);
useEffect(() => {
executeFetchProfile();
}, []);
} = useApi(changePassword);
useEffect(() => {
if (profileData?.success) {
@@ -76,7 +79,6 @@ export function PasswordSecurity() {
useEffect(() => {
if (addData?.success || changeData?.success) {
setShowPasswordAlert(true);
if (!changePasswordUI) {
setChangePasswordUI(true);
}
@@ -90,14 +92,14 @@ export function PasswordSecurity() {
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const handlePasswordSubmit = () => {
const handlePasswordSubmit = async () => {
if (changePasswordUI) {
executeChangePassword({
await executeChangePassword({
oldPassword: currentPassword,
newPassword: password,
});
} else {
executeAddPassword({ password });
await executeAddPassword({ password });
}
};

View File

@@ -11,7 +11,7 @@ import { CardContainer } from '@/components/CardContainer';
import { PageWrapper } from '../PageWrapper';
import { fetchProfile } from '../../api/settingsApi';
import type { LoginLog } from '../../types/settingsApiType';
import { useManualApi } from '@/hooks/useApi';
import { useApi } from '@/hooks/useApi';
import { formatDate } from '@/utils/formatSessionDate';
export function RecentLogins() {
@@ -24,12 +24,7 @@ export function RecentLogins() {
data: profileData,
loading: isLoading,
error: fetchError,
execute: executeFetchProfile,
} = useManualApi(fetchProfile);
useEffect(() => {
executeFetchProfile();
}, [i18n.language]);
} = useApi(fetchProfile, { immediate: true });
useEffect(() => {
if (profileData?.success && Array.isArray(profileData.loginLogs)) {