From 8fcf50fa7b10dbda264c9e6b5e57c1a892956278 Mon Sep 17 00:00:00 2001
From: Amirreza vishteh <74289878+amirrezavishteh@users.noreply.github.com>
Date: Thu, 30 Nov 2023 17:31:14 +0330
Subject: [PATCH 1/6] fix colors
---
vakilpors-front/src/css/PremiumLawyer.css | 34 +++++++++++++++--------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/vakilpors-front/src/css/PremiumLawyer.css b/vakilpors-front/src/css/PremiumLawyer.css
index 544143f2e..f831b103b 100644
--- a/vakilpors-front/src/css/PremiumLawyer.css
+++ b/vakilpors-front/src/css/PremiumLawyer.css
@@ -1,24 +1,36 @@
.custom-styles {
- background: linear-gradient(to bottom, #8e44ad, #6a0dad);
+ background: linear-gradient(to bottom, #8e44ad, #d2b4de);
padding: 30px;
text-align: center;
+
+}
+.custom-header{
+ /* background: linear-gradient(to bottom, #8e44ad, #6a0dad); */
+ margin-top: 0px;
+ padding-top:0px;
}
-
.custom-styles .custom-title {
+ margin-top: 0px;
+ padding-top:0px;
color: white;
font-size: 2.5em;
margin-bottom: 10px;
}
.custom-subtitle {
+ vmargin-top: 0px;
+ padding-top:0px;
font-style: italic;
font-size: 1.2em;
line-height: 1.5;
}
.custom-container {
+ margin-top: 0px;
max-width: 1000px;
margin: 40px auto;
+ background:#d2b4de;
+ padding-top:0px;
}
.custom-plans {
@@ -27,14 +39,14 @@
}
.custom-plan-card {
- background: #e6e6fa; /* Purple */
+ background: white; /* White background for the body */
padding: 30px;
border: 1px solid #d2b4de; /* Lighter Purple */
border-radius: 10px;
}
-.custom-price {
- background: #9b59b6; /* Lighter Purple */
+.custom-plan-card .custom-price {
+ background: #8e44ad; /* Purple for the heading */
border-radius: 10px;
display: flex;
justify-content: space-between;
@@ -42,27 +54,27 @@
padding: 10px 15px;
}
-.custom-price .amount {
+.custom-plan-card .custom-price .amount {
font-size: 24px;
font-weight: bold;
color: white;
}
-.custom-price .period {
+.custom-plan-card .custom-price .period {
font-size: 16px;
color: white;
}
-.custom-description {
- color: #753240;
+.custom-plan-card .custom-description {
+ color: #753240; /* Text color for the body */
margin-top: 20px;
line-height: 1.6;
}
-.custom-features {
+.custom-plan-card .custom-features {
list-style-type: disc;
margin-left: 20px;
- color: #753240;
+ color: #753240; /* Text color for the body */
}
.custom-button {
From c2bff06109605041ef728771aeaa4ea31ad4e104 Mon Sep 17 00:00:00 2001
From: Amirreza vishteh <74289878+amirrezavishteh@users.noreply.github.com>
Date: Thu, 30 Nov 2023 19:05:38 +0330
Subject: [PATCH 2/6] add test : moving bar and app.js and modify test of
advertising
---
vakilpors-front/src/App.test.js | 72 ++++++++++-
.../premium-page/test/Avertising.test.jsx | 118 ++++++++++++++++--
.../test/MovingBarComponent.test.jsx | 38 ++++++
3 files changed, 214 insertions(+), 14 deletions(-)
create mode 100644 vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx
diff --git a/vakilpors-front/src/App.test.js b/vakilpors-front/src/App.test.js
index 4de7037e0..d0c0d4f5c 100644
--- a/vakilpors-front/src/App.test.js
+++ b/vakilpors-front/src/App.test.js
@@ -1,8 +1,68 @@
-import { render, screen } from '@testing-library/react';
-import App from './App';
+import React from 'react';
+import { render, screen, waitFor, act, fireEvent } from '@testing-library/react';
+import axios from 'axios';
+import MockAdapter from 'axios-mock-adapter';
+import { BrowserRouter as Router } from 'react-router-dom';
+import App, { BASE_API_ROUTE } from './App';
-test('renders learn react link', () => {
- render( );
- const linkElement = screen.getByText(/learn react/i);
- expect(linkElement).toBeInTheDocument();
+const mockAxios = new MockAdapter(axios);
+
+const mockLawyers = [
+ {
+ id: 134,
+ user: {
+ id: 13,
+ name: "ترانه",
+ },
+ title: null,
+ city: null,
+ },
+ {
+ id: 1,
+ user: {
+ id: 100,
+ name: "شادی هراتی",
+ },
+ title: "معاضدتی",
+ city: "گلستان",
+ },
+];
+
+mockAxios.onGet(`${BASE_API_ROUTE}Lawyer/GetAll`).reply(200, {
+ data: mockLawyers,
+});
+
+describe('App component', () => {
+ it('renders the App component with lawyer information and advertising', async () => {
+ await act(async () => {
+ render(
+
+
+
+ );
+ });
+
+ await waitFor(() => expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument());
+
+ expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : "وکیل"}`)).toBeInTheDocument();
+ expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : "نامشخص"}`)).toBeInTheDocument();
+
+ expect(screen.getByText(mockLawyers[1].user.name)).toBeInTheDocument();
+ expect(screen.getByText(`عنوان: ${mockLawyers[1].title ? mockLawyers[1].title : "وکیل"}`)).toBeInTheDocument();
+ expect(screen.getByText(`شهر: ${mockLawyers[1].city ? mockLawyers[1].city : "نامشخص"}`)).toBeInTheDocument();
+ });
+
+ it('navigates to Lawyer-search-page when "جست و جوی وکلا" button is clicked', async () => {
+ const { getByText } = render(
+
+
+
+ );
+
+ await act(async () => {
+ fireEvent.click(getByText('جست و جوی وکلا'));
+ });
+
+ await waitFor(() => expect(window.location.pathname).toBe('/Lawyer-search-page'));
+ });
});
diff --git a/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx b/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx
index fcfc1ddf5..6521bf0bb 100644
--- a/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx
+++ b/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx
@@ -1,15 +1,33 @@
import React from 'react';
-import { render, screen } from '@testing-library/react';
+import { render, screen, act, fireEvent } from '@testing-library/react';
import { BrowserRouter as Router } from 'react-router-dom';
import Advertising from '../Avertising';
-const mockLawyer = {
- // your mock lawyer data here
-};
-
-const mockLawyers = [mockLawyer];
+const mockLawyers = [
+ {
+ id: 1,
+ user: { name: 'John Doe' },
+ title: 'Senior Lawyer',
+ licenseNumber: 'ABC123',
+ aboutMe: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
+ profileImageUrl: 'mock_image_url',
+ rating: 4,
+ },
+ // Add more mock lawyers as needed
+];
describe('Advertising component', () => {
+ it('displays loading state initially', async () => {
+ render(
+
+
+
+ );
+
+ expect(screen.getByRole('progressbar')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /بیشتر/i })).not.toBeInTheDocument();
+ });
+
it('displays lawyer information when data is loaded', async () => {
render(
@@ -17,8 +35,92 @@ describe('Advertising component', () => {
);
+ await screen.findByText(mockLawyers[0].user.name); // Wait for the data to be loaded
+
+ // Assertions for LawyerCard component
+ expect(screen.getByAltText(mockLawyers[0].user.name)).toBeInTheDocument();
+ expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument();
+ expect(screen.getByText(`عنوان: ${mockLawyers[0].title}`)).toBeInTheDocument();
+ expect(screen.getByText(`شماره پرونده وکالت: ${mockLawyers[0].licenseNumber}`)).toBeInTheDocument();
+ expect(screen.getByText(`توضیحات: ${mockLawyers[0].aboutMe.split(' ').slice(0, 30).join(' ')}...`)).toBeInTheDocument();
+ expect(screen.getByRole('link', { name: /بیشتر/i })).toHaveAttribute('href', `/LawyerPage/${mockLawyers[0].id}`);
+ expect(screen.getByLabelText('Rated')).toHaveValue(mockLawyers[0].rating);
+ });
+
+ it('cycles through lawyers with button clicks', async () => {
+ render(
+
+
+
+ );
+
+ await screen.findByText(mockLawyers[0].user.name); // Wait for the data to be loaded
+
+ // Initial display
expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument();
- expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : "وکیل"}`)).toBeInTheDocument();
- expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : "نامشخص"}`)).toBeInTheDocument();
+ expect(screen.getByText(mockLawyers[0].title)).toBeInTheDocument();
+
+ // Click next button
+ fireEvent.click(screen.getByRole('button', { name: /•/ }));
+ await screen.findByText(mockLawyers[1].user.name);
+
+ // Check if the next lawyer is displayed
+ expect(screen.getByText(mockLawyers[1].user.name)).toBeInTheDocument();
+ expect(screen.getByText(mockLawyers[1].title)).toBeInTheDocument();
+
+ // Click previous button
+ fireEvent.click(screen.getByRole('button', { name: /•/ }));
+ await screen.findByText(mockLawyers[0].user.name);
+
+ // Check if it cycles back to the initial lawyer
+ expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument();
+ expect(screen.getByText(mockLawyers[0].title)).toBeInTheDocument();
});
});
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// import React from 'react';
+// import { render, screen } from '@testing-library/react';
+// import { BrowserRouter as Router } from 'react-router-dom';
+// import Advertising from '../Avertising';
+
+// const mockLawyer = {
+// // your mock lawyer data here
+// };
+
+// const mockLawyers = [mockLawyer];
+
+// describe('Advertising component', () => {
+// it('displays lawyer information when data is loaded', async () => {
+// render(
+//
+//
+//
+// );
+
+// expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument();
+// expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : "وکیل"}`)).toBeInTheDocument();
+// expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : "نامشخص"}`)).toBeInTheDocument();
+// });
+// });
diff --git a/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx b/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx
new file mode 100644
index 000000000..6d8bb49e2
--- /dev/null
+++ b/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx
@@ -0,0 +1,38 @@
+import React from 'react';
+import { shallow } from 'enzyme';
+import MovingBarComponent from './MovingBarComponent';
+
+describe('MovingBarComponent', () => {
+ it('renders without crashing', () => {
+ shallow( );
+ });
+
+ it('changes background color every 2 seconds', () => {
+ jest.useFakeTimers();
+
+ const wrapper = shallow( );
+ const instance = wrapper.instance();
+
+ // Initial background color
+ const initialBackgroundColor = wrapper.find('.movingBar').prop('style').backgroundColor;
+
+ // Trigger the useEffect function
+ jest.runOnlyPendingTimers();
+
+ // Check if the background color changes after 2 seconds
+ jest.advanceTimersByTime(2000);
+ const updatedBackgroundColor = wrapper.find('.movingBar').prop('style').backgroundColor;
+
+ expect(updatedBackgroundColor).not.toBe(initialBackgroundColor);
+
+ jest.useRealTimers();
+ });
+
+ it('navigates to the specified page when clicked', () => {
+ const mockLocationHref = jest.spyOn(window.location, 'href', 'set');
+ const wrapper = shallow( );
+
+ wrapper.find('.container').simulate('click');
+ expect(mockLocationHref).toHaveBeenCalledWith('/PremiumLawyers');
+ });
+});
From c97fb133c81ff028fc8684db2a5b3c430e3606fd Mon Sep 17 00:00:00 2001
From: Amirreza vishteh <74289878+amirrezavishteh@users.noreply.github.com>
Date: Thu, 30 Nov 2023 19:23:26 +0330
Subject: [PATCH 3/6] fix : tests
---
.../test/MovingBarComponent.test.jsx | 113 ++++++++++++++----
.../premium-page/test/PremiumLawyers.test.jsx | 45 +++++++
2 files changed, 135 insertions(+), 23 deletions(-)
create mode 100644 vakilpors-front/src/components/premium-page/test/PremiumLawyers.test.jsx
diff --git a/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx b/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx
index 6d8bb49e2..c7455a39f 100644
--- a/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx
+++ b/vakilpors-front/src/components/premium-page/test/MovingBarComponent.test.jsx
@@ -1,38 +1,105 @@
+// Import Enzyme and Jest
+import { shallow, mount } from 'enzyme';
import React from 'react';
-import { shallow } from 'enzyme';
-import MovingBarComponent from './MovingBarComponent';
+import '@testing-library/jest-dom/extend-expect';
-describe('MovingBarComponent', () => {
- it('renders without crashing', () => {
- shallow( );
- });
+// Import the component to be tested
+import MovingBarComponent from '../MovingBarComponent;';
- it('changes background color every 2 seconds', () => {
- jest.useFakeTimers();
+// Write a test suite for the component
+describe('MovingBarComponent', () => {
+ // Write a test case for rendering the component
+ test('renders the component with the given text', () => {
+ // Render the component with shallow rendering
+ const wrapper = shallow( );
- const wrapper = shallow( );
- const instance = wrapper.instance();
+ // Assert that the text is present in the component
+ expect(wrapper.find('.custom-text').text()).toBe('This is a test ');
+ });
- // Initial background color
- const initialBackgroundColor = wrapper.find('.movingBar').prop('style').backgroundColor;
+ // Write a test case for changing the background color
+ test('changes the background color every 2 seconds', () => {
+ // Render the component with full DOM rendering
+ const wrapper = mount( );
- // Trigger the useEffect function
- jest.runOnlyPendingTimers();
+ // Get the initial background color
+ const initialColor = wrapper.find('.custom-price').prop('style').backgroundColor;
- // Check if the background color changes after 2 seconds
+ // Wait for 2 seconds
jest.advanceTimersByTime(2000);
- const updatedBackgroundColor = wrapper.find('.movingBar').prop('style').backgroundColor;
- expect(updatedBackgroundColor).not.toBe(initialBackgroundColor);
+ // Get the updated background color
+ const updatedColor = wrapper.find('.custom-price').prop('style').backgroundColor;
- jest.useRealTimers();
+ // Assert that the background color has changed
+ expect(updatedColor).not.toBe(initialColor);
});
- it('navigates to the specified page when clicked', () => {
- const mockLocationHref = jest.spyOn(window.location, 'href', 'set');
- const wrapper = shallow( );
+ // Write a test case for navigating to another page
+ test('navigates to the PremiumLawyers page when clicked', () => {
+ // Render the component with shallow rendering
+ const wrapper = shallow( );
- wrapper.find('.container').simulate('click');
- expect(mockLocationHref).toHaveBeenCalledWith('/PremiumLawyers');
+ // Mock the window.location.href property
+ Object.defineProperty(window, 'location', {
+ value: {
+ href: '',
+ },
+ writable: true,
+ });
+
+ // Simulate a click on the component
+ wrapper.find('.custom-container').simulate('click');
+
+ // Assert that the window.location.href has changed to the PremiumLawyers page
+ expect(window.location.href).toBe('/PremiumLawyers');
});
});
+
+
+
+
+
+
+
+
+
+
+// import React from 'react';
+// import { shallow } from 'enzyme';
+// import MovingBarComponent from '../MovingBarComponent;';
+
+// describe('MovingBarComponent', () => {
+// it('renders without crashing', () => {
+// shallow( );
+// });
+
+// it('changes background color every 2 seconds', () => {
+// jest.useFakeTimers();
+
+// const wrapper = shallow( );
+// const instance = wrapper.instance();
+
+// // Initial background color
+// const initialBackgroundColor = wrapper.find('.movingBar').prop('style').backgroundColor;
+
+// // Trigger the useEffect function
+// jest.runOnlyPendingTimers();
+
+// // Check if the background color changes after 2 seconds
+// jest.advanceTimersByTime(2000);
+// const updatedBackgroundColor = wrapper.find('.movingBar').prop('style').backgroundColor;
+
+// expect(updatedBackgroundColor).not.toBe(initialBackgroundColor);
+
+// jest.useRealTimers();
+// });
+
+// it('navigates to the specified page when clicked', () => {
+// const mockLocationHref = jest.spyOn(window.location, 'href', 'set');
+// const wrapper = shallow( );
+
+// wrapper.find('.container').simulate('click');
+// expect(mockLocationHref).toHaveBeenCalledWith('/PremiumLawyers');
+// });
+// });
diff --git a/vakilpors-front/src/components/premium-page/test/PremiumLawyers.test.jsx b/vakilpors-front/src/components/premium-page/test/PremiumLawyers.test.jsx
new file mode 100644
index 000000000..17bbb140e
--- /dev/null
+++ b/vakilpors-front/src/components/premium-page/test/PremiumLawyers.test.jsx
@@ -0,0 +1,45 @@
+// Import React Testing Library and Jest
+import { render, screen, fireEvent } from '@testing-library/react';
+import '@testing-library/jest-dom/extend-expect';
+import React from 'react';
+
+// Import the component to be tested
+import PremiumLawyers from '../PremiumLawyers';
+
+// Write a test suite for the component
+describe('PremiumLawyers component', () => {
+ // Write a test case for rendering the component
+ test('renders the component with header and plans', () => {
+ // Render the component
+ render( );
+
+ // Assert that the header elements are present
+ expect(screen.getByText('رشد کسب و کار خود را با تبلیغات هدفمند آنلاین افزایش دهید')).toBeInTheDocument();
+ expect(screen.getByText('بین برنامه های روزانه یا هفتگی انتخاب کنید تا با مشتریان جدید ارتباط برقرار کنید.')).toBeInTheDocument();
+
+ // Assert that the plan cards are present
+ expect(screen.getByText('برنامه روزانه')).toBeInTheDocument();
+ expect(screen.getByText('برنامه هفتگی')).toBeInTheDocument();
+
+ // Assert that the plan features are present
+ expect(screen.getByText('قرار دادن لیست ویژه')).toBeInTheDocument();
+ expect(screen.getByText('نمایش تبلیغات در صفحات با ترافیک بالا')).toBeInTheDocument();
+ expect(screen.getByText('گزارش تحلیلی از کلیک ها و تاثیرات')).toBeInTheDocument();
+ expect(screen.getByText('خلاقیت های سفارشی برای تبلیغات موثر')).toBeInTheDocument();
+ });
+
+ // Write a test case for selecting a plan
+ test('selects a plan and shows a confirmation message', () => {
+ // Render the component
+ render( );
+
+ // Find the button for the daily plan
+ const dailyPlanButton = screen.getByText('انتخاب', { selector: 'button' });
+
+ // Click the button
+ fireEvent.click(dailyPlanButton);
+
+ // Assert that a confirmation message is shown
+ expect(screen.getByText('شما برنامه روزانه را انتخاب کرده اید. لطفا اطلاعات پرداخت خود را وارد کنید.')).toBeInTheDocument();
+ });
+});
From baeb3fdcaa2c6fb95b4f01e634a32ae12839ea94 Mon Sep 17 00:00:00 2001
From: Amirreza vishteh <74289878+amirrezavishteh@users.noreply.github.com>
Date: Thu, 30 Nov 2023 19:28:58 +0330
Subject: [PATCH 4/6] add:test
---
vakilpors-front/src/App.test.js | 59 +-
.../src/components/authentication/Login.jsx | 434 +++++----
.../src/components/case-pages/ShowCases.jsx | 545 ++++++++---
.../src/components/case-pages/addNewCase.jsx | 879 +++++++++++++-----
.../components/premium-page/PremiumPage.jsx | 6 +-
.../premium-page/test/Avertising.test.jsx | 47 -
.../src/components/profile/Lawyer_Jobinfo.jsx | 277 +++++-
vakilpors-front/src/images/background.jpg | Bin 0 -> 78875 bytes
8 files changed, 1611 insertions(+), 636 deletions(-)
create mode 100644 vakilpors-front/src/images/background.jpg
diff --git a/vakilpors-front/src/App.test.js b/vakilpors-front/src/App.test.js
index d0c0d4f5c..9c15a15f7 100644
--- a/vakilpors-front/src/App.test.js
+++ b/vakilpors-front/src/App.test.js
@@ -1,9 +1,10 @@
import React from 'react';
-import { render, screen, waitFor, act, fireEvent } from '@testing-library/react';
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { BrowserRouter as Router } from 'react-router-dom';
-import App, { BASE_API_ROUTE } from './App';
+import App from './App';
const mockAxios = new MockAdapter(axios);
@@ -33,36 +34,38 @@ mockAxios.onGet(`${BASE_API_ROUTE}Lawyer/GetAll`).reply(200, {
});
describe('App component', () => {
- it('renders the App component with lawyer information and advertising', async () => {
- await act(async () => {
- render(
-
-
-
- );
- });
+ it('renders learn react link', () => {
+ render( );
+ const linkElement = screen.getByText(/learn react/i);
+ expect(linkElement).toBeInTheDocument();
+ });
- await waitFor(() => expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument());
+ it('renders the App component with lawyer information and advertising', async () => {
+ render(
+
+
+
+ );
- expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : "وکیل"}`)).toBeInTheDocument();
- expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : "نامشخص"}`)).toBeInTheDocument();
+ await waitFor(() => expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument());
- expect(screen.getByText(mockLawyers[1].user.name)).toBeInTheDocument();
- expect(screen.getByText(`عنوان: ${mockLawyers[1].title ? mockLawyers[1].title : "وکیل"}`)).toBeInTheDocument();
- expect(screen.getByText(`شهر: ${mockLawyers[1].city ? mockLawyers[1].city : "نامشخص"}`)).toBeInTheDocument();
- });
+ expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : "وکیل"}`)).toBeInTheDocument();
+ expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : "نامشخص"}`)).toBeInTheDocument();
- it('navigates to Lawyer-search-page when "جست و جوی وکلا" button is clicked', async () => {
- const { getByText } = render(
-
-
-
- );
+ expect(screen.getByText(mockLawyers[1].user.name)).toBeInTheDocument();
+ expect(screen.getByText(`عنوان: ${mockLawyers[1].title ? mockLawyers[1].title : "وکیل"}`)).toBeInTheDocument();
+ expect(screen.getByText(`شهر: ${mockLawyers[1].city ? mockLawyers[1].city : "نامشخص"}`)).toBeInTheDocument();
+ });
- await act(async () => {
- fireEvent.click(getByText('جست و جوی وکلا'));
- });
+ it('navigates to Lawyer-search-page when "جست و جوی وکلا" button is clicked', async () => {
+ const { getByText } = render(
+
+
+
+ );
- await waitFor(() => expect(window.location.pathname).toBe('/Lawyer-search-page'));
- });
+ userEvent.click(getByText('جست و جوی وکلا'));
+
+ await waitFor(() => expect(window.location.pathname).toBe('/Lawyer-search-page'));
+ });
});
diff --git a/vakilpors-front/src/components/authentication/Login.jsx b/vakilpors-front/src/components/authentication/Login.jsx
index 2b191f117..07837d22d 100644
--- a/vakilpors-front/src/components/authentication/Login.jsx
+++ b/vakilpors-front/src/components/authentication/Login.jsx
@@ -1,200 +1,294 @@
import React, { useState, useEffect } from "react";
import { Link, useNavigate } from "react-router-dom";
-import { Helmet } from 'react-helmet-async';
-import { Grid, TextField, Typography, Slide, Button, InputAdornment, IconButton } from '@mui/material';
-import { CastForEducation, Visibility, VisibilityOff } from "@mui/icons-material";
-import { toast } from 'react-toastify';
+import { Helmet } from "react-helmet-async";
+import {
+ Grid,
+ TextField,
+ Typography,
+ Slide,
+ Button,
+ InputAdornment,
+ IconButton,
+} from "@mui/material";
+import {
+ CastForEducation,
+ Visibility,
+ VisibilityOff,
+} from "@mui/icons-material";
+import { toast } from "react-toastify";
import { useAuth } from "../../context/AuthProvider";
-import lawOnline from '../../assests/images/law-online.jpg';
+import lawOnline from "../../assests/images/law-online.jpg";
import StyledButton from "../ButtonComponent";
+import ReactLoading from "react-loading";
// mui rtl
-import rtlPlugin from 'stylis-plugin-rtl';
-import { CacheProvider } from '@emotion/react';
-import createCache from '@emotion/cache';
-import { createTheme } from '@mui/material/styles';
-import { ThemeProvider } from '@mui/material/styles';
+import rtlPlugin from "stylis-plugin-rtl";
+import { CacheProvider } from "@emotion/react";
+import createCache from "@emotion/cache";
+import { createTheme } from "@mui/material/styles";
+import { ThemeProvider } from "@mui/material/styles";
const cacheRtl = createCache({
- key: 'muirtl',
- stylisPlugins: [rtlPlugin],
- typography: {
- fontFamily: 'shabnam',
- },
+ key: "muirtl",
+ stylisPlugins: [rtlPlugin],
+ typography: {
+ fontFamily: "shabnam",
+ },
});
const theme = createTheme({
- direction: 'rtl',
+ direction: "rtl",
});
// mui rtl
const Login = () => {
-
- const [password, setPassword] = useState('');
- const [phoneNumber, setPhoneNumber] = useState('');
- const [show, setShow] = useState(false);
- const [showPassword, setShowPassword] = useState(false);
- const handleClickShowPassword = () => setShowPassword(!showPassword);
- const handleMouseDownPassword = () => setShowPassword(!showPassword);
+ const [password, setPassword] = useState("");
+ const [phoneNumber, setPhoneNumber] = useState("");
+ const [show, setShow] = useState(false);
+ const [showPassword, setShowPassword] = useState(false);
+ const handleClickShowPassword = () => setShowPassword(!showPassword);
+ const handleMouseDownPassword = () => setShowPassword(!showPassword);
+ const [loading, setloading] = useState(false);
- useEffect(() => {
- setShow(true);
- }, []);
+ useEffect(() => {
+ setShow(true);
+ }, []);
- const showErrorMessage = (errorMessage) => {
- toast.error(errorMessage, {
- position: "bottom-right",
- autoClose: 5000,
- hideProgressBar: false,
- closeOnClick: true,
- pauseOnHover: true,
- draggable: true,
- progress: undefined,
- theme: "light",
- rtl:true,
- });
- };
- const showSuccesMessage = (payam) => {
- toast.success(payam, {
- position: "bottom-right",
- autoClose: 3000,
- hideProgressBar: false,
- closeOnClick: true,
- pauseOnHover: true,
- draggable: true,
- progress: undefined,
- theme: "light",
- rtl:true,
- });
- };
+ const showErrorMessage = (errorMessage) => {
+ toast.error(errorMessage, {
+ position: "bottom-right",
+ autoClose: 5000,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ theme: "light",
+ rtl: true,
+ });
+ };
+ const showSuccesMessage = (payam) => {
+ toast.success(payam, {
+ position: "bottom-right",
+ autoClose: 3000,
+ hideProgressBar: false,
+ closeOnClick: true,
+ pauseOnHover: true,
+ draggable: true,
+ progress: undefined,
+ theme: "light",
+ rtl: true,
+ });
+ };
- const { login } = useAuth();
+ const { login } = useAuth();
- const navigate = useNavigate();
+ const navigate = useNavigate();
- const handleLoginClick = async (event) => {
- event.preventDefault();
- if (phoneNumber === '' || password === '') {
- showErrorMessage("لطفا شماره موبایل و رمز عبور را وارد کنید.");
- return;
- }
- else {
- const success = await login(phoneNumber, password);
- if(success === "success"){
- showSuccesMessage("با موفقیت وارد شدید.");
- await delay(3000);
- navigate("/");
- }
- else{
- showErrorMessage("ورود با خطا مواجه شد.");
- }
- }
- };
+ const handleLoginClick = async (event) => {
+ event.preventDefault();
+ if (phoneNumber === "" || password === "") {
+ showErrorMessage("لطفا شماره موبایل و رمز عبور را وارد کنید.");
+ return;
+ } else {
+ setloading(true);
+ const success = await login(phoneNumber, password);
+ if (success === "success") {
+ setloading(false);
+ showSuccesMessage("با موفقیت وارد شدید.");
+ await delay(3000);
+ navigate("/");
+ } else {
+ setloading(false);
+ showErrorMessage("ورود با خطا مواجه شد.");
+ }
+ }
+ };
- const delay = ms => new Promise(
- resolve => setTimeout(resolve, ms)
- );
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
- return (
- <>
-
- ورود
-
-
+ return (
+ <>
+
+ ورود
+
+
-
-
-
-
- به وکیل پرس خوش آمدید!
-
-
-
- setPhoneNumber(e.target.value)}
- variant="outlined"
- inputProps={{ dir: "rtl", style: { fontFamily:"shabnam", fontSize: "17px",color:"black",} }}
- InputLabelProps={{ align: "right", dir: "rtl", style: { fontFamily:"shabnam", fontSize: "17px",color:"black",} }}
- sx={{
- width: {xs:'100%',sm:'80%'},
- padding: 0,
- backgroundColor: 'rgba(255,255,255,0.5)',
- mb: '10px',
- borderRadius:"5px",
- }}/>
-
-
- setPassword(e.target.value)}
- variant="outlined"
- InputProps={{ dir: "rtl", style: { fontFamily:"shabnam", fontSize: "17px",color:"black",},
- endAdornment: (
-
-
- {showPassword ? : }
-
-
- )
- }}
- InputLabelProps={{ align: "right", dir: "rtl", style: { fontFamily:"shabnam", fontSize: "17px",color:"black",} }}
- sx={{
- width: {xs:'100%',sm:'80%'},
- padding: 0,
- backgroundColor: 'rgba(255,255,255,0.5)',
- borderRadius:"5px",
- }}/>
-
-
-
- {/*
+ justifyContent: "center",
+ height: "100vh",
+ backgroundImage: `url(${lawOnline})`,
+ backgroundRepeat: "no-repeat",
+ backgroundSize: "cover",
+ backgroundPosition: "center",
+ }}
+ >
+
+
+
+
+ به وکیل پرس خوش آمدید!
+
+
+
+
+ setPhoneNumber(e.target.value)}
+ variant="outlined"
+ inputProps={{
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "17px",
+ color: "black",
+ },
+ }}
+ InputLabelProps={{
+ align: "right",
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "17px",
+ color: "black",
+ },
+ }}
+ sx={{
+ width: { xs: "100%", sm: "80%" },
+ padding: 0,
+ backgroundColor: "rgba(255,255,255,0.5)",
+ mb: "10px",
+ borderRadius: "5px",
+ }}
+ />
+
+
+ setPassword(e.target.value)}
+ variant="outlined"
+ InputProps={{
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "17px",
+ color: "black",
+ },
+ endAdornment: (
+
+
+ {showPassword ? : }
+
+
+ ),
+ }}
+ InputLabelProps={{
+ align: "right",
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "17px",
+ color: "black",
+ },
+ }}
+ sx={{
+ width: { xs: "100%", sm: "80%" },
+ padding: 0,
+ backgroundColor: "rgba(255,255,255,0.5)",
+ borderRadius: "5px",
+ }}
+ />
+
+
+
+ {/*
ورود
*/}
-
- ورود
-
-
-
-
-
-
- اکانت ندارید؟ ثبت نام کنید!
-
-
- فراموشی رمز عبور
-
-
-
+
+ {!loading && (
+ ورورد
+ )}
+ {loading && (
+
+
+
+ )}
+
+
+
+
+
+
+ اکانت ندارید؟ ثبت نام کنید!
+
+
+ فراموشی رمز عبور
+
+
+
-
+
-
- >
- );
-}
+
+ >
+ );
+};
-export default Login;
\ No newline at end of file
+export default Login;
diff --git a/vakilpors-front/src/components/case-pages/ShowCases.jsx b/vakilpors-front/src/components/case-pages/ShowCases.jsx
index bdf04e685..9cc24f664 100644
--- a/vakilpors-front/src/components/case-pages/ShowCases.jsx
+++ b/vakilpors-front/src/components/case-pages/ShowCases.jsx
@@ -1,39 +1,95 @@
import React, { useEffect, useState } from "react";
-import { Helmet } from 'react-helmet-async';
+import { Helmet } from "react-helmet-async";
import { useNavigate } from "react-router-dom";
import { useParams } from "react-router-dom";
-import useStateRef from 'react-usestateref';
+import useStateRef from "react-usestateref";
import { useAuth } from "../../context/AuthProvider";
import { BASE_API_ROUTE } from "../../Constants";
import axios from "axios";
-import jwt from 'jwt-decode';
-import { Box, Grid, Button, Typography, Card, CardActions, CardContent, IconButton, styled } from '@mui/material';
-import Tooltip, { tooltipClasses } from '@mui/material/Tooltip';
-import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material';
-import { DownloadForOfflineOutlined, } from '@mui/icons-material';
-import { toast } from 'react-toastify';
-
-const HtmlTooltip = styled (({ className, ...props }) => (
-
+import jwt from "jwt-decode";
+import {
+ Box,
+ Grid,
+ Button,
+ Typography,
+ Card,
+ CardActions,
+ CardContent,
+ IconButton,
+ styled,
+} from "@mui/material";
+import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
+import {
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogContentText,
+ DialogTitle,
+} from "@mui/material";
+import { DownloadForOfflineOutlined } from "@mui/icons-material";
+import { toast } from "react-toastify";
+import {
+ Audio,
+ BallTriangle,
+ Bars,
+ Circles,
+ Hearts,
+ Oval,
+ Puff,
+ Rings,
+ SpinningCircles,
+ TailSpin,
+ ThreeDots,
+} from "@agney/react-loading";
+import backgroun from "../../images/background.jpg";
+import { CacheProvider } from "@emotion/react";
+import createCache from "@emotion/cache";
+import { createTheme } from "@mui/material/styles";
+import rtlPlugin from "stylis-plugin-rtl";
+import { ThemeProvider } from "@mui/material/styles";
+import AddIcon from "@mui/icons-material/Add";
+
+const cacheRtl = createCache({
+ key: "muirtl",
+ stylisPlugins: [rtlPlugin],
+});
+const theme = createTheme({
+ typography: {
+ fontFamily: "shabnam",
+ },
+ direction: "rtl",
+});
+
+const HtmlTooltip = styled(({ className, ...props }) => (
+
))(({ theme }) => ({
[`& .${tooltipClasses.tooltip}`]: {
- backgroundColor: '#f5f5f9',
- color: 'rgba(0, 0, 0, 0.87)',
+ backgroundColor: "#f5f5f9",
+ color: "rgba(0, 0, 0, 0.87)",
maxWidth: 300,
- fontSize: '15px',
- border: '1px solid #dadde9',
- fontFamily: 'shabnam',
+ fontSize: "15px",
+ border: "1px solid #dadde9",
+ fontFamily: "shabnam",
},
}));
-
-const ShowCases = () => {
+const ShowCases = () => {
const [Cases, setCases, refCases] = useStateRef([]);
const [openDescription, setOpenDescription] = useState(false);
- const [description, setDescription] = useState('');
+ const [description, setDescription] = useState("");
const { getAccessToken } = useAuth();
const navigate = useNavigate();
+ const [loading, setloading] = useState(false);
const { isLawyer } = useParams();
+ const [openDialog, setOpenDialog] = useState(false);
+
+ const handleClickDelete = () => {
+ setOpenDialog(true);
+ };
+
+ const handleCloseDialog = () => {
+ setOpenDialog(false);
+ };
const handleOpenDescription = (des) => {
setOpenDescription(true);
@@ -46,29 +102,43 @@ const ShowCases = () => {
const getLawyersThatHaveAccessToDoc = async (docId) => {
const token = await getAccessToken();
- if(token){
- const url = BASE_API_ROUTE + `Document/GetLawyersThatHaveAccessToDocument?documentId=${docId}`;
+ if (token) {
+ const url =
+ BASE_API_ROUTE +
+ `Document/GetLawyersThatHaveAccessToDocument?documentId=${docId}`;
try {
- const response = await axios.get(url, {headers: {Authorization: `Bearer ${token}`}});
+ const response = await axios.get(url, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
// console.log('response in getLawyersThatHaveAccessToDoc : ',response);
return response.data.data;
} catch (error) {
- console.log('error in getLawyersThatHaveAccessToDoc : ',error);
+ console.log("error in getLawyersThatHaveAccessToDoc : ", error);
}
}
};
const getCases = async () => {
const token = await getAccessToken();
- if(token){
+ if (token) {
+ setloading(true);
const tokenData = jwt(token);
- const url = BASE_API_ROUTE + ( isLawyer.split('_')[0] == 'true' ? `Document/GetDocumentsThatLawyerHasAccessToByUserId` : `Document/GetDocumentsByUserId?userId=${tokenData.uid}`);
+ const url =
+ BASE_API_ROUTE +
+ (isLawyer.split("_")[0] == "true"
+ ? `Document/GetDocumentsThatLawyerHasAccessToByUserId`
+ : `Document/GetDocumentsByUserId?userId=${tokenData.uid}`);
const Data = {
- "userId": isLawyer.split('_')[1],
- "lawyerId": isLawyer.split('_')[2]
- }
+ userId: isLawyer.split("_")[1],
+ lawyerId: isLawyer.split("_")[2],
+ };
try {
- const response = await (isLawyer.split('_')[0] == 'true' ? axios.post(url, Data, {headers: {Authorization: `Bearer ${token}`}}) : axios.get(url,{headers: {Authorization: `Bearer ${token}`}}));
+ const response = await (isLawyer.split("_")[0] == "true"
+ ? axios.post(url, Data, {
+ headers: { Authorization: `Bearer ${token}` },
+ })
+ : axios.get(url, { headers: { Authorization: `Bearer ${token}` } }));
+ setloading(false);
setCases(response.data.data);
// response.data.data.map(async (casei) => {
// const lawyers = await getLawyersThatHaveAccessToDoc(casei.id);
@@ -77,11 +147,12 @@ const ShowCases = () => {
// });
// console.log('response in getDocument : ',response);
} catch (error) {
- console.log('error in getDocument : ',error);
+ setloading(false);
+ console.log("error in getDocument : ", error);
}
}
};
-
+
useEffect(() => {
getCases();
}, []);
@@ -96,7 +167,7 @@ const ShowCases = () => {
draggable: true,
progress: undefined,
theme: "light",
- rtl:true,
+ rtl: true,
});
};
const showSuccesMessage = (payam) => {
@@ -109,43 +180,51 @@ const ShowCases = () => {
draggable: true,
progress: undefined,
theme: "light",
- rtl:true,
+ rtl: true,
});
};
const handleChooseCase = async (docId) => {
const token = await getAccessToken();
- if(token){
- const url = BASE_API_ROUTE + 'Document/GrantAccessToLawyer';
+ if (token) {
+ const url = BASE_API_ROUTE + "Document/GrantAccessToLawyer";
const data = {
- "lawyerId": isLawyer.split('_')[1], // or number
- "documentId": docId,
- }
+ lawyerId: isLawyer.split("_")[1], // or number
+ documentId: docId,
+ };
try {
- const response = await axios.post(url, data, {headers: {Authorization: `Bearer ${token}`}});
+ const response = await axios.post(url, data, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
// console.log('response in GrantAccessToLawyer : ',response);
- showSuccesMessage('پرونده مورد نظر با موفقیت برای وکیل مورد نظر ارسال شد.');
+ showSuccesMessage(
+ "پرونده مورد نظر با موفقیت برای وکیل مورد نظر ارسال شد."
+ );
} catch (error) {
- console.log('error in GrantAccessToLawyer : ',error);
- showErrorMessage('خطا در ارسال پرونده');
+ console.log("error in GrantAccessToLawyer : ", error);
+ showErrorMessage("خطا در ارسال پرونده");
}
}
};
const handleDeleteCase = async (docId) => {
const token = await getAccessToken();
- if(token){
- const url = BASE_API_ROUTE + `Document/DeleteDocument?documentId=${docId}`;
+ if (token) {
+ const url =
+ BASE_API_ROUTE + `Document/DeleteDocument?documentId=${docId}`;
try {
- const response = await axios.get(url, {headers: {Authorization: `Bearer ${token}`}});
+ const response = await axios.get(url, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
// console.log('response in deleting case : ',response);
getCases();
- showSuccesMessage('پرونده مورد نظر با موفقیت حذف شد.');
+ showSuccesMessage("پرونده مورد نظر با موفقیت حذف شد.");
} catch (error) {
- console.log('error in deleting case : ',error);
- showErrorMessage('خطا در حذف پرونده');
+ console.log("error in deleting case : ", error);
+ showErrorMessage("خطا در حذف پرونده");
}
}
+ setOpenDialog(false)
};
const showLawyersThatHaveAccessToDoc = (docId) => {
@@ -153,103 +232,293 @@ const ShowCases = () => {
};
const card = (casei) => {
- return (
-
-
-
- عنوان : {casei.title}
-
-
- نام : {casei.caseName}
-
-
- گروه : {casei.documentCategory}
-
-
- حداقل بودجه : {casei.minimumBudget} تومان
-
- حداکثر بودجه : {casei.maximumBudget} تومان
-
- handleOpenDescription(casei.description)}>
-
- توضیحات : {casei.description}
+ return (
+
+
+
+
+
+
+ عنوان : {casei.title}
-
-
-
-
-
- {'دانلود فایل'}
-
-
-
- {showLawyersThatHaveAccessToDoc(casei.id)}
-
- {isLawyer == 'false' &&
-
- navigate(`/new-case/edit_${casei.id}`)} sx={{fontFamily: "shabnam", mb:1}} size="small">ویرایش
- handleDeleteCase(casei.id)} sx={{fontFamily: "shabnam", mb:1}} size="small">حذف
-
- }
- {isLawyer.split('_')[0] == 'choose' &&
-
- handleChooseCase(casei.id)} sx={{fontFamily: "shabnam", mb:1, width:'100%'}} size="large">ارسال
-
- }
-
+
+ نام : {casei.caseName}
+
+
+ گروه : {casei.documentCategory}
+
+
+ حداقل بودجه : {casei.minimumBudget} تومان
+
+ حداکثر بودجه : {casei.maximumBudget} تومان
+
+ {/* handleOpenDescription(casei.description)}
+ >
+
+ توضیحات : {casei.description}
+
+ */}
+ {isLawyer !== "false" && (
+
+
+
+
+
+ {"دانلود فایل"}
+
+
+
+
+ )}
+ {showLawyersThatHaveAccessToDoc(casei.id)}
+
+ {isLawyer === "false" && (
+
+
navigate(`/new-case/edit_${casei.id}`)}
+ sx={{ fontFamily: "shabnam" }}
+ size="small"
+ variant="contained"
+ >
+ ویرایش
+
+
+ حذف
+
+
+
+
+ آیا از حذف کردن مطمئنید؟
+
+
+
+ لغو
+ handleDeleteCase(casei.id)} autoFocus>
+ حذف
+
+
+
+
+
+
+ )}
+ {isLawyer.split("_")[0] == "choose" && (
+
+ handleChooseCase(casei.id)}
+ sx={{ fontFamily: "shabnam", mb: 1, width: "100%" }}
+ size="large"
+ >
+ ارسال
+
+
+ )}
+
);
};
-
+
const ClickNewCase = () => {
- navigate('/new-case/add');
+ navigate("/new-case/add");
};
- return(
- <>
-
- پرونده های من
-
-
-
-
-
- {refCases.current.length == 0 ? {isLawyer.split('_')[0] == 'true' ? 'هنوز پرونده ای برای شما ارسال نشده است.' : 'شما هنوز پرونده ای ایجاد نکرده اید.'}
- :
- refCases.current.map((casei) =>
-
- {card(casei)}
+ return (
+ <>
+ {loading && (
+
+
+
+ )}
+ {!loading && (
+ <>
+
+ پرونده های من
+
+
+
+
+
+
+
+ پرونده های من
+
+
+ {isLawyer === "false" && (
+
+ }
+ >
+ پرونده جدید
+
+
+ )}
+
+
+
+
+
+ {refCases.current.length == 0 ? (
+
+ {isLawyer.split("_")[0] == "true"
+ ? "هنوز پرونده ای برای شما ارسال نشده است."
+ : "شما هنوز پرونده ای ایجاد نکرده اید."}
+
+ ) : (
+ refCases.current.map((casei) => (
+
+
+ {card(casei)}
+
+
+ ))
+ )}
+
+
+ {/* {isLawyer == "false" && (
+
+
+ افزودن پرونده
+
- )
- }
+ )} */}
- {isLawyer == 'false' &&
-
- افزودن پرونده
-
- }
-
-
-
-
- متن کامل توضیحات:
-
-
-
- {description}
-
-
-
- بستن
-
-
- >
+
+
+
+ متن کامل توضیحات:
+
+
+
+
+
+ {description}
+
+
+
+
+
+
+ بستن
+
+
+
+
+ >
+ )}
+ >
);
-}
-
-export default ShowCases;
\ No newline at end of file
+};
+export default ShowCases;
diff --git a/vakilpors-front/src/components/case-pages/addNewCase.jsx b/vakilpors-front/src/components/case-pages/addNewCase.jsx
index 3b5f7756a..516b9d959 100644
--- a/vakilpors-front/src/components/case-pages/addNewCase.jsx
+++ b/vakilpors-front/src/components/case-pages/addNewCase.jsx
@@ -1,59 +1,84 @@
import React, { useState, useEffect } from "react";
-import { Helmet } from 'react-helmet-async';
+import { Helmet } from "react-helmet-async";
import { useAuth } from "../../context/AuthProvider";
import { BASE_API_ROUTE } from "../../Constants";
import axios from "axios";
import { useParams } from "react-router-dom";
-import { Typography, Grid, TextField, InputAdornment, IconButton, Box, OutlinedInput, InputLabel, FormControl } from "@mui/material";
-import { toast } from 'react-toastify';
-import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
-import { MuiFileInput } from 'mui-file-input'
-import '../../css/Newcase.css';
+import {
+ Typography,
+ Grid,
+ TextField,
+ InputAdornment,
+ IconButton,
+ Box,
+ OutlinedInput,
+ InputLabel,
+ FormControl,
+} from "@mui/material";
+import { toast } from "react-toastify";
+import Autocomplete, { createFilterOptions } from "@mui/material/Autocomplete";
+import { MuiFileInput } from "mui-file-input";
+import "../../css/Newcase.css";
+import { AddCircleOutline } from "@mui/icons-material";
+import StyledButton from "../ButtonComponent";
+import ReactLoading from "react-loading";
+import { useNavigate } from "react-router-dom";
+import { Button } from "@mui/material";
// mui rtl
-import rtlPlugin from 'stylis-plugin-rtl';
-import { CacheProvider } from '@emotion/react';
-import createCache from '@emotion/cache';
-import { createTheme } from '@mui/material/styles';
-import { ThemeProvider } from '@mui/material/styles';
+import rtlPlugin from "stylis-plugin-rtl";
+import { CacheProvider } from "@emotion/react";
+import createCache from "@emotion/cache";
+import { createTheme } from "@mui/material/styles";
+import { ThemeProvider } from "@mui/material/styles";
const cacheRtl = createCache({
- key: 'muirtl',
- stylisPlugins: [rtlPlugin],
+ key: "muirtl",
+ stylisPlugins: [rtlPlugin],
});
const theme = createTheme({
- direction: 'rtl',
+ typography: {
+ fontFamily: "shabnam",
+ },
+ direction: "rtl",
});
// mui rtl
const filter = createFilterOptions();
const AddNewCase = () => {
-
+ const navigate = useNavigate();
const [DocumentId, setDocumentId] = useState();
- const [isEdit, setisEdit] = useState(false);
- const [Title, setTitle] = useState('');
+ const [isEdit, setisEdit] = useState(false);
+ const [Title, setTitle] = useState("");
const [File, setFile] = useState(null);
- const [FileURL, setFileURL] = useState('');
- const [MinimumBudget, setMinimumBadget] = useState('');
- const [MaximumBudget, setMaximumBadget] = useState('');
- const [Description, setDescription] = useState('');
- const [caseName, setCaseName] = useState('');
- const [DocumentCategory, setDocumentCategory] = useState('');
+ const [FileURL, setFileURL] = useState("");
+ const [MinimumBudget, setMinimumBadget] = useState("");
+ const [MaximumBudget, setMaximumBadget] = useState("");
+ const [Description, setDescription] = useState("");
+ const [caseName, setCaseName] = useState("");
+ const [DocumentCategory, setDocumentCategory] = useState("");
+ const [loading, setloading] = useState(false);
+
const { getAccessToken } = useAuth();
const { func } = useParams();
useEffect(() => {
const getDocData = async () => {
- if(func.split('_')[0] == "edit"){
+ if (func.split("_")[0] == "edit") {
setisEdit(true);
}
- setDocumentId(func.split('_')[1]);
- if(func.split('_')[0] == "edit"){
- const url = BASE_API_ROUTE + `Document/GetDocumentById?documentId=${func.split('_')[1]}`;
+ setDocumentId(func.split("_")[1]);
+ if (func.split("_")[0] == "edit") {
+ const url =
+ BASE_API_ROUTE +
+ `Document/GetDocumentById?documentId=${func.split("_")[1]}`;
const token = await getAccessToken();
- try{
- const response = await axios.get(url, {headers: {Authorization: `Bearer ${token}`}});
+ try {
+ const response = await axios.get(url, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
// console.log("success in Getting Document Data!!! : ",response);
+ console.log(response.data.data);
setTitle(response.data.data.title);
setMinimumBadget(response.data.data.minimumBudget);
setMaximumBadget(response.data.data.maximumBudget);
@@ -61,14 +86,13 @@ const AddNewCase = () => {
setDescription(response.data.data.description);
setDocumentCategory(response.data.data.documentCategory);
setFileURL(response.data.data.fileUrl);
- }
- catch (error) {
- console.log("error in Getting Document Data!!! : ",error);
+ } catch (error) {
+ console.log("error in Getting Document Data!!! : ", error);
}
}
};
getDocData();
- },[]);
+ }, []);
const showErrorMessage = (errorMessage) => {
toast.error(errorMessage, {
@@ -80,7 +104,7 @@ const AddNewCase = () => {
draggable: true,
progress: undefined,
theme: "light",
- rtl:true,
+ rtl: true,
});
};
const showSuccesMessage = (payam) => {
@@ -93,62 +117,66 @@ const AddNewCase = () => {
draggable: true,
progress: undefined,
theme: "light",
- rtl:true,
+ rtl: true,
});
};
const categories = [
- { category: 'ثبت احوال' },
- { category: 'بیمه' },
- { category: 'ملکی' },
- { category: 'مالیات' },
- { category: 'شرکت ها' },
- { category: 'انحصار وراثت' },
- { category: 'دیوان عدالت اداری' },
- { category: 'مالکیت معنوی' },
- { category: 'بین الملل' },
- { category: 'اداره کار' },
- { category: 'جرایم اینترنتی' },
- { category: 'قراردها' },
- { category: 'وصول مطالبات' },
- { category: 'خانواده' },
- { category: 'کیفری (جرائم)' },
- { category: 'اجرای احکام' },
- { category: 'جرایم علیه اشخاص' },
- { category: 'جرایم علیه اموال' },
- { category: 'جرایم علیه امنیت کشور' },
- { category: 'اموال و مالکیت' },
- { category: 'ثبت اسناد' },
- { category: 'داوری' },
- { category: 'سربازی و نظام وظیفه' },
+ { category: "ثبت احوال" },
+ { category: "بیمه" },
+ { category: "ملکی" },
+ { category: "مالیات" },
+ { category: "شرکت ها" },
+ { category: "انحصار وراثت" },
+ { category: "دیوان عدالت اداری" },
+ { category: "مالکیت معنوی" },
+ { category: "بین الملل" },
+ { category: "اداره کار" },
+ { category: "جرایم اینترنتی" },
+ { category: "قراردها" },
+ { category: "وصول مطالبات" },
+ { category: "خانواده" },
+ { category: "کیفری (جرائم)" },
+ { category: "اجرای احکام" },
+ { category: "جرایم علیه اشخاص" },
+ { category: "جرایم علیه اموال" },
+ { category: "جرایم علیه امنیت کشور" },
+ { category: "اموال و مالکیت" },
+ { category: "ثبت اسناد" },
+ { category: "داوری" },
+ { category: "سربازی و نظام وظیفه" },
];
const titles = [
- { title: 'مشاوره حضوری' },
- { title: 'مشاوره تلفنی' },
- { title: 'مشاوره آنلاین' },
- { title: 'وکالت' },
- { title: 'داوری' },
- ]
+ { title: "مشاوره حضوری" },
+ { title: "مشاوره تلفنی" },
+ { title: "مشاوره آنلاین" },
+ { title: "وکالت" },
+ { title: "داوری" },
+ ];
const titleLists = () => {
return (
- {
- if (typeof newValue === 'string') {
- setTitle(newValue)
+ if (typeof newValue === "string") {
+ setTitle(newValue);
} else if (newValue && newValue.inputValue) {
- setTitle(newValue.inputValue)
- } else if(newValue && newValue.title) {
- setTitle(newValue.title)
+ setTitle(newValue.inputValue);
+ } else if (newValue && newValue.title) {
+ setTitle(newValue.title);
}
}}
filterOptions={(options, params) => {
const filtered = filter(options, params);
const { inputValue } = params;
- const isExisting = options.some((option) => inputValue === option.title);
- if (inputValue !== '' && !isExisting) {
+ const isExisting = options.some(
+ (option) => inputValue === option.title
+ );
+ if (inputValue !== "" && !isExisting) {
filtered.push({
inputValue,
title: `Add "${inputValue}"`,
@@ -163,7 +191,7 @@ const AddNewCase = () => {
options={titles}
getOptionLabel={(option) => {
// Value selected with enter, right from the input
- if (typeof option === 'string') {
+ if (typeof option === "string") {
return option;
}
// Add "xxx" option created dynamically
@@ -173,33 +201,45 @@ const AddNewCase = () => {
// Regular option
return option.title;
}}
- renderOption={(props, option) => {option.title} }
+ renderOption={(props, option) => (
+
+ {option.title}
+
+ )}
freeSolo
renderInput={(params) => (
-
+
)}
/>
);
};
-
+
const categoryList = () => {
return (
{
- if (typeof newValue === 'string') {
- setDocumentCategory(newValue)
+ if (typeof newValue === "string") {
+ setDocumentCategory(newValue);
} else if (newValue && newValue.inputValue) {
- setDocumentCategory(newValue.inputValue)
- } else if(newValue && newValue.category) {
- setDocumentCategory(newValue.category)
+ setDocumentCategory(newValue.inputValue);
+ } else if (newValue && newValue.category) {
+ setDocumentCategory(newValue.category);
}
}}
filterOptions={(options, params) => {
const filtered = filter(options, params);
const { inputValue } = params;
- const isExisting = options.some((option) => inputValue === option.category);
- if (inputValue !== '' && !isExisting) {
+ const isExisting = options.some(
+ (option) => inputValue === option.category
+ );
+ if (inputValue !== "" && !isExisting) {
filtered.push({
inputValue,
category: `Add "${inputValue}"`,
@@ -214,7 +254,7 @@ const AddNewCase = () => {
options={categories}
getOptionLabel={(option) => {
// Value selected with enter, right from the input
- if (typeof option === 'string') {
+ if (typeof option === "string") {
return option;
}
// Add "xxx" option created dynamically
@@ -224,166 +264,583 @@ const AddNewCase = () => {
// Regular option
return option.category;
}}
- renderOption={(props, option) => {option.category} }
+ renderOption={(props, option) => (
+
+ {option.category}
+
+ )}
freeSolo
renderInput={(params) => (
-
+
)}
/>
);
};
-
+ const Check = () => {
+ if ((Title === "") | (Title === null)) {
+ showErrorMessage("باید حتما انتخاب کنید چه کاری می خواهید انجام دهید");
+ return false;
+ }
+ if (MaximumBudget <= MinimumBudget) {
+ showErrorMessage("مقدار حداکثر بودجه باید بیشتر از حداقل آن باشد.");
+ return false;
+ }
+ if ((caseName === "") | (caseName === null)) {
+ showErrorMessage("باید حتما نام پرونده خود را انتخاب کنید.");
+ return false;
+ }
+ if ((DocumentCategory === "") | (DocumentCategory === null)) {
+ showErrorMessage("باید زمینه پرونده را حتما انتخاب کنید.");
+ return false;
+ }
+ return true;
+ };
const handleCreateCase = async () => {
- if(MaximumBudget <= MinimumBudget){
- showErrorMessage('مقدار حداکثر بودجه باید بیشتر از حداقل آن باشد.');
+ if (Check() === false) {
return;
}
+ setloading(true);
const data = new FormData();
- data.append('MaximumBudget', MaximumBudget);
- data.append('MinimumBudget', MinimumBudget);
- data.append('FileUrl', '');
- data.append('Title', Title);
- data.append('DocumentCategory', DocumentCategory);
- data.append('File', File);
- data.append('Description', Description);
- data.append('caseName', caseName);
+ data.append("MaximumBudget", MaximumBudget);
+ data.append("MinimumBudget", MinimumBudget);
+ data.append("FileUrl", "");
+ data.append("Title", Title);
+ data.append("DocumentCategory", DocumentCategory);
+ data.append("File", File);
+ data.append("Description", Description);
+ data.append("caseName", caseName);
// console.log({MaximumBudget, MinimumBudget, Title, DocumentCategory, File, Description, caseName});
const token = await getAccessToken();
- if(token){
- const url = BASE_API_ROUTE + 'Document/AddDocument';
+ if (token) {
+ const url = BASE_API_ROUTE + "Document/AddDocument";
try {
- const response = await axios.post(url,data,{headers: {Authorization: `Bearer ${token}`}});
- // console.log('response in adding doc : ', response);
- showSuccesMessage('پرونده با موفقیت ایجاد شد.');
+ const response = await axios.post(url, data, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
+ // console.log('response in adding doc : ', response);
+ setloading(false);
+ showSuccesMessage("پرونده با موفقیت ایجاد شد.");
+ navigate("/show-cases/false");
} catch (error) {
- console.log('error in adding doc : ',error);
- showErrorMessage('ایجاد پرونده با خطا مواجه شد');
+ console.log("error in adding doc : ", error);
+ setloading(false);
+ showErrorMessage("ایجاد پرونده با خطا مواجه شد");
}
}
};
const handleEditCase = async () => {
- if(MaximumBudget <= MinimumBudget){
- showErrorMessage('مقدار حداکثر بودجه باید بیشتر از حداقل آن باشد.');
+ if (Check() === false) {
+ return;
+ }
+ if ((Title === "") | (Title === null)) {
+ showErrorMessage("باید حتما انتخاب کنید چه کاری می خواهید انجام دهید");
+ return;
+ }
+ if (MaximumBudget <= MinimumBudget) {
+ showErrorMessage("مقدار حداکثر بودجه باید بیشتر از حداقل آن باشد.");
return;
}
+ setloading(true);
const data = new FormData();
- data.append('MaximumBudget', MaximumBudget);
- data.append('MinimumBudget', MinimumBudget);
- data.append('FileUrl', FileURL);
- data.append('Title', Title);
- data.append('DocumentCategory', DocumentCategory);
- data.append('Id', DocumentId);
- data.append('File', File);
- data.append('Description', Description);
- data.append('caseName', caseName);
-
+ data.append("MaximumBudget", MaximumBudget);
+ data.append("MinimumBudget", MinimumBudget);
+ data.append("FileUrl", FileURL);
+ data.append("Title", Title);
+ data.append("DocumentCategory", DocumentCategory);
+ data.append("Id", DocumentId);
+ data.append("File", File);
+ data.append("Description", Description);
+ data.append("caseName", caseName);
+
const token = await getAccessToken();
- if(token){
- const url = BASE_API_ROUTE + 'Document/UpdateDocument';
+ if (token) {
+ const url = BASE_API_ROUTE + "Document/UpdateDocument";
try {
- const response = await axios.post(url,data,{headers: {Authorization: `Bearer ${token}`}});
- // console.log('response in updating Document : ', response);
- showSuccesMessage('پرونده با موفقیت ویرایش شد.');
+ const response = await axios.post(url, data, {
+ headers: { Authorization: `Bearer ${token}` },
+ });
+ setloading(false);
+ // console.log('response in updating Document : ', response);
+ showSuccesMessage("پرونده با موفقیت ویرایش شد.");
+ navigate("/show-cases/false");
} catch (error) {
- console.log('error in updating Document : ',error);
- showErrorMessage('ویرایش پرونده با خطا مواجه شد');
+ console.log("error in updating Document : ", error);
+ setloading(false);
+ showErrorMessage("ویرایش پرونده با خطا مواجه شد");
}
}
};
return (
<>
-
- {isEdit ? "ویرایش پرونده" : "افزودن پرونده"}
-
-
-
-
-
- {isEdit ? "ویرایش پرونده" : "افزودن پرونده جدید"}
-
-
- 1
- چه کاری می خواهید برای شما انجام شود؟
-
- {titleLists()}
-
-
-
- 2
- پرونده شما در چه زمینه ای است؟
-
- {categoryList()}
-
-
-
- 3
- نام پرونده
-
- setCaseName(e.target.value)}
- variant="outlined"
- inputProps={{style: { fontFamily:"shabnam"}}}/>
-
-
-
- 4
- پرونده خود را توضیح دهید :
-
- setDescription(e.target.value)}
- variant="outlined"
- inputProps={{style: {fontFamily:"shabnam"}}}/>
-
-
-
- 5
- اپلود فایل پرونده
-
- setFile(File)} />
-
-
-
- 6
- بودجه شما چقدر است ؟
-
- setMinimumBadget(e.target.value)}
- variant="outlined"
- inputProps={{ dir: "rtl", style: { fontFamily:"shabnam", fontSize: "15px",color:"black",} }}
- InputLabelProps={{ align: "right", dir: "rtl", style: { fontFamily:"shabnam", fontSize: "15px",color:"black",} }}
- sx={{width:{xs:'100%',sm:'50%'},mb:'10px'}}/>
- setMaximumBadget(e.target.value)}
- variant="outlined"
- inputProps={{ dir: "rtl", style: { fontFamily:"shabnam", fontSize: "15px",color:"black",}}}
- InputLabelProps={{ align: "right", dir: "rtl", style: { fontFamily:"shabnam", fontSize: "15px",color:"black",} }}
- sx={{width:{xs:'100%',sm:'50%'}}}/>
-
-
- {isEdit ? handleEditCase() : handleCreateCase()}} class="btn btn-p-primary btn-lg btn-block" id="create-new-project">
- {isEdit ? "ویرایش پرونده" : "ایجاد پرونده"}
-
-
-
-
-
+
+ {isEdit ? "ویرایش پرونده" : "افزودن پرونده"}
+
+
+
+
+
+
+
+
+ {isEdit ? "ویرایش پرونده" : "افزودن پرونده جدید"}
+
+
+
+
+ 1
+
+
+ چه کاری می خواهید برای شما انجام شود؟
+
+
+ {titleLists()}
+
+
+
+ 2
+
+
+ پرونده شما در چه زمینه ای است؟
+
+
+ {categoryList()}
+
+
+
+ 3
+
+
+ نام پرونده
+
+
+ setCaseName(e.target.value)}
+ variant="outlined"
+ inputProps={{ style: { fontFamily: "shabnam" } }}
+ />
+
+
+
+ 4
+
+
+ پرونده خود را توضیح دهید :{" "}
+
+
+ setDescription(e.target.value)}
+ variant="outlined"
+ inputProps={{ style: { fontFamily: "shabnam" } }}
+ />
+
+
+
+ 5
+
+
+ اپلود فایل پرونده
+
+
+
+
setFile(File)}
+ />
+ {FileURL && (
+
+
+ دانلود
+
+
+ )}
+
+
+
+
+ 6
+
+
+ بودجه شما چقدر است ؟{" "}
+
+
+ setMinimumBadget(e.target.value)}
+ variant="outlined"
+ inputProps={{
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "15px",
+ color: "black",
+ },
+ }}
+ InputLabelProps={{
+ align: "right",
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "15px",
+ color: "black",
+ },
+ }}
+ sx={{ width: { xs: "100%", sm: "50%" }, mb: "10px" }}
+ size="small"
+ />
+ setMaximumBadget(e.target.value)}
+ variant="outlined"
+ inputProps={{
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "15px",
+ color: "black",
+ },
+ }}
+ InputLabelProps={{
+ align: "right",
+ dir: "rtl",
+ style: {
+ fontFamily: "shabnam",
+ fontSize: "15px",
+ color: "black",
+ },
+ }}
+ sx={{ width: { xs: "100%", sm: "50%" } }}
+ size="small"
+ />
+
+
+
{
+ isEdit ? handleEditCase() : handleCreateCase();
+ }}
+ >
+ {!loading && (
+
+ {" "}
+ {isEdit ? "ویرایش پرونده" : "ایجاد پرونده"}{" "}
+
+ )}
+ {loading && (
+
+
+
+ )}
+
+
+
+
+
+
+
+ راهنمای پرونده
+
+
+ کار مورد انتظار
+
+
+ در این قسمت در میخواهید مشاوره حضوری یا غیر حضوری یا داوری
+ میخواهید باید یکی از گزینه های مورد نظر را انتخاب کنید
+
+
+
+ زمینه پرونده
+
+
+ در این قسمت، توضیح دهید که پرونده شما در چه زمینهای قرار
+ دارد و چه نوع فعالیتی را پوشش میدهد.
+
+
+
+ انتخاب نام
+
+
+ یک نام برای پرونده خودتان انتخاب کنید تا وکیل مورد نظر از
+ روی نام متوجه موضوع مورد نظر بشود
+
+
+
+ توضیح پرونده
+
+
+ نکاتی که در رابطه با پرونده تان ضروری هست را توضیح دهید تا
+ وکیل مورد نظر بتواند کمکتان کند
+
+
+
+ آپلود اسناد
+
+
+ مدرک و اسنادی که در رابطه با پرونده خود دارید را اپلود کنید
+ تا وکیل مورد نظر بعد بررسی اسناد بتواند مشاوره بهتری به شما
+ بدهد
+
+
+
+ هزینه مورد نظر
+
+
+ حداقل و حداکثر هزینه خود را وارد کنید تا بتوانیم شما را کمک
+ کنید فقط هزینه حداقل کمتر از حداکثر باشد
+
+
+
+
+
+
+
>
);
-}
+};
-export default AddNewCase;
\ No newline at end of file
+export default AddNewCase;
diff --git a/vakilpors-front/src/components/premium-page/PremiumPage.jsx b/vakilpors-front/src/components/premium-page/PremiumPage.jsx
index 70d65b5d0..469edae93 100644
--- a/vakilpors-front/src/components/premium-page/PremiumPage.jsx
+++ b/vakilpors-front/src/components/premium-page/PremiumPage.jsx
@@ -193,7 +193,7 @@ const PremiumPage = () => {
setmonthtransaction([]);
setmonth([]);
for (let i = 0; i < transactionmonth.data.data.length; i++) {
- const newData = transactionmonth.data.data[i].amount;
+ const newData =Math.floor(transactionmonth.data.data[i].amount);
const newmonth = transactionmonth.data.data[i].month;
console.log(transactionmonth.data.data[i].amount);
setmonthtransaction((prevState) => [...prevState, newData]);
@@ -408,8 +408,8 @@ const PremiumPage = () => {
borderRadius: "20px",
padding: "5px 50px 5px 50px ",
fontWeight: "bold",
- width: "80%",
- fontSize: "1rem",
+ width: "85%",
+ fontSize: "13px",
}}
>
ویرایش پروفایل
diff --git a/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx b/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx
index 6521bf0bb..a2c925e38 100644
--- a/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx
+++ b/vakilpors-front/src/components/premium-page/test/Avertising.test.jsx
@@ -77,50 +77,3 @@ describe('Advertising component', () => {
expect(screen.getByText(mockLawyers[0].title)).toBeInTheDocument();
});
});
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-// import React from 'react';
-// import { render, screen } from '@testing-library/react';
-// import { BrowserRouter as Router } from 'react-router-dom';
-// import Advertising from '../Avertising';
-
-// const mockLawyer = {
-// // your mock lawyer data here
-// };
-
-// const mockLawyers = [mockLawyer];
-
-// describe('Advertising component', () => {
-// it('displays lawyer information when data is loaded', async () => {
-// render(
-//
-//
-//
-// );
-
-// expect(screen.getByText(mockLawyers[0].user.name)).toBeInTheDocument();
-// expect(screen.getByText(`عنوان: ${mockLawyers[0].title ? mockLawyers[0].title : "وکیل"}`)).toBeInTheDocument();
-// expect(screen.getByText(`شهر: ${mockLawyers[0].city ? mockLawyers[0].city : "نامشخص"}`)).toBeInTheDocument();
-// });
-// });
diff --git a/vakilpors-front/src/components/profile/Lawyer_Jobinfo.jsx b/vakilpors-front/src/components/profile/Lawyer_Jobinfo.jsx
index 13d49b660..ccc2477b8 100644
--- a/vakilpors-front/src/components/profile/Lawyer_Jobinfo.jsx
+++ b/vakilpors-front/src/components/profile/Lawyer_Jobinfo.jsx
@@ -22,6 +22,13 @@ import InputAdornment from "@material-ui/core/InputAdornment";
import IconButton from "@material-ui/core/IconButton";
import CloudUploadIcon from "@material-ui/icons/CloudUpload";
import { useNavigate } from "react-router-dom";
+import Dialog from "@mui/material/Dialog";
+import DialogActions from "@mui/material/DialogActions";
+import DialogContent from "@mui/material/DialogContent";
+import DialogContentText from "@mui/material/DialogContentText";
+import DialogTitle from "@mui/material/DialogTitle";
+import Slide from "@mui/material/Slide";
+import { TransitionProps } from "@mui/material/transitions";
// mui rtl
import rtlPlugin from "stylis-plugin-rtl";
@@ -57,6 +64,17 @@ const Lawyer_Jobinfo = () => {
const [specialties, setSpecialties] = useState([]);
const fileInputRef = useRef(null);
const [loading, setloading] = useState(false);
+
+ const [open, setOpen] = useState(false);
+
+ const handleClickOpen = () => {
+ setOpen(true);
+ };
+
+ const handleClose = () => {
+ setOpen(false);
+ };
+
const descriptionUser =
"کاربر گرامی! در این قسمت میتوانید تمامی اطلاعات شغلی خود را بهروزرسانی و یا ویرایش کنید. لطفا از صحت اطلاعات وارد شده اطمینان حاصل نمائید.";
@@ -212,6 +230,97 @@ const Lawyer_Jobinfo = () => {
);
};
+ const OCRDialog = () => {
+ return (
+
+
+
+
+ شماره کد ملی
+
+
+ از کیفیت و صحت کارت ملی خود مطمئن شوید و پس از ان دکمه ارسال را
+ فشار دهید تا شماره ملی شما استخراج شود اگر شماره ملی درست نیود
+ خودتان اصلاح کنید
+
+
+
+
+
+
+
+
+
+ {/* {!loading && ارسال }
+ {loading && (
+
+
+
+ )} */}
+ ارسال
+
+
+
+
+
+ بستن
+
+
+ );
+ };
+
const handleCallingCardChange = (event) => {
const file = event.target.files[0];
console.log(file);
@@ -300,6 +409,7 @@ const Lawyer_Jobinfo = () => {
: specialtiesString + "/" + takh.title;
});
formData.append("specialties", specialtiesString);
+ console.log(formData);
const token = await getAccessToken();
if (token) {
const tokenData = jwt(token);
@@ -315,6 +425,58 @@ const Lawyer_Jobinfo = () => {
}
}
};
+ function convertImageUrlToFile(url, fileName) {
+ return fetch(url)
+ .then((response) => response.blob())
+ .then((blob) => {
+ const file = new File([blob], fileName, {
+ lastModified: new Date().getTime(),
+ lastModifiedDate: new Date(),
+ type: blob.type,
+ });
+ return file;
+ });
+ }
+ const HandleOcr = async (event) => {
+ console.log(refdetail.current.nationalCardImage);
+
+ const url = BASE_API_ROUTE + `Ocr`;
+ const file = refdetail.current.nationalCardImage;
+
+ console.log(file); // اضافه کردن این خط
+
+ if (file && file instanceof Blob) {
+ const reader = new FileReader();
+
+ reader.onloadend = () => {
+ const fileString = reader.result;
+ console.log(fileString);
+ setdetail({
+ ...refdetail.current,
+ ["nationalCardImage"]: file,
+ });
+ };
+
+ reader.readAsDataURL(file);
+ }
+
+ const formData = new FormData();
+ formData.append("imageFile", refdetail.current.nationalCardImage);
+ console.log(formData);
+
+ axios
+ .post(url, formData, {
+ headers: {
+ "Content-Type": "multipart/form-data"
+ },
+ })
+ .then((response) => {
+ console.log(response);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
const setUserInfo = (event) => {
event.target.name.includes("user")
@@ -575,16 +737,16 @@ const Lawyer_Jobinfo = () => {
accept=".pdf"
onChange={handleResumeChange}
/>
-
- {refdetail.current.resumeLink && (
+ {refdetail.current.resumeLink && (
+
{
>
دانلود
- )}
-
+
+ )}
),
}}
@@ -618,33 +780,70 @@ const Lawyer_Jobinfo = () => {
flexDirection: "column",
}}
>
-
- کارت ملی
-
-
+
+
+ کارت ملی
+
+
+ {refdetail.current.nationalCardImageUrl && (
+
+
+ تست ocr
+
+ {OCRDialog()}
+
+ )}
+