Skip to content

Conversation

@jeflijonathan2327240094
Copy link

@jeflijonathan2327240094 jeflijonathan2327240094 commented Aug 1, 2024

  • add submission page
  • add submission context and custom hook in submission page
  • add the uploaded image to the proof of payment upload form and a good file upload system
  • quick note to speed up note filling
  • add global component dialog and custom hook dialog.
  • the add global component button and the addition of the image downloader utils
  • user search dialog to search for users registered with admin and fill in the fields, you can use npm and the registered name.
  • add handle every error possibility
    new package:
  • notistack are used to provide error, warning, and success notifications.
    ui:
    submission Kas
    dialog
    image
    image

@fanesz
Copy link
Contributor

fanesz commented Aug 1, 2024

@jeflijonathan2327240094 git pull origin development trus fix conflict

@Rendy752 Rendy752 force-pushed the feature/create-kas-submission branch from c937c5e to ba48f60 Compare August 1, 2024 08:16
@jeflijonathan2327240094 jeflijonathan2327240094 linked an issue Aug 1, 2024 that may be closed by this pull request
6 tasks
Copy link
Contributor

@fanesz fanesz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untuk sementara ini dulu, baru aku review dari segi penulisan kode, untuk UI dan fungsionalitas itu nanti.

Rombak folder structure, samain polanya kayak yg admin - financial request.
jadi harusnya pages/KasSubmission, baru didalemnya ada context, hooks, partials.
trus karena ada fitur spesifik, bikin folder List yg isinya komponen dan hooks untuk nampilin list. Trus folder Create. intinya pahamin dan ikutin aja pattern yg procom-admin

kalo ada pertanyaan/bingung/kendala/error, feel free pm aku

package.json Outdated
"react-loading-skeleton": "^3.4.0",
"react-router-dom": "^6.23.1",
"sweetalert2": "^11.12.3",
"sweetalert2-react-content": "^5.0.7",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buang 2 package ini kalo cuma untuk error notifikasi, pake snackbar yg sudah di develop disini

src/api/index.ts Outdated
Accept: "application/json",
"Content-type": "application/json",
};
headers: Headers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

konsep headers ini di rombak lagi, untuk default headers, ttp pake application/json,
trus bikin 1 method baru, POSTFORM (referensi), nah method ini ngeassign manual headers dengan tipe multipart/form-data, dll.

src/api/index.ts Outdated
} catch (err: AxiosError | any) {
if (isAxiosError(err)) {
return err?.response?.data;
console.error("Axios error:", err.message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buang console log dan commend di file ini

evidence: string;
};

export default class CreateKasService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cek lagi naming patternnya, harusnya ini KasSubmissionService, file pagesnya juga jangan spesifik di CreateKas, cek lagi di admin repo yang financial request, disitu ada folder FinancialRequest/Create, disitu baru taro logic dan component untuk create

userPath: string = "/users";
private api: API = new API();
private apiForm: API = new API({ isForm: true });
async post(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tolong newline spacing di perhatiin, cek lagi yg admin, dimana mana harus pake breakpoint newline

Comment on lines 82 to 84
{loading ? (
<div>Loading...</div>
) : (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loading ini harusnya di parent kayak gini.
jadi nampilin loading dialog dulu, baru nampilin actual dialog with data

export type UploadImageRequest = {
file: File;
};
export default class UploadImage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhatiin namanya, harusnya FileService

import { useRef, useEffect } from "react";
import { useCreateKasContext } from "@pages/CreateKas/context/index";
import glassmorphism from "@utils/glassmorphism";
const QuickNote = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note ini untuk apa? kok banyak event listener gini

import UploadImage from "./UploadImage";
import useCreateKasSubmission from "../hooks/useCreateKasSubmission";
import SearchUser from "./SearchUser";
const KasBody: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

untuk seluruh file, perhatiin newline break, setelah import itu dikasih line break

@Rendy752
Copy link
Contributor

ada error syntax pas pertama kali open kas submission
image

@Rendy752
Copy link
Contributor

untuk drag file emang g bisa ya? kalo iya ubah placholder nya jadi "Select image to upload" dengan ubah file accept type ny cuma .png, .jpg aja
image

@Rendy752
Copy link
Contributor

Rendy752 commented Feb 12, 2025

image
Ini optional aja, buat minimalisir user salah upload image, bisa pake 2 pendekatan:

  1. tambah button "X" diujung atas kanan image preview untuk delete image pake api delete /file/images/:id file-upload-controller
  2. atau buat image yang udah diupload cuma nge store data file di frontend dlu, jadi blum hit api post /file/images, untuk buat url untuk di preview image nya pake FileReader bawaan
    file-upload.tsx
    const [previewUrl, setPreviewUrl] = useState<string | null>(null);
    useEffect(() => { const reader = new FileReader(); reader.onloadend = () => { setPreviewUrl(reader.result as string); }; reader.readAsDataURL(file); }, [file]);
    jadi pas sudah klik button submit submission, hit api post /file/images, dpetin id untuk image dlu, lalu passing ke data kas submission untuk di submit semua data nya

@Rendy752 Rendy752 self-requested a review February 12, 2025 12:57
@@ -0,0 +1,18 @@
export const LocalStorage = (key: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

penamaan pascal case itu biasanya untuk nama class atau component.
kalo cuma variable/function, pake camel case

Suggested change
export const LocalStorage = (key: string) => {
export const localStorage = (key: string) => {

import useGetUser from "../hooks/useGetUser";
import { LocalStorage } from "@utils/localStorage";

const SearchUser = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

penamaan komponen bikin lebih spesifik,
misal SearchUserButton

import { useFormContext } from "react-hook-form";
import { LocalStorage } from "@utils/localStorage";

const QuickNote: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

penamaan komponen bikin lebih spesifik

import glassmorphism from "@utils/glassmorphism";
import { Controller, useFormContext } from "react-hook-form";

const PayedAmount: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

penamaan komponen bikin lebih spesifik

handleActiveUser: () => void;
}

const useGetUser = (): HookReturn => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terlalu spesifik, kalo getUser lebih jadi kayak usecase, bukan hooks,
mending useUser. yg relate dgn user, taruh disini nanti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature/Create Kas Submission

5 participants