Skip to content
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

get storybook working for signup form #195

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { Meta, StoryObj } from "@storybook/react"

import SignUpForm from "./SignUpForm"
import { BrowserRouter } from "react-router-dom"

// 👇 This default export determines where your story goes in the story list
const meta: Meta<typeof SignUpForm> = {
Expand All @@ -12,6 +13,13 @@ export default meta
type Story = StoryObj<typeof SignUpForm>

export const FirstStory: Story = {
decorators: [
(Story) => (
<BrowserRouter>
<Story />
</BrowserRouter>
)
],
args: {
// 👇 The args you need here will depend on your component
}
Expand Down
29 changes: 0 additions & 29 deletions client/src/components/composite/SignUpForm/SignUpForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import React, { useState } from "react"
import {
getAuth,
createUserWithEmailAndPassword,
updateProfile
} from "firebase/auth"
import { useNavigate } from "react-router-dom"
import { db } from "../../../firebase"
import { setDoc, doc } from "firebase/firestore"
import Button from "@mui/material/Button"
import TextField from "@mui/material/TextField"
import Snackbar from "@mui/material/Snackbar"
Expand Down Expand Up @@ -62,7 +55,6 @@ const SignUpForm = () => {
setOpen(false)
}

const auth = getAuth()
const navigate = useNavigate()

const handleSubmit = async (event: any) => {
Expand Down Expand Up @@ -106,29 +98,8 @@ const SignUpForm = () => {
}

try {
const { user } = await createUserWithEmailAndPassword(
auth,
email,
password
)
console.log("User created")

await updateProfile(user, { displayName: `${firstName} ${lastName}` })
console.log("Profile updated")

await setDoc(doc(db, "users", user.uid), {
uid: user.uid,
firstName,
lastName,
email,
phoneNumber,
dob,
studentId,
yearLevel,
faculty,
sportType,
interestedInRacing
})
console.log("Document set in Firestore")

setOpen(true)
Expand Down
Loading