Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
feat: form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Jun 21, 2023
1 parent 6fcac61 commit b00f727
Show file tree
Hide file tree
Showing 13 changed files with 458 additions and 149 deletions.
3 changes: 2 additions & 1 deletion components/form/Input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default function Input({
type = "text",
name,
value,
placeholder,
Expand All @@ -14,7 +15,7 @@ export default function Input({
</label>
)}
<input
type="text"
type={type}
placeholder={placeholder}
className={`border-2 transition-all duration-250 ease-linear rounded px-6 py-2 mb-2 block w-full ${
disabled
Expand Down
72 changes: 48 additions & 24 deletions components/layouts/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,51 @@ import { MDXProvider } from "@mdx-js/react";
import Head from "next/head";

import Page from "@components/Page";
import Link from "@components/Link";
import { ComponentStyle } from "@components/mdx/ComponentStyle";
import BreadCrumb from "@components/BreadCrumb";
import SideNav from "@components/navbar/SideNav";

import {
CalendarIcon,
ChartPieIcon,
DocumentDuplicateIcon,
FolderIcon,
HomeIcon,
UsersIcon,
} from "@heroicons/react/24/outline";

export const navigation = [
{ name: "Dashboard", href: "#", icon: HomeIcon, current: true },
{
name: "Teams",
icon: UsersIcon,
current: false,
children: [
{ name: "Engineering", href: "#" },
{ name: "Human Resources", href: "#" },
{ name: "Customer Success", href: "#" },
],
},
{
name: "Projects",
icon: FolderIcon,
current: false,
children: [
{ name: "GraphQL API", href: "#" },
{ name: "iOS App", href: "#" },
{ name: "Android App", href: "#" },
{ name: "New Customer Portal", href: "#" },
],
},
{ name: "Calendar", href: "#", icon: CalendarIcon, current: false },
{
name: "Documents",
href: "#",
icon: DocumentDuplicateIcon,
current: false,
},
{ name: "Reports", href: "#", icon: ChartPieIcon, current: false },
];

export default function DocsLayout({ children, title, section, name }) {
return (
Expand All @@ -18,29 +60,11 @@ export default function DocsLayout({ children, title, section, name }) {
<link rel="icon" href="/favicon.ico" />
</Head>
<Page>
<BreadCrumb section={section} name={name}></BreadCrumb>
<h1 className="mb-4 font-bold text-2xl md:text-4xl">Documentation</h1>
<p>
Here you should find everything you need from getting started with
creating your Profile to more advanced topics. We welcome
contributions, check out the&nbsp;
<Link
target="_blank"
href="https://github.com/EddieHubCommunity/LinkFree"
>
LinkFree Repo
</Link>
&nbsp; and the&nbsp;
<Link
target="_blank"
href="https://github.com/EddieHubCommunity/LinkFree/tree/main/pages/docs"
>
documentation source
</Link>{" "}
on GitHub for more information.
</p>
<div className="float-none my-0 max-w-[1440px] prose ">
<div className="flex flex-grow flex-row">
<BreadCrumb section={section} name={name} />

<div className="flex flex-grow flex-row">
<SideNav navigation={navigation} />
<div className="float-none my-0 max-w-[1440px] prose">
<MDXProvider components={ComponentStyle}>
<div className="w-full max-w-7xl px-4 sm:px-6 lg:px-8 dark:text-white">
{children}
Expand Down
75 changes: 75 additions & 0 deletions components/navbar/SideNav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Disclosure } from "@headlessui/react";
import { ChevronRightIcon } from "@heroicons/react/20/solid";

function classNames(...classes) {
return classes.filter(Boolean).join(" ");
}

export default function SideNav({ navigation }) {
return (
<ul role="list" className="w-64 flex-none invisible sm:visible">
{navigation.map((item) => (
<li key={item.name}>
{!item.children ? (
<a
href={item.href}
className={classNames(
item.current ? "bg-gray-50" : "hover:bg-gray-50",
"group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold text-gray-700"
)}
>
<item.icon
className="h-6 w-6 shrink-0 text-gray-400"
aria-hidden="true"
/>
{item.name}
</a>
) : (
<Disclosure as="div">
{({ open }) => (
<>
<Disclosure.Button
className={classNames(
item.current ? "bg-gray-50" : "hover:bg-gray-50",
"flex items-center w-full text-left rounded-md p-2 gap-x-3 text-sm leading-6 font-semibold text-gray-700"
)}
>
<item.icon
className="h-6 w-6 shrink-0 text-gray-400"
aria-hidden="true"
/>
{item.name}
<ChevronRightIcon
className={classNames(
open ? "rotate-90 text-gray-500" : "text-gray-400",
"ml-auto h-5 w-5 shrink-0"
)}
aria-hidden="true"
/>
</Disclosure.Button>
<Disclosure.Panel as="ul" className="mt-1 px-2">
{item.children.map((subItem) => (
<li key={subItem.name}>
{/* 44px */}
<Disclosure.Button
as="a"
href={subItem.href}
className={classNames(
subItem.current ? "bg-gray-50" : "hover:bg-gray-50",
"block rounded-md py-2 pr-2 pl-9 text-sm leading-6 text-gray-700"
)}
>
{subItem.name}
</Disclosure.Button>
</li>
))}
</Disclosure.Panel>
</>
)}
</Disclosure>
)}
</li>
))}
</ul>
);
}
89 changes: 14 additions & 75 deletions models/Profile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import mongoose from "mongoose";
import mongoose, { Schema } from "mongoose";

const ProfileSchema = new mongoose.Schema(
import { MilestoneSchema } from "./Profile/Milestone";
import { EventSchema } from "./Profile/Event";

const ProfileSchema = new Schema(
{
source: {
type: String,
Expand Down Expand Up @@ -55,42 +58,12 @@ const ProfileSchema = new mongoose.Schema(
},
links: {
default: [],
type: [{ type: mongoose.Schema.Types.ObjectId, ref: "Link" }],
type: [{ type: Schema.Types.ObjectId, ref: "Link" }],
},
milestones: {
type: [MilestoneSchema],
default: [],
},
milestones: [
{
url: {
type: String,
required: true,
min: 2,
max: 256,
},
date: {
type: Date,
required: true,
},
isGoal: Boolean,
title: {
type: String,
required: true,
min: 2,
max: 256,
},
icon: {
type: String,
required: true,
min: 2,
max: 32,
},
description: {
type: String,
required: true,
min: 2,
max: 512,
},
order: Number,
},
],
testimonials: [
{
username: {
Expand Down Expand Up @@ -119,44 +92,10 @@ const ProfileSchema = new mongoose.Schema(
isPinned: Boolean,
},
],
events: [
{
isVirtual: Boolean,
color: String,
name: {
type: String,
required: true,
min: 2,
max: 256,
},
description: {
type: String,
required: true,
min: 2,
max: 512,
},
date: {
start: {
type: Date,
required: true,
},
end: {
type: Date,
required: true,
},
},
url: {
type: String,
required: true,
min: 2,
max: 256,
},
order: Number,
price: {
startingFrom: Number,
},
},
],
events: {
type: [EventSchema],
default: [],
},
},
{ timestamps: true }
);
Expand Down
47 changes: 47 additions & 0 deletions models/Profile/Event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import mongoose, { Schema } from "mongoose";

const EventSchema = new Schema({
isVirtual: Boolean,
name: {
type: String,
required: true,
min: 2,
max: 256,
},
description: {
type: String,
required: true,
min: 2,
max: 512,
},
date: {
type: new Schema({
start: {
type: Date,
},
end: {
type: Date,
},
}),
required: true,
},
url: {
type: String,
required: true,
min: 2,
max: 256,
},
order: Number,
price: {
startingFrom: Number,
},
});

EventSchema.pre("save", () => {
throw new Error("This is a nested document, no need to save it directly");
});

module.exports = {
EventSchema,
Event: mongoose.models.Event || mongoose.model("Event", EventSchema),
};
44 changes: 44 additions & 0 deletions models/Profile/Milestone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import mongoose, { Schema } from "mongoose";

const MilestoneSchema = new Schema({
url: {
type: String,
required: false,
min: 2,
max: 256,
},
date: {
type: Date,
required: true,
},
isGoal: Boolean,
title: {
type: String,
required: true,
min: 2,
max: 256,
},
icon: {
type: String,
required: true,
min: 2,
max: 32,
},
description: {
type: String,
required: true,
min: 2,
max: 512,
},
order: Number,
});

MilestoneSchema.pre("save", () => {
throw new Error("This is a nested document, no need to save it directly");
});

module.exports = {
MilestoneSchema,
Milestone:
mongoose.models.Milestone || mongoose.model("Milestone", MilestoneSchema),
};
Loading

0 comments on commit b00f727

Please sign in to comment.