dn-react-router-toolkit 0.1.3 → 0.1.4
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.
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/auth-kit/client/logout.ts
|
|
21
|
+
var logout_exports = {};
|
|
22
|
+
__export(logout_exports, {
|
|
23
|
+
useLogout: () => useLogout
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(logout_exports);
|
|
26
|
+
var import_react_router = require("react-router");
|
|
27
|
+
function useLogout() {
|
|
28
|
+
const navigate = (0, import_react_router.useNavigate)();
|
|
29
|
+
const logout = async () => {
|
|
30
|
+
const ok = confirm("\uC815\uB9D0 \uB85C\uADF8\uC544\uC6C3 \uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?");
|
|
31
|
+
if (!ok) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const res = await fetch("/api/auth/logout", {
|
|
35
|
+
method: "POST"
|
|
36
|
+
});
|
|
37
|
+
if (res.ok) {
|
|
38
|
+
navigate("/");
|
|
39
|
+
} else {
|
|
40
|
+
const { message } = await res.json();
|
|
41
|
+
alert(message);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return logout;
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
useLogout
|
|
49
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/auth-kit/client/logout.ts
|
|
2
|
+
import { useNavigate } from "react-router";
|
|
3
|
+
function useLogout() {
|
|
4
|
+
const navigate = useNavigate();
|
|
5
|
+
const logout = async () => {
|
|
6
|
+
const ok = confirm("\uC815\uB9D0 \uB85C\uADF8\uC544\uC6C3 \uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?");
|
|
7
|
+
if (!ok) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const res = await fetch("/api/auth/logout", {
|
|
11
|
+
method: "POST"
|
|
12
|
+
});
|
|
13
|
+
if (res.ok) {
|
|
14
|
+
navigate("/");
|
|
15
|
+
} else {
|
|
16
|
+
const { message } = await res.json();
|
|
17
|
+
alert(message);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return logout;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
useLogout
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dn-react-router-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"drizzle-orm": "^0.44",
|
|
79
|
-
"react": "^
|
|
80
|
-
"react-dom": "^
|
|
79
|
+
"react": "^18.2.0",
|
|
80
|
+
"react-dom": "^18.2.0",
|
|
81
81
|
"react-router": "^7"
|
|
82
82
|
}
|
|
83
83
|
}
|