|
|
@@ -16,10 +16,13 @@ import { ProjectResult } from "@/app/api/projects"; |
|
|
|
import { |
|
|
|
CreateNewExpense, |
|
|
|
PostExpenseData, |
|
|
|
saveProjectExpense, |
|
|
|
} from "@/app/api/projectExpenses/actions"; |
|
|
|
import ExpenseTable from "./ExpenseTable"; |
|
|
|
import dayjs from "dayjs"; |
|
|
|
import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; |
|
|
|
import { submitDialog, successDialog } from "../Swal/CustomAlerts"; |
|
|
|
import { useRouter } from 'next/navigation'; |
|
|
|
|
|
|
|
interface Props { |
|
|
|
isOpen: boolean; |
|
|
@@ -44,6 +47,7 @@ type postData = { |
|
|
|
const CreateExpenseModal: React.FC<Props> = ({ isOpen, onClose, projects }) => { |
|
|
|
const { t } = useTranslation(); |
|
|
|
const formProps = useForm<postData>(); |
|
|
|
const router = useRouter(); |
|
|
|
|
|
|
|
const onSubmit = useCallback<SubmitHandler<postData>>((data) => { |
|
|
|
const _data = data.data; |
|
|
@@ -60,6 +64,17 @@ const CreateExpenseModal: React.FC<Props> = ({ isOpen, onClose, projects }) => { |
|
|
|
}; |
|
|
|
}); |
|
|
|
console.log(postData); |
|
|
|
submitDialog(async () => { |
|
|
|
const response = await saveProjectExpense(postData) |
|
|
|
console.log(response) |
|
|
|
if (response) { |
|
|
|
onClose() |
|
|
|
successDialog(t("Submit Success"), t).then(() => { |
|
|
|
router.replace("/expense"); |
|
|
|
}) |
|
|
|
} |
|
|
|
}, t) |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|