Skip to content

Commit

Permalink
add validation schema to create listing form
Browse files Browse the repository at this point in the history
  • Loading branch information
gautvm committed May 16, 2023
1 parent d9646a7 commit 170102c
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/crash_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Steps to reproduce the crash if possible:
Add screenshots here to show any relevant information.

**Browser**

- OS: [e.g. Windows 11]
- Browser: [e.g. Chrome, Safari]

**Additional context**
Add any other context about the problem here.
Add any other context about the problem here.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_not_functioning_unknown.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Steps to reproduce the issue if possible:
Add screenshots to help explain the issue.

**Browser**

- OS: [e.g. Windows 11]
- Browser: [e.g. Chrome, Safari]

**Additional context**
Add any other context about the problem here.
Add any other context about the problem here.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/system_error_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Steps to reproduce the error if possible:
Add screenshots here to show the error message best as possible.

**Browser**

- OS: [e.g. Windows 11]
- Browser: [e.g. Chrome, Safari]

**Additional context**
Add any other context about the problem here.
Add any other context about the problem here.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/ui_bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Steps to reproduce the behavior the UI issue:
Add screenshots here to show the UI issue as best as possible.

**Browser**

- OS: [e.g. Windows 11]
- Browser: [e.g. Chrome, Safari]

**Additional context**
Add any other context about the problem here.
Add any other context about the problem here.
12 changes: 6 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
All Submissions:

* [ ] Have you followed the guidelines in our [Contributing](../../CONTRIBUTING.md) document?
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change?
- [ ] Have you followed the guidelines in our [Contributing](../../CONTRIBUTING.md) document?
- [ ] Have you checked to ensure there aren't other open [Pull Requests](../../../pulls) for the same update/change?

### New Feature Submissions:

Expand All @@ -10,7 +10,7 @@ All Submissions:

### Changes to Core Features:

* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
* [ ] Have you written new tests for your core changes, as applicable?
* [ ] Have you successfully run tests with your changes locally?
* [ ] Does your submission require changes to the database?
- [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
- [ ] Have you written new tests for your core changes, as applicable?
- [ ] Have you successfully run tests with your changes locally?
- [ ] Does your submission require changes to the database?
7 changes: 3 additions & 4 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ on: [pull_request_target]

jobs:
label:

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
17 changes: 8 additions & 9 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: '32 14 * * *'
- cron: "32 14 * * *"

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "Stale issue message"
stale-pr-message: "Stale pull request message"
stale-issue-label: "no-issue-activity"
stale-pr-label: "no-pr-activity"
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
10 changes: 6 additions & 4 deletions components/headers/EventHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export const EventHeader = (props: any) => {
<br />{" "}
{props.event.location_name && (
<a
href={props.event.gmaps_url} target="_blank"
rel="noopener noreferrer"
href={props.event.gmaps_url}
target="_blank"
rel="noopener noreferrer"
>
{props.event.location_name},
</a>
Expand All @@ -56,8 +57,9 @@ export const EventHeader = (props: any) => {
</p>
{props.event.website && props.event.website !== "N/A" && (
<a
href={props.event.website} target="_blank"
rel="noopener noreferrer"
href={props.event.website}
target="_blank"
rel="noopener noreferrer"
>
<Social
icon={FaLink}
Expand Down
4 changes: 3 additions & 1 deletion components/misc/FAQ.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const FAQ = (props: {
className="flex items-center justify-between cursor-pointer text-lightGray hover:text-white transition-all duration-150"
onClick={toggleOpen}
>
<h3 className={`${open && 'text-white'} text-lg font-medium`}>{props.question}</h3>
<h3 className={`${open && "text-white"} text-lg font-medium`}>
{props.question}
</h3>
<FaArrowUp
className={`text-md transform transition-transform ${
open ? "rotate-180 text-white" : ""
Expand Down
39 changes: 27 additions & 12 deletions components/modals/CreateListingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import { IconType } from "react-icons";
import router from "next/router";
import { ListingType } from "@/types/ListingType";
import { codes } from "currency-codes";
import * as yup from "yup";

type Props = {
isOpen: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
};

const currencyOptions = ["USD", ""];
const validationSchema = yup.object().shape({
title: yup.string().required("Title is required"),
price: yup.string().required("Price is required"),
});

const Input = (props: {
className?: string;
placeholder: string;
Expand Down Expand Up @@ -54,18 +59,28 @@ const ModalBody = (props: { setOpen: Dispatch<SetStateAction<boolean>> }) => {
const [currencyType, setCurrencyType] = useState("USD");

const createListing = async () => {
const data = {
title: title,
content: description,
price: price,
type: listingType,
currencyType: currencyType,
};
try {
await validationSchema.validate({
title,
description,
price,
});

const data = {
title: title,
content: description,
price: price,
type: listingType,
currencyType: currencyType,
};

await fetch(`${API_URL}/api/@me/post`, {
method: "POST",
body: JSON.stringify(data),
}).then(() => router.reload());
await fetch(`${API_URL}/api/@me/post`, {
method: "POST",
body: JSON.stringify(data),
}).then(() => router.reload());
} catch (error) {
setErrorMessage((error as Error).message);
}
};

return (
Expand Down
5 changes: 3 additions & 2 deletions components/screens/TeamScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ export const TeamScreen = (props: any) => {
<div className="flex flex-wrap gap-3 md:gap-5 mt-3">
{props.team.website && (
<a
href={props.team.website} target="_blank"
rel="noopener noreferrer"
href={props.team.website}
target="_blank"
rel="noopener noreferrer"
>
<Social
icon={FaLink}
Expand Down
5 changes: 4 additions & 1 deletion components/screens/marketplace/MarketplacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export const MarketplacePage = (props: any) => {
</div>
</div>
<div className="flex justify-center items-center">
<a href={`mailto:${props.marketplacePost.author?.email}`} rel="noopener noreferrer">
<a
href={`mailto:${props.marketplacePost.author?.email}`}
rel="noopener noreferrer"
>
<button className="text-sm ml-auto flex border border-[#2A2A2A] bg-card hover:border-gray-600 py-1 px-4 text-lightGray font-medium rounded-lg">
Contact Seller
</button>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"sharp": "^0.32.1",
"tailwindcss": "3.3.2",
"typescript": "5.0.4",
"use-debounce": "^9.0.4"
"use-debounce": "^9.0.4",
"yup": "^1.1.1"
},
"devDependencies": {
"@commitlint/cli": "^17.6.3",
Expand Down
6 changes: 5 additions & 1 deletion pages/fame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export default function HOFPage() {
<Header
className="flex"
title={
<a href="https://www.firsthalloffame.org/" target="_blank" rel="noopener noreferrer">
<a
href="https://www.firsthalloffame.org/"
target="_blank"
rel="noopener noreferrer"
>
<h1 className="flex text-3xl md:text-5xl font-black text-primary mb-2 hover:text-white">
<FaMedal className="mr-1 md:ml-0 ml-[-10px] md:mb-0 mb-3 w-[50px]" />{" "}
<span className="italic md:mr-3 mr-2">FIRST</span> Hall of Fame
Expand Down
5 changes: 3 additions & 2 deletions pages/teams/[team]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ export default function TeamPage({ user, teamMembers }: any) {
</a>
</Link>
<a
href={event.gmaps_url} target="_blank"
rel="noopener noreferrer"
href={event.gmaps_url}
target="_blank"
rel="noopener noreferrer"
>
<p className="text-lightGray hover:text-white">
{event.location_name &&
Expand Down
30 changes: 30 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3162,6 +3162,11 @@ prop-types@^15.8.1:
object-assign "^4.1.1"
react-is "^16.13.1"

property-expr@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-2.0.5.tgz#278bdb15308ae16af3e3b9640024524f4dc02cb4"
integrity sha512-IJUkICM5dP5znhCckHSv30Q4b5/JA5enCtkRHYaOVOAocnH/1BQEYTC5NMfT3AVl/iXKdr3aqQbQn9DxyWknwA==

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
Expand Down Expand Up @@ -3774,6 +3779,11 @@ through2@^4.0.0:
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==

tiny-case@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-case/-/tiny-case-1.0.3.tgz#d980d66bc72b5d5a9ca86fb7c9ffdb9c898ddd03"
integrity sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==

tippy.js@^6.3.1:
version "6.3.7"
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-6.3.7.tgz#8ccfb651d642010ed9a32ff29b0e9e19c5b8c61c"
Expand All @@ -3793,6 +3803,11 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

toposort@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330"
integrity sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==

trim-newlines@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
Expand Down Expand Up @@ -3883,6 +3898,11 @@ type-fest@^0.8.1:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==

type-fest@^2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz#88068015bb33036a598b952e55e9311a60fd3a9b"
integrity sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==

typed-array-length@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb"
Expand Down Expand Up @@ -4067,6 +4087,16 @@ yocto-queue@^0.1.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

yup@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/yup/-/yup-1.1.1.tgz#49dbcf5ae7693ed0a36ed08a9e9de0a09ac18e6b"
integrity sha512-KfCGHdAErqFZWA5tZf7upSUnGKuTOnsI3hUsLr7fgVtx+DK04NPV01A68/FslI4t3s/ZWpvXJmgXhd7q6ICnag==
dependencies:
property-expr "^2.0.5"
tiny-case "^1.0.3"
toposort "^2.0.2"
type-fest "^2.19.0"

[email protected]:
version "3.21.4"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db"
Expand Down

1 comment on commit 170102c

@vercel
Copy link

@vercel vercel bot commented on 170102c May 16, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.