Skip to content

Commit

Permalink
Riyad/client dashboard (#247)
Browse files Browse the repository at this point in the history
* developing freelancer dashboard

* add new dashboard

* update the dashboard

* briefs search working

* swith profile on navbar

* 1. add applications page
2. add message page
3.add  ongoing page

* fix hovering issue

* functional applications count

* add myprojects page

* added filters for briefs container

* functional freelancer dashboard

* new bug fixes

* fixed tests with new changes on brief/apply

* approved brief fixes

* fixed redirect to freelancers/new

* fixed test

* 1.fix long descriptions
2. redirect to owner profile
3. redirect to brief
4. limit skill show to 4
5. handle chat click
6. remove search and filter button add redirect to brief

* 1. make chat click as popup

* fix client side error

* new comit

* 1. fix client side rendering issue

* 1. implemented the new client dashboard

* minor update

* fix client side error

* another fix

* 1. fix grant section in client dashboard
2. fix total earning in freelancer dashboard

* 1. fix typo
2. add user images
3. add backbutton to wallet page
4. add view all button to client dashboard

* 1. add item number to my projects
2. remove commented code
3 . add total spent

---------

Co-authored-by: ssani7 <[email protected]>
  • Loading branch information
shakilahmedriyad and ssani7 authored Oct 31, 2023
1 parent f1c13d8 commit 6218156
Show file tree
Hide file tree
Showing 38 changed files with 3,076 additions and 441 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@types/react-slick": "^0.23.10",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"apexcharts": "^3.44.0",
"axios": "^1.5.1",
"bad-words": "^3.0.4",
"bcryptjs": "^2.4.3",
Expand Down Expand Up @@ -71,6 +72,7 @@
"rc-pagination": "^3.4.2",
"react": "18.2.0",
"react-activity-feed": "^1.4.0",
"react-apexcharts": "^1.4.1",
"react-copy-to-clipboard": "^5.1.0",
"react-country-flag": "^3.1.0",
"react-country-region-selector": "^3.6.1",
Expand All @@ -90,6 +92,7 @@
"stream-chat-react": "^10.7.3",
"styled-components": "^5.3.9",
"swagger-ui-react": "^4.19.0",
"swiper": "^11.0.3",
"test-utils": "^1.1.1",
"typescript": "5.0.2",
"uuidv4": "^6.2.12"
Expand Down
Binary file added public/peer-to-peer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions src/components/AreaGraph/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import dynamic from 'next/dynamic';

const Chart = dynamic(() => import('react-apexcharts'), {
ssr: false,
});

export default function AreaGrah() {
const options = {
fill: {
colors: ['#3B27C1'],
},
stroke: {
height: '1px',
colors: ['#3B27C1'],
},
dataLabels: {
enabled: false,
},
toolbar: {
enabled: false,
show: false,
},
xaxis: {
categories: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'],
},
};

const series = [
{
name: 'profile views',
data: [0, 0, 3, 5, 2, 6, 0],
},
];

return <Chart series={series} options={options} type='area' height={320} />;
}
150 changes: 150 additions & 0 deletions src/components/BriefComponent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import StarIcon from '@mui/icons-material/Star';
import { Rating } from '@mui/material';
import TimeAgo from 'javascript-time-ago';
import en from 'javascript-time-ago/locale/en.json';
import Image from 'next/image';
import { useRouter } from 'next/router';
import {
AiOutlineCalendar,
AiOutlineClockCircle,
AiOutlinePlus,
} from 'react-icons/ai';
import { HiOutlineCurrencyDollar } from 'react-icons/hi';
import { TbNorthStar } from 'react-icons/tb';
import { TbUsers } from 'react-icons/tb';
import { TfiEmail } from 'react-icons/tfi';
import { VscVerified } from 'react-icons/vsc';

import { Brief } from '@/model';

TimeAgo.addLocale(en);
const timeAgo = new TimeAgo('en-US');

export default function BriefComponent({ brief }: { brief: Brief }) {
const router = useRouter();
return (
<div className='flex border-b hover:bg-imbue-light-purple-three cursor-pointer last:border-b-0'>
<div
onClick={() => router.push(`/briefs/${brief.id}`)}
className='py-9 px-7 max-w-[70%] w-full'
>
<p className='text-2xl text-imbue-purple-dark'>{brief.headline}</p>
<div className='flex text-sm text-imbue-dark-coral gap-5 mt-5'>
<p className='px-3 flex items-center gap-1 rounded-xl py-1 bg-imbue-light-coral '>
<TbNorthStar size={18} />
{brief.experience_level}
</p>
<p className='px-3 rounded-xl flex gap-1 items-center py-1 bg-imbue-light-coral '>
<AiOutlineCalendar size={18} />
Posted {timeAgo.format(new Date(brief.created))}
</p>
<p className='px-3 flex items-center gap-1 rounded-xl py-1 bg-imbue-light-coral '>
<AiOutlineClockCircle size={18} />
{brief.duration}
</p>
<p className='px-3 flex items-center gap-1 rounded-xl py-1 bg-imbue-light-coral '>
<HiOutlineCurrencyDollar size={20} />
Fixed price
</p>
</div>
<div className='mt-7'>
<p className='text-black text-sm'>
{brief.description.length > 500
? brief.description.substring(0, 500)
: brief.description}
{brief.description.length > 500 && (
<span className='text-imbue-purple ml-1 cursor-pointer underline'>
more
</span>
)}
</p>
</div>
<div className='flex gap-2 mt-5'>
{[0, 1, 2, 3].map(
(item) =>
brief.skills.at(item) && (
<p
key={'skills' + item}
className='text-imbue-purple flex items-center gap-1 bg-imbue-light-purple-three px-4 rounded-full py-1'
>
{brief.skills.at(item)?.name}
<AiOutlinePlus color='black' size={18} />
</p>
)
)}
{brief.skills.length - 4 > 0 && (
<p className='text-imbue-purple flex items-center gap-1 bg-imbue-light-purple-three px-4 rounded-full py-1'>
{brief.skills.length - 4} more
</p>
)}
</div>
</div>
<div className='max-w-[30%] w-full py-7 border-l'>
<div className='px-7 flex gap-2 pb-4 border-b'>
<Image
className='w-9 h-9 rounded-full'
src={
brief.owner_photo || require('@/assets/images/profile-image.png')
}
width={40}
height={40}
alt='profile'
/>
<div>
<p
onClick={() => {
router.push(`/profile/${brief.owner_name}`);
}}
className='text-black'
>
{brief.created_by}
</p>
<p className='text-sm'>Company Hire</p>
</div>
</div>
<div className='text-black border-b text-sm py-3 space-y-2 px-9'>
<p className='flex items-center'>
<span className='text-imbue-purple mr-2'>
<VscVerified size={20} />
</span>
Payment method verified
</p>
<p className='flex items-center'>
<span className='text-imbue-purple mr-2 ml-0.5'>
<TfiEmail size={16} />
</span>
{brief.number_of_briefs_submitted}
</p>
<p className='flex items-center'>
<span className='text-imbue-purple mr-1.5'>
<HiOutlineCurrencyDollar size={20} />
</span>
$19k total spent
</p>
<p className='flex items-center'>
<span className='text-imbue-purple mr-2'>
<TbUsers size={18} />
</span>
59 hires,6 active
</p>
</div>
<div className='text-xs pt-3 px-7 text-black'>
<Rating
className='text-base'
name='text-feedback'
value={4.68}
readOnly
precision={0.5}
emptyIcon={
<StarIcon style={{ opacity: 0.55 }} fontSize='inherit' />
}
/>
<div className='flex mt-1 justify-between'>
<p>4.68 of 40 reviews</p>
<p>Member since: Aug 17,2023</p>
</div>
</div>
</div>
</div>
);
}
41 changes: 37 additions & 4 deletions src/components/ClientView/ClientView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import classNames from 'classnames';
import ArrowBackIcon from '@mui/icons-material/ChevronLeft';
import { useRouter } from 'next/router';
import { useState } from 'react';

import { Freelancer, Project } from '@/model';
Expand Down Expand Up @@ -29,9 +30,41 @@ export default function ClientView({
loadingApplications,
}: ClientViewProps) {
const [switcher, setSwitcher] = useState('application');
const router = useRouter();
return (
<div className='bg-white rounded-2xl overflow-hidden'>
<div className='text-imbue-purple py-7 px-9 flex text-sm space-x-9 border-b border-b-imbue-light-purple'>
<div className='flex items-center w-full'>
<div
onClick={() => router.back()}
className='border border-content ml-2 group hover:bg-content rounded-full flex items-center justify-center cursor-pointer left-5 top-10'
>
<ArrowBackIcon
className='h-7 w-7 group-hover:text-white'
color='secondary'
/>
</div>
<div className='mx-2 border w-full justify-between rounded-3xl flex cursor-pointer'>
<p
onClick={() => setSwitcher('application')}
className='text-2xl text-black py-5 border-r text-center w-full '
>
Briefs ({briefs?.briefsUnderReview?.length})
</p>
<p
onClick={() => setSwitcher('projects')}
className='text-2xl text-black py-5 border-r text-center w-full'
>
Projects({briefs?.acceptedBriefs.length})
</p>
<p
onClick={() => setSwitcher('grants')}
className='text-2xl text-black border-r py-5 text-center w-full'
>
Grants({ongoingGrants.length})
</p>
</div>
</div>
{/* <div className='text-imbue-purple py-7 px-9 flex text-sm space-x-9 border-b border-b-imbue-light-purple'>
<p
onClick={() => setSwitcher('application')}
className={classNames(
Expand All @@ -41,7 +74,7 @@ export default function ClientView({
: 'text-imbue-light-purple-two'
)}
>
Briefs ({briefs?.briefsUnderReview.length})
Briefs ({briefs?.briefsUnderReview?.length})
</p>
<p
onClick={() => setSwitcher('projects')}
Expand All @@ -65,7 +98,7 @@ export default function ClientView({
>
Grants({ongoingGrants.length})
</p>
</div>
</div> */}
{/* <Divider className='mb-5' /> */}

{switcher === 'application' && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Divider } from '@mui/material';
import TimeAgo from 'javascript-time-ago';
import en from 'javascript-time-ago/locale/en.json';
import router from 'next/router';
import { useState } from 'react';

Expand All @@ -8,7 +9,7 @@ import { displayState, OffchainProjectState, Project } from '@/model';
interface BreifApplicationProps {
applications: any;
}

TimeAgo.addLocale(en);
const timeAgo = new TimeAgo('en-US');

const BreifApplication: React.FC<BreifApplicationProps> = ({
Expand All @@ -18,9 +19,15 @@ const BreifApplication: React.FC<BreifApplicationProps> = ({
const loadBrefApplicationValue = 10;
const [loadValue, setValue] = useState(loadBrefApplicationValue);
const redirectToApplication = (application: Project) => {
router.push(
`/briefs/${application.brief_id}/applications/${application.id}/`
);
if (application.chain_project_id)
router.push(
`/projects/${application.id}/`
);

else
router.push(
`/briefs/${application.brief_id}/applications/${application.id}/`
);
};

const redirectToDiscoverBriefs = () => {
Expand All @@ -47,10 +54,10 @@ const BreifApplication: React.FC<BreifApplicationProps> = ({
{applications?.map(
(item: any, index: number) =>
index <
Math.min(
applications.length,
Math.max(loadValue, loadBrefApplicationValue)
) && (
Math.min(
applications.length,
Math.max(loadValue, loadBrefApplicationValue)
) && (
<>
<div
key={item.id}
Expand All @@ -72,9 +79,8 @@ const BreifApplication: React.FC<BreifApplicationProps> = ({
</div>
<div className='flex pb-9 flex-row-reverse justify-between'>
<div
className={`px-4 py-1 lg:py-2 w-fit rounded-full text-xs lg:text-base text-center ${
OffchainProjectState[item?.status_id || 0]
}-button `}
className={`px-4 py-1 lg:py-2 w-fit rounded-full text-xs lg:text-base text-center ${OffchainProjectState[item?.status_id || 0]
}-button `}
>
{displayState(item?.status_id || 0)}
</div>
Expand Down
28 changes: 20 additions & 8 deletions src/components/Dashboard/MyChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ function DashboardChatBox({ client }: { client: StreamChat }) {
const filters = client && { members: { $in: [String(client.user?.id)] } };
const router = useRouter();

useEffect(() => {
if (router.query.chat && !channel) {
router.query.chat = [];
router.replace(router, undefined, { shallow: true });
}
}, [router.query.chat, channel, router]);
// useEffect(() => {
// if (router.query.chat && !channel) {
// router.query.chat = [];
// router.replace(router, undefined, { shallow: true });
// }
// }, [router.query.chat, channel, router]);

const closeChat = () => {
//for navigating back and front
Expand All @@ -57,6 +57,19 @@ function DashboardChatBox({ client }: { client: StreamChat }) {
return username;
};

useEffect(() => {
if (router.query.chat) {
const channleId = router.query.chat;
const targetChannle = channels.filter(
(item: any) => item.id === channleId
);
if (targetChannle.length) {
setChannel(targetChannle[0]);
setActiveChannel(targetChannle[0]);
}
}
}, []);

const getUserPhoto = (index: string) => {
const array: any = Object.values(channels[index]?.state?.members);
let profile_photo = 'Not Found';
Expand All @@ -79,7 +92,6 @@ function DashboardChatBox({ client }: { client: StreamChat }) {
const handleChatClick = (selectedChannel: any) => {
setChannel(selectedChannel);
setActiveChannel(selectedChannel);

//for navigating back and front
router.query.chat = selectedChannel.id;
router.push(router, undefined, { shallow: true });
Expand Down Expand Up @@ -183,7 +195,7 @@ function DashboardChatBox({ client }: { client: StreamChat }) {
};

return (
<div className='custom-chat-container relative w-full rounded-2xl h-[75vh] bg---theme-grey-dark border border-white border-opacity-25 overflow-hidden -mt-2'>
<div className='custom-chat-container relative w-full rounded-2xl h-[85vh] bg---theme-grey-dark border border-white border-opacity-25 overflow-hidden -mt-2'>
<Chat client={client} theme='str-chat__theme-light'>
{mobileView ? (
<>
Expand Down
Loading

0 comments on commit 6218156

Please sign in to comment.