mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
'use client'
|
|
|
|
import { FC, ReactNode, useState } from 'react';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
|
|
import useMobileView from '@/hooks/useMobileView';
|
|
|
|
type Props = {
|
|
children?: ReactNode
|
|
};
|
|
|
|
const ForgotPassword: FC<Props> = ({ children }) => {
|
|
const { isMobile } = useMobileView()
|
|
const [showDialog, setShowDialog] = useState(false)
|
|
|
|
const handleForgotPassword = () => {
|
|
const name = process.env.NEXT_PUBLIC_HATS_SUPPORT_NAME
|
|
const phone = process.env.NEXT_PUBLIC_HATS_SUPPORT_PHONE
|
|
|
|
const text = `Hello ${name}, here I convey that I forgot my HIS Attendance Task System (H.A.T.s) account password, I ask for your help to reset my account password, thank you in advance :)`
|
|
|
|
let url = `https://wa.me/${phone}?text=${text}`
|
|
|
|
if (isMobile) {
|
|
url = `https://api.whatsapp.com/send?phone=${phone}&text=${text}`
|
|
} else {
|
|
url = `https://web.whatsapp.com/send?phone=${phone}&text=${text}`
|
|
}
|
|
|
|
window.open(url, '_blank')!.focus();
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Dialog open={showDialog} onOpenChange={setShowDialog}>
|
|
<DialogTrigger asChild>
|
|
{children ?
|
|
children
|
|
:
|
|
<Button variant='ghost'>I forgot my passsword</Button>
|
|
}
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<DialogHeader>
|
|
<DialogTitle className="dark:text-white">Confirm forgot password</DialogTitle>
|
|
<DialogDescription>
|
|
Are you sure to continue this process?
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<DialogFooter className='mt-5'>
|
|
<Button variant="outline" type="button" onClick={() => setShowDialog(false)} >
|
|
Cancel
|
|
</Button>
|
|
<Button type="submit" onClick={handleForgotPassword}>
|
|
Continue
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default ForgotPassword; |