@sikka/hawa 0.0.1 → 0.0.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.
- package/.github/workflows/hawa-publish-push.yml +45 -0
- package/.github/workflows/hawa-publish.yml +45 -0
- package/.prettierrc +28 -28
- package/README.md +149 -119
- package/es/index.es.js +1 -0
- package/lib/index.js +1 -0
- package/package.json +59 -47
- package/rollup.config.js +30 -40
- package/src/Assets/images/card-background/1.jpeg +0 -0
- package/src/Assets/images/card-background/10.jpeg +0 -0
- package/src/Assets/images/card-background/11.jpeg +0 -0
- package/src/Assets/images/card-background/12.jpeg +0 -0
- package/src/Assets/images/card-background/13.jpeg +0 -0
- package/src/Assets/images/card-background/14.jpeg +0 -0
- package/src/Assets/images/card-background/15.jpeg +0 -0
- package/src/Assets/images/card-background/16.jpeg +0 -0
- package/src/Assets/images/card-background/17.jpeg +0 -0
- package/src/Assets/images/card-background/18.jpeg +0 -0
- package/src/Assets/images/card-background/19.jpeg +0 -0
- package/src/Assets/images/card-background/2.jpeg +0 -0
- package/src/Assets/images/card-background/20.jpeg +0 -0
- package/src/Assets/images/card-background/21.jpeg +0 -0
- package/src/Assets/images/card-background/22.jpeg +0 -0
- package/src/Assets/images/card-background/23.jpeg +0 -0
- package/src/Assets/images/card-background/24.jpeg +0 -0
- package/src/Assets/images/card-background/25.jpeg +0 -0
- package/src/Assets/images/card-background/3.jpeg +0 -0
- package/src/Assets/images/card-background/4.jpeg +0 -0
- package/src/Assets/images/card-background/5.jpeg +0 -0
- package/src/Assets/images/card-background/6.jpeg +0 -0
- package/src/Assets/images/card-background/7.jpeg +0 -0
- package/src/Assets/images/card-background/8.jpeg +0 -0
- package/src/Assets/images/card-background/9.jpeg +0 -0
- package/src/Assets/images/card-type/amex.png +0 -0
- package/src/Assets/images/card-type/diners.png +0 -0
- package/src/Assets/images/card-type/discover.png +0 -0
- package/src/Assets/images/card-type/mastercard.png +0 -0
- package/src/Assets/images/card-type/troy.png +0 -0
- package/src/Assets/images/card-type/unionpay.png +0 -0
- package/src/Assets/images/card-type/visa.png +0 -0
- package/src/blocks/Account/UserProfile.js +15 -0
- package/src/blocks/Account/UserSettings.js +15 -0
- package/src/blocks/Account/index.js +2 -0
- package/src/blocks/AuthForms/NewPasswordForm.js +17 -0
- package/src/blocks/AuthForms/ResetPasswordForm.js +14 -0
- package/src/blocks/AuthForms/SignInForm.js +19 -0
- package/src/blocks/AuthForms/SignUpForm.js +20 -0
- package/src/blocks/AuthForms/index.js +4 -0
- package/src/blocks/AuthForms/viaFacebook.js +0 -0
- package/src/blocks/AuthForms/viaGithub.js +0 -0
- package/src/blocks/AuthForms/viaGoogle.js +0 -0
- package/src/blocks/AuthForms/viaTwitter.js +0 -0
- package/src/blocks/Payment/Form/CForm.js +326 -0
- package/src/blocks/Payment/Form/Card.js +242 -0
- package/src/blocks/Payment/Gateway/GooglePay.js +251 -0
- package/src/blocks/Payment/Gateway/Payfort.js +90 -0
- package/src/blocks/Payment/Gateway/Paypal.js +138 -0
- package/src/blocks/Payment/Gateway/Wallet.js +149 -0
- package/src/blocks/Payment/PaymentMethod.js +132 -0
- package/src/blocks/index.js +13 -0
- package/src/index.js +2 -1
- package/src/layout/Box.js +25 -0
- package/src/layout/index.js +1 -0
- package/src/stories/ActionButton.stories.js +49 -0
- package/src/stories/AdaptiveButton.stories.js +80 -84
- package/src/stories/Alert.stories.js +41 -0
- package/src/stories/AuthForm.stories.js +79 -0
- package/src/stories/Box.stories.js +64 -0
- package/src/stories/CheckBox.stories.js +35 -33
- package/src/stories/GlobalVariables.stories.js +101 -108
- package/src/stories/HawaProvider.stories.js +23 -23
- package/src/stories/InputLabel.stories.js +92 -100
- package/src/stories/Introduction.stories.js +211 -0
- package/src/stories/RadioSelector.stories.js +69 -69
- package/src/stories/TextField.stories.js +50 -59
- package/src/stories/UserAccount.stories.js +46 -0
- package/src/styles.css +400 -403
- package/src/styles.scss +679 -0
- package/src/themes/HawaProvider.js +45 -0
- package/src/ui/ActionButton.js +15 -0
- package/src/{components/Hawa/AdaptiveButton/AdaptiveButton.jsx → ui/AdaptiveButton.js} +252 -261
- package/src/{components/Hawa/AutoCompleteField/AutoCompleteField.jsx → ui/AutoCompleteField.js} +33 -33
- package/src/{components/Hawa/Checkbox/Checkbox.jsx → ui/Checkbox.js} +21 -20
- package/src/{components/Hawa/DragDropImages/DragDropImages.jsx → ui/DragDropImages.js} +180 -180
- package/src/{components/Hawa/Hawa.jsx → ui/Hawa.js} +3 -3
- package/src/{components/Hawa/RadioBox/RadioBox.jsx → ui/RadioBox.js} +29 -29
- package/src/{components/Hawa/RadioSelector/RadioSelector.jsx → ui/RadioSelector.js} +51 -51
- package/src/ui/Row.js +21 -0
- package/src/{components/Hawa/SelectedField/SelectedField.jsx → ui/SelectedField.js} +46 -46
- package/src/ui/StyledAlert.js +30 -0
- package/src/ui/StyledInputLabel.js +19 -0
- package/src/ui/StyledTooltip.js +46 -0
- package/src/{components/Hawa/TabPanel/TabPanel.jsx → ui/TabPanel.js} +37 -38
- package/src/{components/Hawa/TextArea/TextArea.jsx → ui/TextArea.js} +38 -39
- package/src/ui/TextField.js +62 -0
- package/src/{components/Hawa → ui}/index.js +13 -11
- package/src/util.js +20 -0
- package/storybook-static/0.d3bc3395610cf5d3ee94.manager.bundle.js +1 -0
- package/storybook-static/0.dd3d47f5.iframe.bundle.js +1 -0
- package/storybook-static/1.4e43f671.iframe.bundle.js +3 -0
- package/storybook-static/{4.f6eb74f4.iframe.bundle.js.LICENSE.txt → 1.4e43f671.iframe.bundle.js.LICENSE.txt} +8 -8
- package/storybook-static/1.4e43f671.iframe.bundle.js.map +1 -0
- package/storybook-static/2.9a757207.iframe.bundle.js +1 -0
- package/storybook-static/3.c1dc7159.iframe.bundle.js +1 -0
- package/storybook-static/4.8c311a6b48cad9f29317.manager.bundle.js +2 -0
- package/storybook-static/{5.fa71488e730c5c7f885f.manager.bundle.js.LICENSE.txt → 4.8c311a6b48cad9f29317.manager.bundle.js.LICENSE.txt} +8 -8
- package/storybook-static/5.88fe62ee92ff5ca67829.manager.bundle.js +1 -0
- package/storybook-static/6.96d184f368dea006cb52.manager.bundle.js +2 -0
- package/storybook-static/{11.49c687eaa6261f8b7be2.manager.bundle.js.LICENSE.txt → 6.96d184f368dea006cb52.manager.bundle.js.LICENSE.txt} +12 -12
- package/storybook-static/{7.a806a38f.iframe.bundle.js → 7.5ec31f3702b08ab0b71c.manager.bundle.js} +1 -1
- package/storybook-static/7.69d2e532.iframe.bundle.js +1 -0
- package/storybook-static/8.5ce13be7612bd3a6b864.manager.bundle.js +1 -0
- package/storybook-static/8.68cd1217.iframe.bundle.js +3 -0
- package/storybook-static/{6.fbc7b90b.iframe.bundle.js.LICENSE.txt → 8.68cd1217.iframe.bundle.js.LICENSE.txt} +12 -12
- package/storybook-static/8.68cd1217.iframe.bundle.js.map +1 -0
- package/storybook-static/9.488e3969.iframe.bundle.js +1 -0
- package/storybook-static/iframe.html +348 -138
- package/storybook-static/index.html +59 -47
- package/storybook-static/main.65cb2769.iframe.bundle.js +1 -0
- package/storybook-static/main.7e391cf7bf72b0d18ea5.manager.bundle.js +1 -0
- package/storybook-static/runtime~main.6e2e1544.iframe.bundle.js +1 -0
- package/storybook-static/runtime~main.cc29f4c2175f187a3707.manager.bundle.js +1 -0
- package/storybook-static/vendors~main.d144d840.iframe.bundle.js +3 -0
- package/storybook-static/{vendors~main.73411ca9.iframe.bundle.js.LICENSE.txt → vendors~main.d144d840.iframe.bundle.js.LICENSE.txt} +148 -148
- package/storybook-static/vendors~main.d144d840.iframe.bundle.js.map +1 -0
- package/storybook-static/vendors~main.f228d62e92b69563cefb.manager.bundle.js +2 -0
- package/storybook-static/{vendors~main.d3455eed64b243c89325.manager.bundle.js.LICENSE.txt → vendors~main.f228d62e92b69563cefb.manager.bundle.js.LICENSE.txt} +104 -88
- package/tools/build-styles.js +17 -0
- package/yarn-error.log +10910 -0
- package/src/components/Hawa/AdaptiveButton/index.js +0 -1
- package/src/components/Hawa/AutoCompleteField/index.js +0 -1
- package/src/components/Hawa/Checkbox/index.js +0 -1
- package/src/components/Hawa/DragDropImages/index.js +0 -1
- package/src/components/Hawa/HawaProvider/HawaProvider.js +0 -19
- package/src/components/Hawa/HawaProvider/index.js +0 -1
- package/src/components/Hawa/InputLabel/StyledInputLabel.jsx +0 -36
- package/src/components/Hawa/InputLabel/index.js +0 -1
- package/src/components/Hawa/RadioBox/index.js +0 -1
- package/src/components/Hawa/RadioSelector/index.js +0 -1
- package/src/components/Hawa/Row/Row.jsx +0 -23
- package/src/components/Hawa/Row/index.js +0 -1
- package/src/components/Hawa/SelectedField/index.js +0 -1
- package/src/components/Hawa/TabPanel/index.js +0 -1
- package/src/components/Hawa/TextArea/index.js +0 -1
- package/src/components/Hawa/TextField/TextField.jsx +0 -41
- package/src/components/Hawa/TextField/index.js +0 -1
- package/storybook-static/0.86a7edfd.iframe.bundle.js +0 -1
- package/storybook-static/0.b73eaee9a88f178d62ed.manager.bundle.js +0 -1
- package/storybook-static/1.f296d183a17268696d73.manager.bundle.js +0 -1
- package/storybook-static/10.9998ba67d65d81d20896.manager.bundle.js +0 -1
- package/storybook-static/11.49c687eaa6261f8b7be2.manager.bundle.js +0 -2
- package/storybook-static/12.c9538ed3766c96f289e7.manager.bundle.js +0 -1
- package/storybook-static/4.f6eb74f4.iframe.bundle.js +0 -3
- package/storybook-static/4.f6eb74f4.iframe.bundle.js.map +0 -1
- package/storybook-static/5.ec6f37af.iframe.bundle.js +0 -1
- package/storybook-static/5.fa71488e730c5c7f885f.manager.bundle.js +0 -2
- package/storybook-static/6.8096ae4aadde0743697b.manager.bundle.js +0 -1
- package/storybook-static/6.fbc7b90b.iframe.bundle.js +0 -3
- package/storybook-static/6.fbc7b90b.iframe.bundle.js.map +0 -1
- package/storybook-static/7.b34baecbd082bc7b188d.manager.bundle.js +0 -1
- package/storybook-static/8.15577edffecf900a8de2.manager.bundle.js +0 -1
- package/storybook-static/9.d7d85aa0a49a98f17218.manager.bundle.js +0 -1
- package/storybook-static/main.355ffc59.iframe.bundle.js +0 -1
- package/storybook-static/main.ce406c7e93b98325390e.manager.bundle.js +0 -1
- package/storybook-static/runtime~main.3d81579b.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.909d038f912f063e8837.manager.bundle.js +0 -1
- package/storybook-static/vendors~main.73411ca9.iframe.bundle.js +0 -3
- package/storybook-static/vendors~main.73411ca9.iframe.bundle.js.map +0 -1
- package/storybook-static/vendors~main.d3455eed64b243c89325.manager.bundle.js +0 -2
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { getToken } from "../token";
|
|
4
|
-
import { useDropzone } from "react-dropzone";
|
|
5
|
-
import useTranslation from "next-translate/useTranslation";
|
|
6
|
-
import Badge from "@material-ui/core/Badge";
|
|
7
|
-
import CloseIcon from "@material-ui/icons/Close";
|
|
8
|
-
import styles from "../styles/Theme.module.css";
|
|
9
|
-
|
|
10
|
-
const thumbsContainer = {
|
|
11
|
-
display: "flex",
|
|
12
|
-
flexDirection: "row",
|
|
13
|
-
flexWrap: "wrap",
|
|
14
|
-
marginTop: 10
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const DragDropItemImage = ({
|
|
18
|
-
files,
|
|
19
|
-
setFiles,
|
|
20
|
-
itemId,
|
|
21
|
-
setDeletedFiles,
|
|
22
|
-
refetchSingleMenu
|
|
23
|
-
}) => {
|
|
24
|
-
const token = getToken();
|
|
25
|
-
const [cmp, setCmp] = useState(0);
|
|
26
|
-
//const [thumbs, setThumbs] = useState("");
|
|
27
|
-
const { t } = useTranslation("common");
|
|
28
|
-
const { getRootProps, getInputProps, fileRejections, acceptedFiles } =
|
|
29
|
-
useDropzone({
|
|
30
|
-
multiple: token.Pack?.image_per_item_limit > 1,
|
|
31
|
-
accept: "image/*",
|
|
32
|
-
maxSize: 5000000,
|
|
33
|
-
maxFiles: token.Pack?.image_per_item_limit,
|
|
34
|
-
onDrop: (acceptedFiles) => {
|
|
35
|
-
setFiles(
|
|
36
|
-
acceptedFiles.map((file, index) =>
|
|
37
|
-
Object.assign(file, {
|
|
38
|
-
preview: URL.createObjectURL(file)
|
|
39
|
-
})
|
|
40
|
-
)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const handleRemoveFile = async (file) => {
|
|
45
|
-
console.log("fezafezaf", acceptedFiles[file]);
|
|
46
|
-
if (acceptedFiles[file]?.isFromDB) {
|
|
47
|
-
setDeletedFiles((old) => [
|
|
48
|
-
...old,
|
|
49
|
-
{
|
|
50
|
-
img_url: acceptedFiles[file]?.img_url,
|
|
51
|
-
_id: acceptedFiles[file]?._id
|
|
52
|
-
}
|
|
53
|
-
]);
|
|
54
|
-
try {
|
|
55
|
-
await axios.post(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
);
|
|
67
|
-
refetchSingleMenu();
|
|
68
|
-
acceptedFiles.splice(file, 1);
|
|
69
|
-
setFiles(acceptedFiles);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
console.error(err);
|
|
72
|
-
}
|
|
73
|
-
console.log("accepted files after delete : ", acceptedFiles);
|
|
74
|
-
setCmp((old) => old + 1);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// if (file.hasOwnProperty("_id")) {
|
|
78
|
-
// console.log("Yes");
|
|
79
|
-
// return;
|
|
80
|
-
// }
|
|
81
|
-
acceptedFiles.splice(file, 1);
|
|
82
|
-
|
|
83
|
-
setFiles(
|
|
84
|
-
acceptedFiles.map((f) =>
|
|
85
|
-
Object.assign(f, { preview: URL.createObjectURL(f) })
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
// setFiles(acceptedFiles);
|
|
89
|
-
};
|
|
90
|
-
useEffect(
|
|
91
|
-
() => () => {
|
|
92
|
-
files.forEach((file) => {
|
|
93
|
-
URL.revokeObjectURL(file.preview);
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
[files]
|
|
98
|
-
);
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (files[0]?.hasOwnProperty("_id")) {
|
|
101
|
-
files?.map((file, index) => {
|
|
102
|
-
acceptedFiles.push({
|
|
103
|
-
preview: `https://qawaim-images.s3-ap-southeast-1.amazonaws.com/${file.image_url}`,
|
|
104
|
-
isFromDB: true,
|
|
105
|
-
_id: file._id,
|
|
106
|
-
img_url: file.image_url
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
console.log("accepted files : ", acceptedFiles);
|
|
110
|
-
setFiles(acceptedFiles);
|
|
111
|
-
}
|
|
112
|
-
return () => {
|
|
113
|
-
acceptedFiles.splice(0, acceptedFiles?.length);
|
|
114
|
-
};
|
|
115
|
-
}, []);
|
|
116
|
-
const errs = fileRejections.map((rej, i) => {
|
|
117
|
-
return (
|
|
118
|
-
<div key={i} className={styles.upload_error_container}>
|
|
119
|
-
<div>{rej.file.name}</div>
|
|
120
|
-
<div>{t(rej.errors[0].code)}</div>
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const thumbs = files.map((file, index) => (
|
|
126
|
-
<Badge
|
|
127
|
-
key={index}
|
|
128
|
-
onClick={(e) => {
|
|
129
|
-
e.preventDefault();
|
|
130
|
-
e.stopPropagation();
|
|
131
|
-
console.log("Clicking", index);
|
|
132
|
-
handleRemoveFile(index);
|
|
133
|
-
}}
|
|
134
|
-
badgeContent={<CloseIcon fontSize="small" />}
|
|
135
|
-
color="primary"
|
|
136
|
-
style={{
|
|
137
|
-
margin: 10,
|
|
138
|
-
width: 100,
|
|
139
|
-
height: 100
|
|
140
|
-
}}
|
|
141
|
-
>
|
|
142
|
-
<div
|
|
143
|
-
style={{
|
|
144
|
-
display: "flex",
|
|
145
|
-
justifyContent: "center",
|
|
146
|
-
alignItems: "center",
|
|
147
|
-
overflow: "hidden",
|
|
148
|
-
height: 100,
|
|
149
|
-
width: 100,
|
|
150
|
-
backgroundImage: `url(${file.preview})`,
|
|
151
|
-
backgroundSize: "cover",
|
|
152
|
-
backgroundPosition: "center"
|
|
153
|
-
}}
|
|
154
|
-
key={file.name}
|
|
155
|
-
/>
|
|
156
|
-
</Badge>
|
|
157
|
-
));
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<section className={styles.upload_main_container}>
|
|
161
|
-
<div
|
|
162
|
-
{...getRootProps({
|
|
163
|
-
onClick: (e) => {
|
|
164
|
-
console.log("e : ", e);
|
|
165
|
-
e.preventDefault(), console.log("khobza");
|
|
166
|
-
},
|
|
167
|
-
style: { height: "100%", width: "100%", padding: 10 }
|
|
168
|
-
})}
|
|
169
|
-
>
|
|
170
|
-
<input {...getInputProps()} />
|
|
171
|
-
<div style={{ fontSize: 13 }}>{t("drag-n-drop")}</div>
|
|
172
|
-
<div style={{ fontSize: 13, marginTop: 5 }}>{t("max-file-size")}</div>
|
|
173
|
-
{thumbs ? <aside style={thumbsContainer}>{thumbs}</aside> : null}
|
|
174
|
-
{errs}
|
|
175
|
-
</div>
|
|
176
|
-
</section>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default DragDropItemImage;
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
// import axios from "axios";
|
|
3
|
+
import { getToken } from "../token";
|
|
4
|
+
import { useDropzone } from "react-dropzone";
|
|
5
|
+
import useTranslation from "next-translate/useTranslation";
|
|
6
|
+
import Badge from "@material-ui/core/Badge";
|
|
7
|
+
import CloseIcon from "@material-ui/icons/Close";
|
|
8
|
+
import styles from "../styles/Theme.module.css";
|
|
9
|
+
|
|
10
|
+
const thumbsContainer = {
|
|
11
|
+
display: "flex",
|
|
12
|
+
flexDirection: "row",
|
|
13
|
+
flexWrap: "wrap",
|
|
14
|
+
marginTop: 10
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const DragDropItemImage = ({
|
|
18
|
+
files,
|
|
19
|
+
setFiles,
|
|
20
|
+
itemId,
|
|
21
|
+
setDeletedFiles,
|
|
22
|
+
refetchSingleMenu
|
|
23
|
+
}) => {
|
|
24
|
+
const token = getToken();
|
|
25
|
+
const [cmp, setCmp] = useState(0);
|
|
26
|
+
//const [thumbs, setThumbs] = useState("");
|
|
27
|
+
const { t } = useTranslation("common");
|
|
28
|
+
const { getRootProps, getInputProps, fileRejections, acceptedFiles } =
|
|
29
|
+
useDropzone({
|
|
30
|
+
multiple: token.Pack?.image_per_item_limit > 1,
|
|
31
|
+
accept: "image/*",
|
|
32
|
+
maxSize: 5000000,
|
|
33
|
+
maxFiles: token.Pack?.image_per_item_limit,
|
|
34
|
+
onDrop: (acceptedFiles) => {
|
|
35
|
+
setFiles(
|
|
36
|
+
acceptedFiles.map((file, index) =>
|
|
37
|
+
Object.assign(file, {
|
|
38
|
+
preview: URL.createObjectURL(file)
|
|
39
|
+
})
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const handleRemoveFile = async (file) => {
|
|
45
|
+
console.log("fezafezaf", acceptedFiles[file]);
|
|
46
|
+
if (acceptedFiles[file]?.isFromDB) {
|
|
47
|
+
setDeletedFiles((old) => [
|
|
48
|
+
...old,
|
|
49
|
+
{
|
|
50
|
+
img_url: acceptedFiles[file]?.img_url,
|
|
51
|
+
_id: acceptedFiles[file]?._id
|
|
52
|
+
}
|
|
53
|
+
]);
|
|
54
|
+
try {
|
|
55
|
+
// await axios.post(
|
|
56
|
+
// `${process.env.NEXT_PUBLIC_QAWAIM_API_URL}/deleteImages`,
|
|
57
|
+
// {
|
|
58
|
+
// deletedFiles: [
|
|
59
|
+
// {
|
|
60
|
+
// img_url: acceptedFiles[file]?.img_url,
|
|
61
|
+
// _id: acceptedFiles[file]?._id
|
|
62
|
+
// }
|
|
63
|
+
// ],
|
|
64
|
+
// itemId: itemId
|
|
65
|
+
// }
|
|
66
|
+
// );
|
|
67
|
+
refetchSingleMenu();
|
|
68
|
+
acceptedFiles.splice(file, 1);
|
|
69
|
+
setFiles(acceptedFiles);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error(err);
|
|
72
|
+
}
|
|
73
|
+
console.log("accepted files after delete : ", acceptedFiles);
|
|
74
|
+
setCmp((old) => old + 1);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// if (file.hasOwnProperty("_id")) {
|
|
78
|
+
// console.log("Yes");
|
|
79
|
+
// return;
|
|
80
|
+
// }
|
|
81
|
+
acceptedFiles.splice(file, 1);
|
|
82
|
+
|
|
83
|
+
setFiles(
|
|
84
|
+
acceptedFiles.map((f) =>
|
|
85
|
+
Object.assign(f, { preview: URL.createObjectURL(f) })
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
// setFiles(acceptedFiles);
|
|
89
|
+
};
|
|
90
|
+
useEffect(
|
|
91
|
+
() => () => {
|
|
92
|
+
files.forEach((file) => {
|
|
93
|
+
URL.revokeObjectURL(file.preview);
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
[files]
|
|
98
|
+
);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (files[0]?.hasOwnProperty("_id")) {
|
|
101
|
+
files?.map((file, index) => {
|
|
102
|
+
acceptedFiles.push({
|
|
103
|
+
preview: `https://qawaim-images.s3-ap-southeast-1.amazonaws.com/${file.image_url}`,
|
|
104
|
+
isFromDB: true,
|
|
105
|
+
_id: file._id,
|
|
106
|
+
img_url: file.image_url
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
console.log("accepted files : ", acceptedFiles);
|
|
110
|
+
setFiles(acceptedFiles);
|
|
111
|
+
}
|
|
112
|
+
return () => {
|
|
113
|
+
acceptedFiles.splice(0, acceptedFiles?.length);
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
const errs = fileRejections.map((rej, i) => {
|
|
117
|
+
return (
|
|
118
|
+
<div key={i} className={styles.upload_error_container}>
|
|
119
|
+
<div>{rej.file.name}</div>
|
|
120
|
+
<div>{t(rej.errors[0].code)}</div>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const thumbs = files.map((file, index) => (
|
|
126
|
+
<Badge
|
|
127
|
+
key={index}
|
|
128
|
+
onClick={(e) => {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
console.log("Clicking", index);
|
|
132
|
+
handleRemoveFile(index);
|
|
133
|
+
}}
|
|
134
|
+
badgeContent={<CloseIcon fontSize="small" />}
|
|
135
|
+
color="primary"
|
|
136
|
+
style={{
|
|
137
|
+
margin: 10,
|
|
138
|
+
width: 100,
|
|
139
|
+
height: 100
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
style={{
|
|
144
|
+
display: "flex",
|
|
145
|
+
justifyContent: "center",
|
|
146
|
+
alignItems: "center",
|
|
147
|
+
overflow: "hidden",
|
|
148
|
+
height: 100,
|
|
149
|
+
width: 100,
|
|
150
|
+
backgroundImage: `url(${file.preview})`,
|
|
151
|
+
backgroundSize: "cover",
|
|
152
|
+
backgroundPosition: "center"
|
|
153
|
+
}}
|
|
154
|
+
key={file.name}
|
|
155
|
+
/>
|
|
156
|
+
</Badge>
|
|
157
|
+
));
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<section className={styles.upload_main_container}>
|
|
161
|
+
<div
|
|
162
|
+
{...getRootProps({
|
|
163
|
+
onClick: (e) => {
|
|
164
|
+
console.log("e : ", e);
|
|
165
|
+
e.preventDefault(), console.log("khobza");
|
|
166
|
+
},
|
|
167
|
+
style: { height: "100%", width: "100%", padding: 10 }
|
|
168
|
+
})}
|
|
169
|
+
>
|
|
170
|
+
<input {...getInputProps()} />
|
|
171
|
+
<div style={{ fontSize: 13 }}>{t("drag-n-drop")}</div>
|
|
172
|
+
<div style={{ fontSize: 13, marginTop: 5 }}>{t("max-file-size")}</div>
|
|
173
|
+
{thumbs ? <aside style={thumbsContainer}>{thumbs}</aside> : null}
|
|
174
|
+
{errs}
|
|
175
|
+
</div>
|
|
176
|
+
</section>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export default DragDropItemImage;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const Hawa = (props) => {
|
|
2
|
-
return <div>test</div>;
|
|
3
|
-
};
|
|
1
|
+
export const Hawa = (props) => {
|
|
2
|
+
return <div>test</div>;
|
|
3
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
3
|
-
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
|
4
|
-
import Checkbox from "@material-ui/core/Checkbox";
|
|
5
|
-
|
|
6
|
-
export const StyledRadioBox = (props) => {
|
|
7
|
-
const { control } = useFormContext();
|
|
8
|
-
const { name, defaultValue, rules, shouldUnregister } = props;
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<React.Fragment>
|
|
12
|
-
<Controller
|
|
13
|
-
render={({ field }) => (
|
|
14
|
-
<FormControlLabel
|
|
15
|
-
control={<Checkbox />}
|
|
16
|
-
{...props}
|
|
17
|
-
{...field}
|
|
18
|
-
checked={field.value}
|
|
19
|
-
/>
|
|
20
|
-
)}
|
|
21
|
-
name={name}
|
|
22
|
-
rules={rules}
|
|
23
|
-
control={control}
|
|
24
|
-
defaultValue={defaultValue}
|
|
25
|
-
shouldUnregister={shouldUnregister}
|
|
26
|
-
/>
|
|
27
|
-
</React.Fragment>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
3
|
+
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
|
4
|
+
import Checkbox from "@material-ui/core/Checkbox";
|
|
5
|
+
|
|
6
|
+
export const StyledRadioBox = (props) => {
|
|
7
|
+
const { control } = useFormContext();
|
|
8
|
+
const { name, defaultValue, rules, shouldUnregister } = props;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<React.Fragment>
|
|
12
|
+
<Controller
|
|
13
|
+
render={({ field }) => (
|
|
14
|
+
<FormControlLabel
|
|
15
|
+
control={<Checkbox />}
|
|
16
|
+
{...props}
|
|
17
|
+
{...field}
|
|
18
|
+
checked={field.value}
|
|
19
|
+
/>
|
|
20
|
+
)}
|
|
21
|
+
name={name}
|
|
22
|
+
rules={rules}
|
|
23
|
+
control={control}
|
|
24
|
+
defaultValue={defaultValue}
|
|
25
|
+
shouldUnregister={shouldUnregister}
|
|
26
|
+
/>
|
|
27
|
+
</React.Fragment>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import React, { useState, useContext } from "react";
|
|
2
|
-
import { ThemeProvider } from "../HawaProvider";
|
|
3
|
-
|
|
4
|
-
export const StyledRadioSelector = (props) => {
|
|
5
|
-
const [value, setValue] = useState(props.defaultValue);
|
|
6
|
-
const theme = useContext(ThemeProvider);
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div
|
|
10
|
-
style={{
|
|
11
|
-
backgroundColor: "white",
|
|
12
|
-
display: "flex",
|
|
13
|
-
flexDirection: "row",
|
|
14
|
-
margin: theme.margins,
|
|
15
|
-
padding: theme.paddings,
|
|
16
|
-
marginBottom: 10
|
|
17
|
-
}}
|
|
18
|
-
>
|
|
19
|
-
{props.options.map((
|
|
20
|
-
return (
|
|
21
|
-
<div
|
|
22
|
-
key={
|
|
23
|
-
className="radio_option"
|
|
24
|
-
onClick={() => {
|
|
25
|
-
setValue(
|
|
26
|
-
if (props.handleChange) {
|
|
27
|
-
props.handleChange();
|
|
28
|
-
}
|
|
29
|
-
}}
|
|
30
|
-
style={
|
|
31
|
-
value.toLowerCase() ===
|
|
32
|
-
? {
|
|
33
|
-
borderRadius: theme.borderRadius,
|
|
34
|
-
padding: theme.paddings,
|
|
35
|
-
backgroundColor:
|
|
36
|
-
theme.primaryColor || props.bgSelectedColor || "blue",
|
|
37
|
-
color: props.textSelectedColor || "lightgray"
|
|
38
|
-
}
|
|
39
|
-
: {
|
|
40
|
-
borderRadius: theme.borderRadius,
|
|
41
|
-
padding: theme.paddings
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
>
|
|
45
|
-
{
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
})}
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
1
|
+
import React, { useState, useContext } from "react";
|
|
2
|
+
import { ThemeProvider } from "../themes/HawaProvider";
|
|
3
|
+
|
|
4
|
+
export const StyledRadioSelector = (props) => {
|
|
5
|
+
const [value, setValue] = useState(props.defaultValue);
|
|
6
|
+
const theme = useContext(ThemeProvider);
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
style={{
|
|
11
|
+
backgroundColor: "white",
|
|
12
|
+
display: "flex",
|
|
13
|
+
flexDirection: "row",
|
|
14
|
+
margin: theme.margins,
|
|
15
|
+
padding: theme.paddings,
|
|
16
|
+
marginBottom: 10
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
{props.options.map((singleOption) => {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
key={singleOption.label}
|
|
23
|
+
className="radio_option"
|
|
24
|
+
onClick={() => {
|
|
25
|
+
setValue(singleOption.label);
|
|
26
|
+
if (props.handleChange) {
|
|
27
|
+
props.handleChange();
|
|
28
|
+
}
|
|
29
|
+
}}
|
|
30
|
+
style={
|
|
31
|
+
value.toLowerCase() === singleOption.label.toLowerCase()
|
|
32
|
+
? {
|
|
33
|
+
borderRadius: theme.borderRadius,
|
|
34
|
+
padding: theme.paddings,
|
|
35
|
+
backgroundColor:
|
|
36
|
+
theme.primaryColor || props.bgSelectedColor || "blue",
|
|
37
|
+
color: props.textSelectedColor || "lightgray"
|
|
38
|
+
}
|
|
39
|
+
: {
|
|
40
|
+
borderRadius: theme.borderRadius,
|
|
41
|
+
padding: theme.paddings
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
{singleOption.text}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
})}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
package/src/ui/Row.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const Row = (props) => {
|
|
2
|
+
return (
|
|
3
|
+
<div
|
|
4
|
+
style={{
|
|
5
|
+
backgroundColor: "var(--light)",
|
|
6
|
+
borderRadius: "var(--borderR)",
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "row",
|
|
9
|
+
justifyContent: "space-between",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
height: 50,
|
|
12
|
+
padding: 10,
|
|
13
|
+
marginBottom: 20,
|
|
14
|
+
width: "100%"
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<div style={{ fontWeight: 800 }}>{props.title}</div>
|
|
18
|
+
{props.actionComponent}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
3
|
-
import FormHelperText from "@material-ui/core/FormHelperText";
|
|
4
|
-
import FormControl from "@material-ui/core/FormControl";
|
|
5
|
-
import MenuItem from "@material-ui/core/MenuItem";
|
|
6
|
-
import Select from "@material-ui/core/Select";
|
|
7
|
-
|
|
8
|
-
const MuiSelect = (props) => {
|
|
9
|
-
const { name, options, required, error } = props;
|
|
10
|
-
let isError = false;
|
|
11
|
-
let errorMessage = "";
|
|
12
|
-
if (error && error.hasOwnProperty(name)) {
|
|
13
|
-
isError = true;
|
|
14
|
-
errorMessage = error[name].message;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<FormControl fullWidth={true} error={isError}>
|
|
19
|
-
{label} {required ? <span className="req-label">*</span> : null}
|
|
20
|
-
<Select id={name} {...props}>
|
|
21
|
-
<MenuItem value="">
|
|
22
|
-
<em>None</em>
|
|
23
|
-
</MenuItem>
|
|
24
|
-
{options.map((item) => (
|
|
25
|
-
<MenuItem key={item.id} value={item.id}>
|
|
26
|
-
{item.label}
|
|
27
|
-
</MenuItem>
|
|
28
|
-
))}
|
|
29
|
-
</Select>
|
|
30
|
-
<FormHelperText>{errorMessage}</FormHelperText>
|
|
31
|
-
</FormControl>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const SelectField = (props) => {
|
|
36
|
-
const { control } = useFormContext();
|
|
37
|
-
return (
|
|
38
|
-
<React.Fragment>
|
|
39
|
-
<Controller
|
|
40
|
-
control={control}
|
|
41
|
-
render={(field) => <MuiSelect {...props} {...field} />}
|
|
42
|
-
{...props}
|
|
43
|
-
/>
|
|
44
|
-
</React.Fragment>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Controller, useFormContext } from "react-hook-form";
|
|
3
|
+
import FormHelperText from "@material-ui/core/FormHelperText";
|
|
4
|
+
import FormControl from "@material-ui/core/FormControl";
|
|
5
|
+
import MenuItem from "@material-ui/core/MenuItem";
|
|
6
|
+
import Select from "@material-ui/core/Select";
|
|
7
|
+
|
|
8
|
+
const MuiSelect = (props) => {
|
|
9
|
+
const { name, options, required, error } = props;
|
|
10
|
+
let isError = false;
|
|
11
|
+
let errorMessage = "";
|
|
12
|
+
if (error && error.hasOwnProperty(name)) {
|
|
13
|
+
isError = true;
|
|
14
|
+
errorMessage = error[name].message;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<FormControl fullWidth={true} error={isError}>
|
|
19
|
+
{label} {required ? <span className="req-label">*</span> : null}
|
|
20
|
+
<Select id={name} {...props}>
|
|
21
|
+
<MenuItem value="">
|
|
22
|
+
<em>None</em>
|
|
23
|
+
</MenuItem>
|
|
24
|
+
{options.map((item) => (
|
|
25
|
+
<MenuItem key={item.id} value={item.id}>
|
|
26
|
+
{item.label}
|
|
27
|
+
</MenuItem>
|
|
28
|
+
))}
|
|
29
|
+
</Select>
|
|
30
|
+
<FormHelperText>{errorMessage}</FormHelperText>
|
|
31
|
+
</FormControl>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const SelectField = (props) => {
|
|
36
|
+
const { control } = useFormContext();
|
|
37
|
+
return (
|
|
38
|
+
<React.Fragment>
|
|
39
|
+
<Controller
|
|
40
|
+
control={control}
|
|
41
|
+
render={(field) => <MuiSelect {...props} {...field} />}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
</React.Fragment>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { ThemeProvider } from "../themes/HawaProvider";
|
|
3
|
+
|
|
4
|
+
export const StyledAlert = (props) => {
|
|
5
|
+
const theme = useContext(ThemeProvider);
|
|
6
|
+
|
|
7
|
+
let alertStyle = {
|
|
8
|
+
backgroundColor: "green",
|
|
9
|
+
padding: 10,
|
|
10
|
+
marginTop: 10,
|
|
11
|
+
marginBottom: 10,
|
|
12
|
+
borderRadius: theme.borderRadius
|
|
13
|
+
};
|
|
14
|
+
switch (props.type) {
|
|
15
|
+
case "warning":
|
|
16
|
+
alertStyle.backgroundColor = "yellow";
|
|
17
|
+
return <div style={alertStyle}>{props.text}</div>;
|
|
18
|
+
break;
|
|
19
|
+
case "danger":
|
|
20
|
+
alertStyle.backgroundColor = "red";
|
|
21
|
+
return <div style={alertStyle}>{props.text}</div>;
|
|
22
|
+
break;
|
|
23
|
+
case "notification":
|
|
24
|
+
alertStyle.backgroundColor = "blue";
|
|
25
|
+
return <div style={alertStyle}>{props.text}</div>;
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
return <div style={alertStyle}>{props.text}</div>;
|
|
29
|
+
}
|
|
30
|
+
};
|