Skip to content

chore: function to form aplllied #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/FormJoin/FormJoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FormEmail } from '@/components/FormEmail';
import { FormSelect } from '@/components/FormSelect';
import { FormTextarea } from '@/components/FormTextarea';
import { FormUsername } from '@/components/FormUsername';
import contactHandler from '@/pages/api/contact';

export type Inputs = {
name: string;
Expand All @@ -25,8 +26,12 @@ export function FormJoin() {
formState: { errors, dirtyFields }
} = useForm<Inputs>({ mode: 'onChange' });

const onSubmit = (data: Inputs) => {
console.log(data);
const onSubmit = async (data: Inputs) => {
const resopnse = await fetch(`${location.origin}/api/contact`, {
body: JSON.stringify(data),
method: 'POST'
});
console.log(resopnse);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We would like to show some popup that will tell us if it failed or succeed. react-toastify is cool

};

return (
Expand Down
12 changes: 7 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import type { AppProps } from 'next/app';

import { Layout } from '@/layouts';

const App = ({ Component, pageProps }: AppProps) => (
<Layout>
<Component {...pageProps} />
</Layout>
);
const App = ({ Component, pageProps }: AppProps) => {
return (
<Layout>
<Component {...pageProps} />
</Layout>
);
};
Comment on lines +7 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can revert this


export default App;
9 changes: 7 additions & 2 deletions src/pages/api/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === 'POST') {
const { name, email, guild, message } = req.body;
const response = schema.safeParse(req.body);
console.log(req.body);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove console log


if (!response.success) {
const { errors } = response.error;
Expand All @@ -26,10 +27,14 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
const apiUrl = 'https://api.brevo.com/v3/smtp/email';

const emailData = {
sender: { name, email },
sender: {
name: 'Formularz',
email: '[email protected]',
replayTo: { email, name }
},
to: [
{
email: 'kontakt@coderscrew.pl',
email: 'jedrzej.ratajczak@coderscrew.pl',
name: 'Coders Crew'
}
],
Expand Down
26 changes: 15 additions & 11 deletions src/pages/index.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert changes in this file

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useRouter } from 'next/router';

import {
About,
Guilds,
Expand All @@ -8,16 +10,18 @@ import {
Projects
} from '@/containers';

const Index = () => (
<div className="bg-additional-darkWhite">
<Introduction />
<About />
<Guilds />
<Projects />
<Opinions />
<HowWeWork />
<Partnerships />
</div>
);
const Index = () => {
return (
<div className="bg-additional-darkWhite">
<Introduction />
<About />
<Guilds />
<Projects />
<Opinions />
<HowWeWork />
<Partnerships />
</div>
);
};

export default Index;