Skip to content

Commit

Permalink
Merge branch 'dev' into ZA/fix/auth
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-ve authored Oct 22, 2023
2 parents 4478d99 + 4a8ef73 commit 0dcf746
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 42 deletions.
6 changes: 3 additions & 3 deletions components/Navbars/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function TopBar(props: { activePage: string; showDashBorad: boolean }) {
</Link>
<Link
onClick={handleAuthMenu}
href={`/portfolio/${globalAuth?.user?.slug}`}
href={`/portfolio/${globalAuth?.user?.slug}/manage`}
className=" border-[#EBEEEF] cursor-pointer hover:bg-[#F4FBF6] py-5 px-4 flex gap-6 "
>
<Image draggable={false} src={briefCaseIcon} alt="Briefcase icon" />
Expand Down Expand Up @@ -712,8 +712,8 @@ function MenuUI({
</div>
<div className=" group flex flex-col ali justify-center gap-1 ">
<Link
className={activeLink(`/portfolio/${globalAuth?.user?.slug}`)}
href={`/portfolio/${globalAuth?.user?.slug}`}
className={activeLink(`/portfolio/${globalAuth?.user?.slug}/manage`)}
href={`/portfolio/${globalAuth?.user?.slug}/manage`}
>
Manage Portfolio
</Link>
Expand Down
2 changes: 1 addition & 1 deletion modules/home/carousel/portfolios/portfolioCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const PortfolioCarousel = () => {
{/* Shop section */}
{logo?.section === 'shop' && (
<div
className="absolute border-white-200 border-[1px] inset-0 bg-cover bg-center bg-no-repeat flex flex-col justify-end mr-2 md:mr-6 rounded-md"
className="absolute border-white-200 border-[1px] inset-0 bg-cover bg-center bg-no-repeat flex flex-col justify-end mr-2 md:mr-6 rounded-[11px]"
style={{ backgroundImage: `url(${logo?.src})` }}
>
<div className="flex justify-center w-full items-center bg-white-100 p-2 rounded-b">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const MobileCustomerDashboard = ({ data }: { data: PurchaseData[] }) => {
isOpen={isModalOpen}
onClose={closeModal}
product={selectedOrder?.product_id || ''}
customerID={selectedOrder?.customer_id || ''}
user={selectedOrder?.customer_id || ''}
/>
</div>
</div>
Expand Down
59 changes: 25 additions & 34 deletions modules/portfolio/component/new-custom-section-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void
validateInputOnChange: true,
validate: {
addList: {
title: (value) =>
value?.length === 0 || containsWhitespace(value) ? 'Title is empty or contains whitespaces' : null,
title: (value) => (value?.length === 0 ? 'Title is empty or contains whitespaces' : null),
subtitle: {
title: (value) =>
value?.length === 0 || containsWhitespace(value) ? 'Subtitle is empty or contains whitespaces' : null,
title: (value) => (value?.length === 0 ? 'Subtitle is empty or contains whitespaces' : null),
value: (value) => (value?.length === 0 ? 'Subtitle - value is empty or contains whitespaces' : null),
},
dates: {
Expand All @@ -76,15 +74,15 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void
fields: (value) => {
const errors = value?.reduce((acc, field, index) => {
if (field?.inputfield !== undefined) {
if (field.inputfield?.length === 0 || containsWhitespace(field.inputfield)) {
if (field.inputfield?.length === 0) {
acc.push(`Input title is empty or contains whitespaces`);
}
if (field?.value?.length === 0) {
acc.push(`Input field is empty`);
}
}
if (field?.links !== undefined) {
if (field.links?.length === 0 || containsWhitespace(field.links)) {
if (field.links?.length === 0) {
acc.push(`Link title is empty or contains whitespaces`);
}
if (!urlRegex.test(field.value)) {
Expand Down Expand Up @@ -163,7 +161,6 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void
value: sectionForm?.values?.section[0].description,
});
}
console.log(sectionForm?.values?.section[0].fields);
fields.push(
...sectionForm?.values?.section[0].fields
.filter((field) => field.type && field.inputfield && field.value)
Expand All @@ -176,18 +173,12 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void
}),
);

if (fields.length) {
if (fields.length < 1) {
const response = await axios.post(`https://hng6-r5y3.onrender.com/api/v1/custom/field`, {
customUserSectionId: sectionForm?.values?.section[0]?.id,
fields: fields,
});
return response.data;
} else {
return notify({
message: 'No fields added',
autoClose: 1000,
type: 'error',
});
}
});

Expand All @@ -205,31 +196,31 @@ function CreateCustomSectionContainer({ onClose, userId }: { onClose: () => void
setNewSection(true);
},
onError: (error) => {
console.error('Mutation failed:', error);
notify({
message: 'No fields added',
autoClose: 1000,
type: 'error',
});
},
});
};

const handleSubmit = (values: any) => {
// createNewCustomSectionOption.mutate(undefined, {
// onSuccess: (res) => {
// sectionForm.setFieldValue('section', values?.addList);
// sectionForm.setFieldValue('section.0.id', res?.data?.id);
// setGetNewSection(true);
// setNewSection(false);
// },
// onError: () => {
// notify({
// message: 'An error occurred please try again',
// autoClose: 1000,
// type: 'error',
// });
// },
// });
sectionForm.setFieldValue('section', values?.addList);
// sectionForm.setFieldValue('section.0.id', res?.data?.id);
setGetNewSection(true);
setNewSection(false);
createNewCustomSectionOption.mutate(undefined, {
onSuccess: (res) => {
sectionForm.setFieldValue('section', values?.addList);
sectionForm.setFieldValue('section.0.id', res?.data?.id);
setGetNewSection(true);
setNewSection(false);
},
onError: () => {
notify({
message: 'An error occurred please try again',
autoClose: 1000,
type: 'error',
});
},
});
};

const handleClose = () => {
Expand Down
6 changes: 3 additions & 3 deletions modules/shop/component/productPage/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const Header: React.FC<HeaderProps> = ({
</Link>
<Link
onClick={handleAuthMenu}
href={`/portfolio/${globalAuth?.user?.slug}`}
href={`/portfolio/${globalAuth?.user?.slug}/manage`}
className=" border-[#EBEEEF] cursor-pointer hover:bg-[#F4FBF6] py-5 px-4 flex gap-6 "
>
<Image draggable={false} src={briefCaseIcon} alt="Briefcase icon" />
Expand Down Expand Up @@ -634,8 +634,8 @@ function MenuUI({
</div>
<div className=" group flex flex-col ali justify-center gap-1 ">
<Link
className={activeLink(`/portfolio/${globalAuth?.user?.slug}`)}
href={`/portfolio/${globalAuth?.user?.slug}`}
className={activeLink(`/portfolio/${globalAuth?.user?.slug}/manage`)}
href={`/portfolio/${globalAuth?.user?.slug}/manage`}
>
Manage Portfolio
</Link>
Expand Down

0 comments on commit 0dcf746

Please sign in to comment.