Fakultas Ilmu Komputer UI

Commit ffcc0ee4 authored by Muhammad Dzikra Muzaki's avatar Muhammad Dzikra Muzaki
Browse files

[REFACTOR] Fix issues according to SonarQube

parent 1803369e
Pipeline #76187 passed with stages
in 3 minutes and 35 seconds
This diff is collapsed.
import React from "react";
import { useForm } from "react-hook-form";
import useSendData from "../../utils/useSendData";
import {
ErrorDiv
} from "../../component/html/html";
import { css } from "@emotion/core";
import Button from "@material-ui/core/Button";
import SystemUpdateAltIcon from '@material-ui/icons/SystemUpdateAlt';
const FormDonasi = ({ idDonasi, defaultStatus }) => {
const url = `${process.env.REACT_APP_BASE_URL}/program-donations/${idDonasi}/`;
const { handleSubmit } = useForm({
defaultValues: {
donation_status: defaultStatus,
},
});
const [send, errorSend] = useSendData({
url,
header: { "Content-Type": "application/json" },
method: "PUT",
redirect: `/donasi-barang/`,
});
const onSubmit = (data) => {
data = {
donation_status : "002",
}
send(JSON.stringify({ ...data }));
};
return (
<div data-testid="form-status">
{errorSend && <ErrorDiv>Status donasi tidak dapat disimpan</ErrorDiv>}
<form
onSubmit={handleSubmit(onSubmit)}
css={css`
display: flex;
`}
>
<Button
data-testid="button-submit-status"
type="submit"
variant="contained"
color="primary"
endIcon={<SystemUpdateAltIcon />}
>
Donasi Diterima
</Button>
</form>
</div>
);
};
export default FormDonasi;
import React from "react";
import { useForm } from "react-hook-form";
import useSendData from "../../utils/useSendData";
import {
ErrorDiv
} from "../../component/html/html";
import { css } from "@emotion/core";
import Button from "@material-ui/core/Button";
import SystemUpdateAltIcon from '@material-ui/icons/SystemUpdateAlt';
const FormDonasiBarang = ({ idDonasi, defaultStatus }) => {
const url = `${process.env.REACT_APP_BASE_URL}/program-donations/${idDonasi}/`;
const { handleSubmit } = useForm({
defaultValues: {
donation_status: defaultStatus,
},
});
const [send, errorSend] = useSendData({
url,
header: { "Content-Type": "application/json" },
method: "PUT",
redirect: `/donasi-barang/`,
});
const onSubmit = (data) => {
data = {
donation_status : "002",
}
send(JSON.stringify({ ...data }));
};
return (
<div data-testid="form-status">
{errorSend && <ErrorDiv>Status donasi tidak dapat disimpan</ErrorDiv>}
<form
onSubmit={handleSubmit(onSubmit)}
css={css`
display: flex;
`}
>
<Button
data-testid="button-submit-status"
type="submit"
variant="contained"
color="primary"
endIcon={<SystemUpdateAltIcon />}
>
Donasi Diterima
</Button>
</form>
</div>
);
};
export default FormDonasiBarang;
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