Skip to content

Commit

Permalink
Merge pull request #1538 from hngx-org/Phoenix
Browse files Browse the repository at this point in the history
Phoenix
  • Loading branch information
incredible-phoenix246 authored Jan 6, 2024
2 parents 1ba99f3 + f8f5537 commit c90ab04
Show file tree
Hide file tree
Showing 12 changed files with 482 additions and 24 deletions.
6 changes: 5 additions & 1 deletion components/Modals/Removecart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { MouseEvent, useState } from 'react';
import Image from 'next/image';
import group from '../../public/assets/removecart/Group.png';
import trash from '../../public/assets/removecart/delete.svg';
import Modal from '@ui/Modal';

interface RemoveCartProps {
closeModal: () => void;
Expand All @@ -11,7 +12,10 @@ interface RemoveCartProps {

const RemoveCart: React.FC<RemoveCartProps> = ({ closeModal, onRemoveItem, productId }) => {
return (
<div className="fixed inset-0 flex items-center justify-center z-50 bg-[#00000080] bg-opacity-30">
<div
className="fixed inset-0 flex items-center justify-center z-50 bg-[#00000080] bg-opacity-30"
onClick={closeModal}
>
<div id="modal" className="bg-white-100 p-4 rounded-lg w-[90%] md:w-[50%] lg:w-[24%] h-415 text-center ">
<svg
onClick={closeModal}
Expand Down
14 changes: 7 additions & 7 deletions components/Modals/TempUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const TempUser = ({ isOpen, onClose }: TempUser) => {
};
const payment = userForm.get('paymentMethod') as string;
const tempUser = await createTempUser(data);

if (tempUser.data.token) {
localStorage.setItem('trans_token',tempUser.data.token);
localStorage.setItem('trans_token', tempUser.data.token);

const cartItems = JSON.parse(localStorage.getItem('products') as string);
const cartIds = await getCardItemsId(cartItems);
Expand Down Expand Up @@ -75,7 +75,7 @@ const TempUser = ({ isOpen, onClose }: TempUser) => {
Firstname
</label>
<input
className="flex items-center justify-between w-full border border-[#E1E3E2] rounded-lg p-4 mb-4 focus:outline-none focus:border-brand-green-primary"
className="flex items-center justify-between w-full border border-[#E1E3E2] rounded-lg p-4 mb-4 focus:outline-none focus:border-brand-green-primary font-medium text-[16px]"
placeholder="Mark"
type="text"
name="first_name"
Expand All @@ -87,7 +87,7 @@ const TempUser = ({ isOpen, onClose }: TempUser) => {
Lastname
</label>
<input
className="flex items-center justify-between w-full border border-[#E1E3E2] rounded-lg p-4 mb-4 focus:outline-none focus:border-brand-green-primary"
className="flex items-center justify-between w-full border border-[#E1E3E2] rounded-lg p-4 mb-4 focus:outline-none focus:border-brand-green-primary font-medium text-[16px]"
placeholder="Essein"
type="text"
name="last_name"
Expand All @@ -99,7 +99,7 @@ const TempUser = ({ isOpen, onClose }: TempUser) => {
Email
</label>
<input
className="flex items-center justify-between w-full border border-[#E1E3E2] rounded-lg p-4 mb-4 focus:outline-none focus:border-brand-green-primary"
className="flex items-center justify-between w-full border border-[#E1E3E2] rounded-lg p-4 mb-4 focus:outline-none focus:border-brand-green-primary font-medium text-[16px]"
placeholder="[email protected]"
type="email"
name="email"
Expand All @@ -115,7 +115,7 @@ const TempUser = ({ isOpen, onClose }: TempUser) => {
name="paymentMethod"
value="paystack"
/>
<span className="ml-2">Pay with Paystack </span>
<span className="ml-2 font-medium text-[16px]">Pay with Paystack </span>
</label>
<Image src={paystack} alt="paystack" width={64} height={64} />
</div>
Expand All @@ -128,7 +128,7 @@ const TempUser = ({ isOpen, onClose }: TempUser) => {
name="paymentMethod"
value="flutterwave"
/>
<span className="ml-2">Pay with Flutterwave</span>
<span className="ml-2 font-medium text-[16px]">Pay with Flutterwave</span>
</label>
<Image src={flutterwave} alt="mastercard" width={76} height={76} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/ui/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { DetailedHTMLProps, InputHTMLAttributes, SelectHTMLAttributes } f
import { twMerge } from 'tailwind-merge';

const inputVariants = cva(
'relative px-4 py-3 flex items-center justify-center gap-3 w-fit h-[48px] rounded-[10px] font-manropeL text-dark-100 hide-caret transition-all select-none focus-within:border-brand-green-primary ',
'relative px-4 py-3 flex items-center justify-center gap-3 w-fit h-[48px] rounded-[10px] font-manropeL text-[#111111] font-medium hide-caret transition-all select-none focus-within:border-brand-green-primary ',
{
variants: {
intent: {
Expand Down
13 changes: 5 additions & 8 deletions http/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import $http from './axios';
import axios from 'axios';
import { AUTH_HTTP_URL } from './auth';



// export const CART_ENDPOINT = "https://zuri-cart-checkout.onrender.com/api/v1/checkout_cart"

export const STAGING_URL = process.env.NEXT_PUBLIC_APP_STAGING_URL || 'https://staging.zuri.team';
export const API_BASE_URL = process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL || 'https://zuriportfolio-backend.onrender.com/api/v1'
export const API_BASE_URL =
process.env.NEXT_PUBLIC_BACKEND_ENDPOINT_URL || 'https://zuriportfolio-backend.onrender.com/api/v1';
export const RECENTLY_VIEWED_ENDPOINT = 'https://staging.zuri.team/api/marketplace/v1/recently-viewed';
export const CART_ENDPOINT = API_BASE_URL + "/checkout";
export const SHOP_API_URL = `${API_BASE_URL}/shop-internal`
export const PORTFOLIO_BASE_URL = `${API_BASE_URL}/portfolio`


export const CART_ENDPOINT = API_BASE_URL + '/checkout';
export const SHOP_API_URL = `${API_BASE_URL}/shop-internal`;
export const PORTFOLIO_BASE_URL = `${API_BASE_URL}/portfolio`;

export const addToCart = async (cartItems: string[], token: string) => {
try {
Expand Down
211 changes: 211 additions & 0 deletions modules/portfolio/Filter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
import React, { Dispatch, useRef, useState, useEffect } from 'react';
import { ArrowLeft2, ArrowRight2, Element3, Filter } from 'iconsax-react';
import CustomDropdown from '../explore/components/CustomDropdown';
import { Input } from '@ui/Input';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';
import { alltracksType } from '../explore/@types';

const SearchAndFilter = (prop: {
setSearchQuery?: Dispatch<React.SetStateAction<string>>;
filters: { SortBy?: number; Country?: string };
handleFilters: (type: string, value: string | number) => void;
setFilter: Dispatch<React.SetStateAction<{ SortBy?: number; Country?: string }>>;
setPageNumber: () => void;
handleGo: () => void;
}) => {
const { setPageNumber, handleGo } = prop;
const [activeSection, setActiveSection] = useState(0);
const [selectedOption, setSelectedOption] = useState<string>('');
const [selectedOption2, setSelectedOption2] = useState<string>('');
const [showLeftButton, setShowLeftButton] = useState<boolean>(true);
const [showRightButton, setShowRightButton] = useState<boolean>(true);
const [showFilterComponent, setShowFilterComponent] = useState<boolean>(false);

const { filters, handleFilters } = prop;
const sliderRef = useRef<HTMLDivElement>(null);

const [searchQuery, setSearchQuery] = useState(''); // Separate state for the search query

// Add a state variable to track the button's disabled state
const [isButtonDisabled, setIsButtonDisabled] = useState(true);

// an effect that handles enable or disable the button based on input values
useEffect(() => {
const isInputValid = prop.filters.Country || prop.filters.SortBy !== undefined;
const isSearchValid = searchQuery.trim() !== ''; // Validate the search query

// Enable the button if both input and search are valid, otherwise disable it
setIsButtonDisabled(!(isInputValid && isSearchValid));
}, [searchQuery, prop.filters]);

const handleScroll = () => {
const slider = sliderRef.current!; // Non-null assertion

// setShowLeftButton(!isStart);
// setShowRightButton(!isEnd);
};

const closeFilterComponent = (option?: 'close' | 'clear') => {
if (option === 'clear') {
prop.setFilter({});
} else {
setShowFilterComponent(false);
}
};
const slideLeft = () => {
const slider = sliderRef.current!; // Non-null assertion
slider.scrollLeft -= 150; // Adjust the scroll distance as needed
};

const slideRight = () => {
const slider = sliderRef.current!; // Non-null assertion
slider.scrollLeft += 150; // Adjust the scroll distance as needed
};

const handleCustomDropdownChange = (option: string) => {
setSelectedOption(option);

if (option === 'Nigeria' || option === 'Ghana' || option === 'Cameroon') {
return handleFilters('Country', option);
}

delete filters.Country;
};
const handleCustomDropdownChange2 = (option: string) => {
setSelectedOption2(option);
const [location, country] = option.split(',');
handleFilters('Location', `${location} ${country}`);
};

const handleAllTrack = async () => {
const { data } = await axios.get('https://explore-90v6.onrender.com/api/track/getAllTracks');
return data;
};

const { data: trackData, isLoading: trackLoading } = useQuery<{ data: alltracksType[] }>({
queryKey: ['alltrack'],
queryFn: () => handleAllTrack(),
});

const allTrack: alltracksType[] = [{ name: 'All', id: 0 }, ...(trackData?.data ?? [])];

return (
<section id="top" className="p-4 xl:px-0">
<div className="relative -mt-[7rem] mx-auto mb-5 py-8 px-6 bg-white-100 font-manropeL xl:max-w-[77.5rem] z-[1]">
<div className="md:justify-between justify-btween items-center md:items-start flex flex-col md:flex-row gap-8">
<div className="w-full grid grid-cols-2 gap-4 md:grid-cols-5">
<form className="col-span-full grid grid-cols-[1fr_auto] gap-3 md:col-span-3">
<label className="col-span-full text-[#5B5F5E]" htmlFor="Search query title">
Search by name or role
</label>
<Input
onChange={(e) => {
prop.setSearchQuery && prop.setSearchQuery(e.target.value);
prop.setFilter({});
setPageNumber();
}}
type="text"
name="search input"
intent={'default'}
placeHolder="Search by name or role"
required
className="w-full text-grey-900 border-[1px] border-white-120 rounded-lg placeholder:text-white-400"
/>
<button
onClick={handleGo}
className="h-12 self-end bg-brand-green-primary text-lg tracking-wide text-white-100 p-2 px-4 rounded-lg uppercase sm:px-6"
disabled={isButtonDisabled}
>
Go
</button>
</form>

<div className="grid gap-3">
<label className="text-[#5B5F5E]" htmlFor="Location">
Location
</label>
<CustomDropdown
options={['Lagos, Nigeria', 'Accra, Ghana', 'Nairobi, Kenya']}
selectedValue={selectedOption2}
placeholder="Location"
onChange={handleCustomDropdownChange2}
/>
</div>

<button className="hidden">
<Filter
size={48}
color="#1a1c1b"
className="border-2 border-brand-disabled2 text-black rounded-xl p-2 hover:bg-brand-green-primary"
/>
</button>
</div>
</div>

<div
className="h-full overflow-x-scroll mt-4 mr-[6.5rem] scroll whitespace-nowrap scroll-smooth scrollbar-none"
ref={sliderRef}
onScroll={handleScroll}
>
<div className="justify-start items-center inline-flex mt-4 gap-4">
{
allTrack.map((section, index) => (
<div
key={index}
className={`px-4 py-[0.625rem] rounded-lg justify-center items-center gap-2 flex cursor-pointer font-manropeB text-[0.875rem] ${
activeSection === index ? 'bg-brand-green-primary text-white-100' : 'bg-white text-[#737373]'
}`}
onClick={() => {
setActiveSection(index);
handleFilters('Track', section.name);
setShowFilterComponent(section.name === 'All Filter');
}}
>
{section.name === 'All' ? (
<div className="flex justify-center items-center gap-2 text-center">
<Element3 size="24" color={activeSection === index ? '#fff' : '#5B5F5E'} variant="Bold" />
{section.name}
</div>
) : (
<div className="flex justify-center items-center gap-2 text-center">{section.name}</div>
)}
</div>
))
// ....
}
</div>
</div>
<div className="relative right-1 flex top-3 md:top-0">
{showLeftButton && (
<div
className="w-12 h-12 p-3 bg-white rounded-2xl border border-stone-300 justify-center items-center gap-2 inline-flex absolute -top-[2.95rem] right-[3.5rem] bg-white-100"
onClick={slideLeft}
>
<div className="w-6 h-6 justify-center items-center flex cursor-pointer">
<div className="w-6 h-6 relative">
<ArrowLeft2 color="#737373" />
</div>
</div>
</div>
)}

{showRightButton && (
<div
className="w-12 h-12 p-3 bg-white rounded-2xl border border-stone-300 justify-center items-center gap-2 inline-flex absolute -top-[2.95rem] right-0 bg-white-100"
onClick={slideRight}
>
<div className="w-6 h-6 justify-center items-center flex cursor-pointer">
<div className="w-6 h-6 relative">
<ArrowRight2 color="#737373" />
</div>
</div>
</div>
)}
</div>
</div>
</section>
);
};

export default SearchAndFilter;
18 changes: 18 additions & 0 deletions modules/portfolio/component/Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Breadcrumbs from './Breadcrumbs';

const Banner = () => {
return (
<section className="-mt-5 bg-[95%_25%] bg-no-repeat lg:pt-[4rem] 2xl:bg-[45%_25%]">
<div className="relative -mt-5 py-12 pb-[8rem] px-6 grid gap-4 font-manropeL text-base xl:w-[77.5rem] xl:mx-auto xl:px-0">
<Breadcrumbs />
<span className="py-3 font-manropeB font-regular text-5xl ">Explore</span>

<h1 className="max-w-[24rem] relative xl:max-w-[36rem] pr-3 font-regular text-xl leading-[2] text-[#536066]">
Find your perfect creactive match
</h1>
</div>
</section>
);
};

export default Banner;
31 changes: 31 additions & 0 deletions modules/portfolio/component/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';

function Breadcrumbs() {
const router = useRouter();
const routeArr = router.route.slice(1).split('/');

const breadcrumbs = routeArr.map((el, i, arr) => (
<React.Fragment key={i}>
<span className="mx-2">{'>'}</span>
<Link
href={`/${arr.slice(0, i).join('/')}/${el}`}
className={`${i + 1 === arr.length ? ' text-green-600 font-manropeB' : null}`}
>
{el.split('-').join(' ')}
</Link>
</React.Fragment>
));

return (
<div className="font-manropeB font-medium text-xl text-[#5B5F5E] capitalize">
<div>
<Link href="/">Home</Link>
{breadcrumbs}
</div>
</div>
);
}

export default Breadcrumbs;
Loading

1 comment on commit c90ab04

@vercel
Copy link

@vercel vercel bot commented on c90ab04 Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

zuriportfolio-frontend – ./

zuriportfolio.vercel.app
zuriportfolio-frontend-git-dev-zuri-team.vercel.app
zuriportfolio-frontend-zuri-team.vercel.app

Please sign in to comment.