-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* button setting * menu donate * menu donate print modale * save prew * fin donation donationPageForm --------- Co-authored-by: Максим Коробков <[email protected]>
- Loading branch information
Showing
9 changed files
with
429 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[debug] [2024-01-06T06:33:03.911Z] ---------------------------------------------------------------------- | ||
[debug] [2024-01-06T06:33:03.915Z] Command: C:\Program Files (x86)\nodejs\node.exe C:\Users\makst\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js init | ||
[debug] [2024-01-06T06:33:03.915Z] CLI Version: 13.0.2 | ||
[debug] [2024-01-06T06:33:03.916Z] Platform: win32 | ||
[debug] [2024-01-06T06:33:03.916Z] Node Version: v20.10.0 | ||
[debug] [2024-01-06T06:33:03.916Z] Time: Sat Jan 06 2024 16:33:03 GMT+1000 (Владивосток, стандартное время) | ||
[debug] [2024-01-06T06:33:03.916Z] ---------------------------------------------------------------------- | ||
[debug] | ||
[debug] [2024-01-06T06:33:03.923Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] | ||
[debug] [2024-01-06T06:33:03.923Z] > authorizing via signed-in user ([email protected]) | ||
[info] | ||
######## #### ######## ######## ######## ### ###### ######## | ||
## ## ## ## ## ## ## ## ## ## ## | ||
###### ## ######## ###### ######## ######### ###### ###### | ||
## ## ## ## ## ## ## ## ## ## ## | ||
## #### ## ## ######## ######## ## ## ###### ######## | ||
|
||
You're about to initialize a Firebase project in this directory: | ||
|
||
C:\Users\makst\OneDrive\Documents\React\karavan-book-tracker-1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
packages/common/src/components/forms/profile/pagedonation/PageMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { CurrentUser } from "common/src/services/api/useCurrentUser"; | ||
import { DonationPageDoc } from "common/src/services/api/donation"; | ||
import { apiRefs } from "common/src/services/api/refs"; | ||
import { useDocumentData } from "react-firebase-hooks/firestore"; | ||
import { Button, Radio, RadioChangeEvent, Space, Switch, Modal } from "antd"; | ||
import { PrinterTwoTone, LinkOutlined } from "@ant-design/icons"; | ||
import { useState } from "react"; | ||
import Link from "antd/es/typography/Link"; | ||
import printPdfDonations from "common/src/components/forms/profile/pagedonation/printPdfDonations"; | ||
import printPdfDonations88 from "common/src/components/forms/profile/pagedonation/printPdfDonations88"; | ||
|
||
export type PageFormValues = DonationPageDoc; | ||
|
||
type Props = { | ||
initialValues: PageFormValues; | ||
disabled?: boolean; | ||
currentUser: CurrentUser; | ||
}; | ||
|
||
const PageMenu = ({ currentUser }: Props) => { | ||
const { profile, user } = currentUser; | ||
|
||
const initialPageDoc: DonationPageDoc = { | ||
banks: [], | ||
active: false, | ||
socialTelegram: "", | ||
socialWhats: "", | ||
socialMail: "", | ||
socialLink: "", | ||
avatar: "", | ||
userName: "", | ||
greetingText: "", | ||
buttonBank: "", | ||
}; | ||
|
||
const userId = profile?.id || user?.uid || ""; | ||
|
||
const [donationPageDocData] = useDocumentData<DonationPageDoc>( | ||
userId ? apiRefs.donationPage(userId) : null | ||
); | ||
|
||
const initialValues = donationPageDocData || initialPageDoc; | ||
|
||
const [switchState, setSwitchState] = useState(initialValues.active); | ||
|
||
const myPageLink = `https://books-donation.web.app/page/${userId}`; | ||
|
||
const [value, setValue] = useState(true); | ||
|
||
const onChange = (e: RadioChangeEvent) => { | ||
//console.log("radio checked", e.target.value); | ||
setValue(e.target.value); | ||
}; | ||
|
||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
|
||
const showModal = () => { | ||
setIsModalOpen(true); | ||
}; | ||
|
||
const handleOk = () => { | ||
setIsModalOpen(false); | ||
}; | ||
|
||
const handleCancel = () => { | ||
setIsModalOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Space | ||
direction="vertical" | ||
style={{ display: "flex", flexFlow: "column", alignItems: "center", marginTop: 20 }} | ||
> | ||
{initialValues.active ? ( | ||
<Button type="primary" ghost icon={<LinkOutlined />}> | ||
<Link copyable={{ text: myPageLink }} href={myPageLink} target="_blank"> | ||
Ваша страница визитки | ||
</Link> | ||
</Button> | ||
) : ( | ||
"" | ||
)} | ||
{initialValues.active ? ( | ||
<Button type="dashed" onClick={showModal} icon={<PrinterTwoTone />}> | ||
Распечатать визитки | ||
</Button> | ||
) : ( | ||
"" | ||
)}{" "} | ||
</Space> | ||
{initialValues.active ? ( | ||
<Space | ||
direction="vertical" | ||
style={{ display: "flex", flexFlow: "column", alignItems: "center", marginBottom: 15 }} | ||
> | ||
<Modal title="Выберете формат" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}> | ||
<Radio.Group name="radiogroup" defaultValue={1} onChange={onChange} value={value}> | ||
<Radio value={true} onClick={printPdfDonations}> | ||
16 QR | ||
</Radio> | ||
<Radio value={false} onClick={printPdfDonations88}> | ||
88 QR | ||
</Radio> | ||
</Radio.Group> | ||
</Modal> | ||
</Space> | ||
) : ( | ||
"" | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default PageMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.