Merge pull request 'Update' (#104) from that-fe into master

Reviewed-on: #104
This commit is contained in:
joseph 2025-02-07 19:32:13 +11:00
commit 5165ded25e
3 changed files with 19 additions and 11 deletions

View File

@ -55,8 +55,6 @@
display: flex; display: flex;
margin-top: 20px; margin-top: 20px;
gap: 10px; gap: 10px;
max-height: 72vh;
overflow-y: scroll;
} }
.titleSidebar { .titleSidebar {

View File

@ -103,6 +103,9 @@ const StaffEvaluation = () => {
name: '', name: '',
role: '', role: '',
note: '', note: '',
user_id: 0,
created_at: '',
updated_at: '',
}, },
validate: { validate: {
name: (value) => name: (value) =>
@ -511,9 +514,10 @@ const StaffEvaluation = () => {
const handleCreate = async (values: DataProjectReview) => { const handleCreate = async (values: DataProjectReview) => {
try { try {
const { id, ...data } = values
const res = await post(projectReviewAdd, { const res = await post(projectReviewAdd, {
...data, name: values.name,
role: values.role,
note: values.note,
user_id: filter.userID, user_id: filter.userID,
}) })
if (res.id) { if (res.id) {
@ -530,7 +534,10 @@ const StaffEvaluation = () => {
const handleUpdate = async (values: DataProjectReview) => { const handleUpdate = async (values: DataProjectReview) => {
try { try {
const res = await update(projectReviewUpdate, { const res = await update(projectReviewUpdate, {
...values, id: values.id,
name: values.name,
role: values.role,
note: values.note,
user_id: filter.userID, user_id: filter.userID,
}) })
if (res) { if (res) {

View File

@ -3,7 +3,6 @@ import { getFormDataHeader, getHeaderInfo } from '@/rtk/helpers/tokenCreator'
import { removeTokens } from '@/rtk/localStorage' import { removeTokens } from '@/rtk/localStorage'
import { notifications } from '@mantine/notifications' import { notifications } from '@mantine/notifications'
import axios from 'axios' import axios from 'axios'
import moment from 'moment'
const handleResponse = (response: any) => { const handleResponse = (response: any) => {
if (response.status === 401) { if (response.status === 401) {
removeTokens() removeTokens()
@ -158,14 +157,18 @@ export const postImage = async (url: string, body: any, method: any) => {
} }
} }
export const exportFile = async (url: string, params: any = {}, fileName: string) => { export const exportFile = async (
url: string,
params: any = {},
fileName: string,
) => {
const header = await getHeaderInfo() const header = await getHeaderInfo()
try { try {
const response = await axios.get(url, { const response = await axios.get(url, {
...header, ...header,
params, params,
responseType: 'blob' responseType: 'blob',
}) })
if (response.status === 200) { if (response.status === 200) {
@ -174,7 +177,7 @@ export const exportFile = async (url: string, params: any = {}, fileName: string
const link = document.createElement('a') const link = document.createElement('a')
link.href = downloadUrl link.href = downloadUrl
link.download = fileName link.download = fileName
document.body.appendChild(link) document.body.appendChild(link)
link.click() link.click()
window.URL.revokeObjectURL(downloadUrl) window.URL.revokeObjectURL(downloadUrl)
@ -188,7 +191,7 @@ export const exportFile = async (url: string, params: any = {}, fileName: string
return true return true
} }
throw new Error('Export failed') throw new Error('Export failed')
} catch (error: any) { } catch (error: any) {
notifications.show({ notifications.show({