Filename,Content
index.tsx,"/* eslint-disable react/jsx-filename-extension */
import React from 'react';
import { createRoot } from 'react-dom/client';
import navigationService from '@common/navigation/NavigationService';
import App from './App';
import('./store');
const container = document.getElementById('root');
const root = createRoot(container);
root.render();
//@ts-ignore
if (module?.hot) {
//@ts-ignore
module.hot.accept(function (err) {
console.log('An error occurred while accepting new version: ', err);
});
}
window.onpopstate = () => {
navigationService.goBack();
};
"
App.tsx,"/* eslint-disable import/no-named-as-default */
/* eslint-disable no-useless-constructor */
/* eslint-disable import/no-named-as-default-member */
/* eslint-disable import/extensions */
import React from 'react';
import { Provider } from 'react-redux';
import BasePropTypes from '@common/models/BasePropTypes';
import { routeManager } from '@protolibrary/core';
import storeConfiguration from './store';
import './assets/css/tooltip.css';
import './assets/fonts/style.scss';
import './assets/colors/style.scss';
import './assets/css/main.scss';
import 'prototable/index.css';
import { ThemeApp } from './ThemeApp';
import { ErrorBoundary } from 'react-error-boundary';
import ErrorFallback from '@common/error/ErrorFallback';
import LocalStorage from '@common/storage/Storage';
class App extends React.Component {
constructor(props: BasePropTypes) {
super(props);
}
UNSAFE_componentWillMount(): void {
routeManager.generateRoutes('', {}, {}, '', {});
LocalStorage.delete('x-app-version');
}
render(): React.ReactNode {
return (
// eslint-disable-next-line react/jsx-filename-extension
{
// Reset the state of your app so the error doesn't happen again
}}
onError={(error, componentStack) => {
// Do something with the runtime error
}}
>
);
}
}
export default App;
"
ThemeApp.tsx,"import ProtoContextProvider from '@common/hocs/ProtoContext';
import { ConnectedRouter } from '@protolibrary/core';
import React, { useEffect, useState } from 'react';
import AppMain from './AppMain';
import storeConfiguration from './store';
import { DARK_THEME, LIGHT_THEME } from './themes';
import { default as ProtoProvider } from '@protoweb/provider';
import { Route } from 'react-router-dom';
import { useStore } from '@core/states';
import Block from '@protoweb/block';
import NewVersionModal from '@common/modals/NewVersionModal';
import appState from '@core/states/AppState';
interface Props {}
export const ThemeApp = (props: Props) => {
const { theme, newVersion } = useStore('appState');
const [showModal, setShowModal] = useState(false);
useEffect(() => {
if (newVersion) {
setShowModal(true);
}
}, [newVersion]);
return (
{
setShowModal(false);
appState.update({ newVersion: false });
}}
/>
);
};
"
store.tsx,"import { configure, addAjaxEnricher, routeReducer } from '@protolibrary/core';
import setupAxiosInterceptors from './core/configuration/axios';
import ajaxEnricher from './core/configuration/enricher';
setupAxiosInterceptors();
addAjaxEnricher(ajaxEnricher);
const storeConfiguration = configure({ routing: routeReducer }, []);
export default storeConfiguration;
"
UserCreateUpdate.tsx,"import InputLayout from '@common/components/input-layout';
import PageHeader from '@common/components/page-header';
import RemoteSelect from '@common/components/remote-select';
import navigationService from '@common/navigation/NavigationService';
import { NavigationOperationType } from '@common/navigation/NavigationTypes';
import toastManager from '@common/toast/ToastManager';
import { TextField, Form, Col, Container, Row, Button } from '@protolibrary/components';
import { email, required } from '@protoweb/utils';
import roleService from '@services/RoleService';
import userService, { User } from '@services/UserService';
import { useLocationParams } from '@utils/LocationUtils';
import React, { useEffect, useState } from 'react';
import PasswordInput from '@common/components/password-input';
const UserCreateUpdate = props => {
const { operationType, id } = useLocationParams(props);
const [data, setData] = useState(null);
const refForm = React.useRef(null);
const handleOnSubmit = () => {
const values = refForm.current.getValues();
if (operationType === NavigationOperationType.CREATE) {
const request: User = {
userName: values.userName,
firstName: values.firstName,
lastName: values.lastName,
roleIds: values.roleIds,
email: values.email,
};
userService.post(request, { password: values.password }).then(res => {
toastManager.show('success', 'Kullanıcı basariyla olusturuldu');
navigationService.push('/system-management/user-management');
});
} else if (operationType === NavigationOperationType.UPDATE) {
const request: User = {
id: data?.id,
userName: data?.userName,
firstName: values.firstName,
lastName: values.lastName,
email: values.email,
roleIds: values.roleIds,
};
userService.put(request).then(res => {
toastManager.show('success', 'Kullanıcı başarıyla guncellendi');
navigationService.push('/system-management/user-management');
});
}
};
useEffect(() => {
operationType === NavigationOperationType.UPDATE &&
userService.get(id).then(res => {
setData(res);
refForm.current.setValues(res);
});
}, []);
return (
);
};
export default UserCreateUpdate;
import React from 'react';
import BasePropTypes from '@common/models/BasePropTypes';
import { Block, BackgroundImage, Label } from '@protolibrary/components';
import COLORS from '@resources/colors';
interface LoginPropTypes extends BasePropTypes {
fromCaptcha: boolean;
}
const WelcomePage: React.FC = () => {
return (
);
};
export default WelcomePage;
import React from 'react';
import { Button, Col, Container, Form, Row } from '@protolibrary/components';
import PageHeader from '@common/components/page-header';
import InputLayout from '@common/components/input-layout';
import PasswordInput from '@common/components/password-input';
import { required } from '@protoweb/utils';
import userService from '@services/UserService';
import toastManager from '@common/toast/ToastManager';
import { useLocationParams } from '@utils/LocationUtils';
import navigationService from '@common/navigation/NavigationService';
const ResetPassword = props => {
const { id, userName, fullName } = useLocationParams(props);
const refForm = React.useRef(null);
const handleOnSubmit = () => {
const values = refForm.current.getValues();
userService.resetPassword(id, { newPassword: values.newPassword }).then(_ => {
toastManager.show('success', 'Şifre başarıyla sıfırlandı.');
navigationService.push('/system-management/user-management');
});
};
return (
);
};
export default ResetPassword;
import InputLayout from '@common/components/input-layout';
import PageHeader from '@common/components/page-header';
import toastManager from '@common/toast/ToastManager';
import { Form, Col, Container, Row, Button } from '@protolibrary/components';
import { required } from '@protoweb/utils';
import userService, { ChangePasswordData } from '@services/UserService';
import React from 'react';
import PasswordInput from '@common/components/password-input';
const ChangePassword = props => {
const refForm = React.useRef(null);
const handleOnSubmit = () => {
const values = refForm.current.getValues();
const request: ChangePasswordData = {
oldPassword: values.oldPassword,
newPassword: values.newPassword,
newPasswordValidation: values.newPasswordValidation,
};
userService.changePassword(request).then(res => {
toastManager.show('success', 'Şifre başarıyla değiştirildi.');
});
};
return (
);
};
export default ChangePassword;
import { Container } from '@protolibrary/components';
import React from 'react';
import Countdown from '../../components/countdown';
const DashBoard = () => {
return (
);
};
export default DashBoard;
import React from 'react';
import BasePropTypes from '@common/models/BasePropTypes';
import {
Block,
Form,
Icon,
TextField,
BackgroundImage,
Label,
Checkbox,
} from '@protolibrary/components';
import Button from '@protoweb/button';
import authService from '@services/AuthService';
import PasswordInput from '@common/components/password-input';
import COLORS from '@resources/colors';
import { LOGO } from '../../layout/assets/icons';
import useLocalization from '@hooks/useLocalization';
interface LoginPropTypes extends BasePropTypes {
fromCaptcha: boolean;
}
const Login: React.FC = () => {
const formRef = React.useRef();
const { t } = useLocalization();
const handleOnSubmit = (_, formValues): void => {
let values = { userName: formValues?.userName, password: formValues?.password };
authService.login(values, formValues?.rememberMe);
};
const textfieldStyle = () => {
return {
container: {
height: 60,
position: 'relative',
cursor: 'pointer',
},
element: {
paddingLeft: 20,
height: 60,
cursor: 'pointer',
borderRadius: 8,
background: 'white',
borderWidth: 1,
borderStyle: 'solid',
borderColor: COLORS.GRAY,
fontSize: 16,
},
};
};
return (
);
};
export default Login;
"
AppMain.tsx,"import ErrorManager from '@common/error/ErrorManager';
import * as React from 'react';
import { useSelector } from 'react-redux';
import { Route, Switch } from 'react-router-dom';
import 'react-tippy/dist/tippy.css';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import Loader from './components/Loader';
import { useStore } from '@core/states';
import DashBoard from './pages/authenticated/Dashboard';
import OrderPage from './pages/authenticated/order-management';
import NewOrderPage from './pages/authenticated/order-management/pages/NewOrder';
import Login from './pages/guest/Login';
import navigationService from '@common/navigation/NavigationService';
import 'primeflex/primeflex.css';
import 'react-toastify/dist/ReactToastify.css';
import './assets/css/custom.css';
import './assets/css/main.scss';
import './assets/css/tooltip.css';
import GenericModal from '@components/GenericModal';
import Layout from './layout';
import TaskManagement from './pages/authenticated/task-management';
import RoleManagement from './pages/authenticated/role-management';
import UserManagement from './pages/authenticated/user-management';
import UserCreateUpdate from './pages/authenticated/user-management/pages/UserCreateUpdate';
import CreateUpdateTask from './pages/authenticated/task-management/pages/CreateUpdateTask';
import CreateUpdateRole from './pages/authenticated/role-management/pages/CreateUpdateRole';
import authState from '@core/states/AuthState';
import accountService from '@services/Account';
import NAVIGATION_PATHS from '@common/navigation/NavigationPaths';
import OrderDetail from './pages/authenticated/order-management/pages/OrderDetail';
import OrderVehicleDetail from './pages/authenticated/order-management/pages/OrderVehicleDetail';
import ChangePassword from './pages/authenticated/user-management/pages/ChangePassword';
import ResetPassword from './pages/authenticated/user-management/pages/ResetPassword';
import en from 'public/lang/en.json';
import tr from 'public/lang/tr.json';
import LocalizedStrings from '@localization/LocalizedStrings';
import CustomerManagement from './pages/authenticated/customer-management';
import CustomerCreateUpdate from './pages/authenticated/customer-management/pages/CustomerCreateUpdate';
import ProjectManagement from './pages/authenticated/project-management';
import ProjectCreateUpdate from './pages/authenticated/project-management/pages/ProjectCreateUpdate';
export interface AppMainPropTypes {
authenticated: boolean;
isLoading: boolean;
location: any;
}
function AppMain({ location }: AppMainPropTypes) {
const isAuthenticated = useSelector(state => state.authState.authenticated);
const modalStore = useStore('modalState');
const { open, type, closeAction, confirmAction } = modalStore;
const { open: loaderOpen } = useStore('loaderState');
React.useEffect(() => {
const lastRoute = sessionStorage.getItem('routePath');
accountService.getInfo().then(res => {
authState.update({ authenticated: true, roles: res.roles, fullName: res.fullName });
let routeParameters = sessionStorage.getItem('routeParameters');
if (routeParameters && typeof routeParameters === 'string') {
routeParameters = JSON.parse(routeParameters);
}
navigationService.push(
lastRoute || NAVIGATION_PATHS.SYSTEM_MANAGEMENT.ORDER.BASE,
routeParameters,
);
});
}, [isAuthenticated]);
React.useEffect(() => {
new LocalizedStrings({ EN: en, TR: tr });
}, []);
return (
<>
{loaderOpen && }
{open && (
)}
{isAuthenticated ? (
) : (
)}
>
);
}
export default AppMain;
"