ar-design 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,7 @@ import { ARIcon } from "../../icons";
|
|
|
5
5
|
import Dropzone from "./Dropzone";
|
|
6
6
|
import Button from "../button";
|
|
7
7
|
import List from "./List";
|
|
8
|
+
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
8
9
|
const Upload = ({ text, files, onChange, allowedTypes, maxSize, type = "list", multiple }) => {
|
|
9
10
|
// refs
|
|
10
11
|
const _firstLoad = useRef(false);
|
|
@@ -133,7 +134,9 @@ const Upload = ({ text, files, onChange, allowedTypes, maxSize, type = "list", m
|
|
|
133
134
|
})();
|
|
134
135
|
}, [selectedFiles]);
|
|
135
136
|
useEffect(() => {
|
|
136
|
-
if (_firstLoad.current)
|
|
137
|
+
if (!_firstLoad.current && files.length === 0)
|
|
138
|
+
return;
|
|
139
|
+
if (Utils.DeepEqual(files, selectedFiles))
|
|
137
140
|
return;
|
|
138
141
|
setSelectedFiles(files);
|
|
139
142
|
_firstLoad.current = true;
|
|
@@ -2,11 +2,13 @@ declare class Api {
|
|
|
2
2
|
private _host?;
|
|
3
3
|
private _core?;
|
|
4
4
|
private _init?;
|
|
5
|
+
private _token?;
|
|
5
6
|
private _url;
|
|
6
7
|
constructor(values: {
|
|
7
8
|
host?: string;
|
|
8
9
|
core?: string;
|
|
9
10
|
init?: RequestInit;
|
|
11
|
+
token?: string;
|
|
10
12
|
});
|
|
11
13
|
Get(values: {
|
|
12
14
|
input?: RequestInfo | undefined;
|
|
@@ -38,6 +40,7 @@ declare class Api {
|
|
|
38
40
|
init?: RequestInit;
|
|
39
41
|
}): Promise<Response>;
|
|
40
42
|
private HeaderProperties;
|
|
43
|
+
private Cookies;
|
|
41
44
|
/**
|
|
42
45
|
* Burada bir fetch işlemi gerçekleştirilmekte fakat farklı olarak burayı `interceptor` olarak kullanmaktayız.
|
|
43
46
|
* @param input
|
|
@@ -2,6 +2,7 @@ class Api {
|
|
|
2
2
|
_host;
|
|
3
3
|
_core;
|
|
4
4
|
_init;
|
|
5
|
+
_token;
|
|
5
6
|
_url;
|
|
6
7
|
constructor(values) {
|
|
7
8
|
this._host = values.host || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -91,8 +92,20 @@ class Api {
|
|
|
91
92
|
return {
|
|
92
93
|
Accept: "application/json",
|
|
93
94
|
"Content-Type": "application/json",
|
|
95
|
+
...(this._token && { Authorization: `Bearer ${this.Cookies(this._token)}` }),
|
|
94
96
|
};
|
|
95
97
|
};
|
|
98
|
+
Cookies = (name) => {
|
|
99
|
+
if (typeof window === "undefined")
|
|
100
|
+
return undefined;
|
|
101
|
+
const cookies = document.cookie.split("; ");
|
|
102
|
+
const cookieObject = [];
|
|
103
|
+
cookies.forEach((cookie) => {
|
|
104
|
+
const [key, value] = cookie.split("=");
|
|
105
|
+
cookieObject.push({ key: key, value: value });
|
|
106
|
+
});
|
|
107
|
+
return decodeURIComponent(cookieObject.find((x) => x.key === name)?.value ?? "");
|
|
108
|
+
};
|
|
96
109
|
/**
|
|
97
110
|
* Burada bir fetch işlemi gerçekleştirilmekte fakat farklı olarak burayı `interceptor` olarak kullanmaktayız.
|
|
98
111
|
* @param input
|
|
@@ -3,7 +3,7 @@ class Service {
|
|
|
3
3
|
_api;
|
|
4
4
|
_endPoint;
|
|
5
5
|
constructor(values) {
|
|
6
|
-
this._api = new Api({ host: values.host, core: values.core, init: values.init });
|
|
6
|
+
this._api = new Api({ host: values.host, core: values.core, init: values.init, token: values.token });
|
|
7
7
|
this._endPoint = values.endPoint;
|
|
8
8
|
}
|
|
9
9
|
async Get(values) {
|