fixing the size on reset

This commit is contained in:
2026-03-15 10:05:56 -04:00
parent 5ef55ff8dd
commit 90f4dcb10c

View File

@@ -10,8 +10,9 @@ const QRForm: React.FC = () => {
const { state, dispatch } = useQrStore();
const { text, size, loading } = state;
const callingApi = async (overrideText?: string) => {
const callingApi = async (overrideText?: string, overrideSize?: number) => {
const currentText = overrideText ?? text;
const currentSize = overrideSize ?? size;
dispatch({ type: 'setError', payload: null });
dispatch({ type: 'setImageUrl', payload: null });
@@ -22,7 +23,7 @@ const QRForm: React.FC = () => {
dispatch({ type: 'setLoading', payload: true });
try {
const payload = { text: currentText, size };
const payload = { text: currentText, size: currentSize };
const res: GenerateResult = await generateQr(payload);
const blobType = { type: res.mime };
const blob = new Blob([res.data], blobType);
@@ -56,7 +57,7 @@ const QRForm: React.FC = () => {
useEffect(() => {
if (callApiOnReset) {
callingApi(initialState.text);
callingApi(initialState.text, initialState.size);
setCallApiOnReset(false);
}
}, [callApiOnReset, callingApi]);