Fakultas Ilmu Komputer UI

Commit 664e2400 authored by Giovan Isa Musthofa's avatar Giovan Isa Musthofa
Browse files

Merge branch 'warmfix-cors-and-register-api' into 'staging'

Warmfix post sprint review 2

See merge request !38
parents 549deb5b f3af422f
Pipeline #39423 failed with stages
in 16 minutes and 31 seconds
......@@ -141,6 +141,10 @@ STATIC_ROOT = 'static_root/'
CORS_ORIGIN_WHITELIST = [
"http://localhost:8000",
"http://localhost:8080",
"https://dblood-staging.netlify.app",
"https://dblood.netlify.app",
"https://dblood-staging.netlify.com",
"https://dblood.netlify.com",
]
......
......@@ -6,6 +6,18 @@ axios.defaults.baseURL = BASE_API_URL
export const getListJadwalDonor = date =>
axios.get(`/donor/jadwal/?date=${date}`)
export const postRegisterFull = data =>
axios.post(
"/auth/register-full/",
{
email: data.email,
password: data.password,
first_name: data.first_name,
profile: data,
},
{ mode: "cors" }
)
export const postUserLogin = (email, password) =>
axios.post(
"/auth/access/",
......
import React from "react"
import { Form } from "react-bootstrap"
import { useForm } from "react-hook-form"
import * as yup from "yup"
import axios from "axios"
import { BASE_API_URL } from "../config"
import { postRegisterFull } from "../api"
import ModalRegisterAccount from "./register-account"
......@@ -17,7 +15,7 @@ const ModalRegister = ({ show, handleClose }) => {
.string()
.min(8, "Password terlalu pendek - setidaknya harus 8 karakter.")
.matches(
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/,
/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/,
"Password harus terdiri dari minimal 1 huruf kecil, 1 huruf kapital, 1 angka, dan 1 karakter spesial (!@#$%^&*)."
)
.required("Masukkan password."),
......@@ -28,7 +26,7 @@ const ModalRegister = ({ show, handleClose }) => {
first_name: yup
.string()
.matches(
/^(?=^.{5,70}$)^[A-Za-z]+([\ A-Za-z]+)*$/,
/^(?=^.{5,70}$)^[A-Za-z]+([ A-Za-z]+)*$/,
"Masukkan nama yang valid."
)
.required("Masukkan nama."),
......@@ -69,27 +67,25 @@ const ModalRegister = ({ show, handleClose }) => {
validationSchema: schema,
})
const onSubmit = async data => {
await axios({
method: "post",
url: `${BASE_API_URL}/auth/register-full/`,
timeout: 60000,
data: {
email: data.email,
password: data.password,
first_name: data.first_name,
profile: data,
},
postRegisterFull({
email: data.email,
password: data.password,
first_name: data.first_name,
profile: data,
})
.then(response => {
console.log(response.data)
window.alert(
"Silakan verifikasi email terlebih dahulu di " +
response.data.email +
" untuk login."
),
location.reload()
)
})
.catch(error => {
console.log(error)
if (error.response) {
window.alert(JSON.stringify(error.response.data))
}
})
.catch(error => console.error("timeout exceeded"))
}
return (
<>
......
......@@ -20,6 +20,7 @@ const AuthProvider = props => {
setUser(user)
} catch (error) {
// do nothing if the token is invalid
console.log(error)
}
}
useEffect(() => {
......
import React from "react"
import Card from "../../components/card"
import Layout from "../../components/layout"
import SEO from "../../components/seo"
import useIsMounted from "../../hooks/is-mounted"
const EmailVerificationFailedPage = () => {
const isMounted = useIsMounted()
return (
<Layout navbar>
<SEO title="Verifikasi Email" />
......
import { fireEvent, render, wait } from "@testing-library/react"
import { render } from "@testing-library/react"
import React from "react"
import EmailVerificationFailedPage from "./failed"
......
import React from "react"
import Card from "../../components/card"
import Layout from "../../components/layout"
import SEO from "../../components/seo"
import useIsMounted from "../../hooks/is-mounted"
const EmailVerificationSuccessPage = () => {
const isMounted = useIsMounted()
return (
<Layout navbar>
<SEO title="Verifikasi Email" />
......
import { fireEvent, render, wait } from "@testing-library/react"
import { render } from "@testing-library/react"
import React from "react"
import EmailVerificationSuccessPage from "./success"
......
import React from "react"
import Layout from "../components/layout"
import SEO from "../components/seo"
import logo from "../images/pmi.png"
import "./profile.scss"
......@@ -17,7 +16,7 @@ const ProfilePage = () => (
<div className="card-body fluid">
<div className="row justify-content-between">
<div className="col-2" id="logo-id">
<img src={logo} className="responsive" />
<img alt={""} src={logo} className="responsive" />
</div>
<div className="col-6" id="id-card">
<p className="card-text">Unit Transfusi Darah</p>
......@@ -52,7 +51,7 @@ const ProfilePage = () => (
<div className="card-body fluid">
<div className="row justify-content-between">
<div className="col-2" id="logo-id">
<img src={logo} className="responsive" />
<img alt={""} src={logo} className="responsive" />
</div>
<div className="col-6" id="id-card">
<p className="card-text">Unit Transfusi Darah</p>
......@@ -85,7 +84,7 @@ const ProfilePage = () => (
<div className="card-body fluid">
<div className="row justify-content-between">
<div className="col-2" id="logo-id">
<img src={logo} className="responsive" />
<img alt={""} src={logo} className="responsive" />
</div>
<div className="col-6" id="id-card">
<p className="card-text">Unit Transfusi Darah</p>
......@@ -117,7 +116,7 @@ const ProfilePage = () => (
<div className="card-body fluid">
<div className="row justify-content-between">
<div className="col-2" id="logo-id">
<img src={logo} className="responsive" />
<img alt={""} src={logo} className="responsive" />
</div>
<div className="col-6" id="id-card">
<p className="card-text">Unit Transfusi Darah</p>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment