2024-11-05 11:12:42 +00:00
"use strict" ;
( ( ) => {
var exports = { } ;
exports . id = 5785 ;
exports . ids = [ 5785 ] ;
exports . modules = {
/***/ 5591 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "default" : ( ) => ( /* binding */ Contact ) ,
/* harmony export */ "getServerSideProps" : ( ) => ( /* binding */ getServerSideProps )
/* harmony export */ } ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 997 ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 6689 ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
/* harmony import */ var _components _general _LoadingBlock _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 5264 ) ;
/* harmony import */ var _components _general _PageHeadTags _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _ ( 4097 ) ;
/* harmony import */ var _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _ ( 370 ) ;
/* harmony import */ var _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _4 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _4 _ _ ) ;
/* harmony import */ var _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _ ( 6729 ) ;
/* harmony import */ var _layouts _GeneralLayout _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _ ( 6217 ) ;
/* harmony import */ var _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _ ( 9395 ) ;
/* harmony import */ var _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _6 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _6 _ _ ) ;
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { import ( "@/package-shared/types" ) . UserType | null } props . user
* @ param { string | null } props . email
* @ param { string } props . productionEnvironment
* @ param { any } props . existingAlerts
* / f u n c t i o n C o n t a c t ( { u s e r , e m a i l , p r o d u c t i o n E n v i r o n m e n t , e x i s t i n g A l e r t s , } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / c o n s t p a g e T i t l e = " U n s u b s c r i b e | D a t a s q u i r e l " ;
const pageDescription = "Unsubscribe from email alerts" ;
let head = /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . Fragment , {
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "title" , {
children : pageTitle
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "meta" , {
name : "description" ,
content : pageDescription
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _components _general _PageHeadTags _ _WEBPACK _IMPORTED _MODULE _3 _ _ /* ["default"] */ . Z , {
pageTitle : pageTitle ,
pageDescription : pageDescription ,
pagePathname : "/unsubscribe"
} )
]
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ l o a d i n g , s e t L o a d i n g ] = r e a c t _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 1 _ _ _ d e f a u l t ( ) . u s e S t a t e ( f a l s e ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / r e a c t _ j s x _ r u n t i m e _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 0 _ _ . j s x ( ( r e a c t _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 1 _ _ _ d e f a u l t ( ) . F r a g m e n t ) , {
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _layouts _GeneralLayout _ _WEBPACK _IMPORTED _MODULE _5 _ _ /* ["default"] */ . Z , {
head : head ,
user : user ,
productionEnvironment : productionEnvironment ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "main" , {
children : /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "section" , {
children : [
loading && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _components _general _LoadingBlock _ _WEBPACK _IMPORTED _MODULE _2 _ _ /* ["default"] */ . Z , { } ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "flex-col" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "h1" , {
className : "text-2xl" ,
children : "Unsubscribe from Email alerts"
} ) ,
! email && /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "p" , {
className : "max-w-md" ,
children : [
"No email please " ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : "/login" ,
children : "Login"
} ) ,
" " ,
"to Access Email Subscriptions or click on" ,
" " ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "i" , {
children : '"unsubscribe"'
} ) ,
" from your mail box"
]
} ) ,
email && /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "form" , {
className : "flex flex-col items-start gap-4" ,
onSubmit : ( e ) => {
e . preventDefault ( ) ;
setLoading ( true ) ;
/** @type {HTMLFormElement} */ // @ts-ignore
const formEl = e . target ;
( 0 , _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _7 _ _ /* ["default"] */ . Z ) ( "/api/unsubscribe" , {
method : "post" ,
body : {
email : email ,
alerts : formEl [ "alerts_checkbox" ] . checked ,
userId : user ? . id ? user . id : null
}
} ) . then ( ( res ) => {
console . log ( res ) ;
setLoading ( false ) ;
} ) ;
} ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
className : "bg-slate-100 py-1 px-3 rounded-full" ,
children : email
} ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "flex items-center gap-1" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "input" , {
type : "checkbox" ,
name : "alerts_checkbox" ,
id : "alerts_checkbox" ,
defaultChecked : existingAlerts ? true : false ,
className : "w-6 h-6"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "label" , {
htmlFor : "alerts_checkbox" ,
className : "text-base whitespace-nowrap text-slate-800" ,
children : "Alerts"
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "button" , {
children : "Save Settings"
} )
]
} )
]
} )
]
} )
} )
} )
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Server Side Props or Static Props
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ type { import ( "next" ) . GetServerSideProps }
* / a s y n c f u n c t i o n g e t S e r v e r S i d e P r o p s ( { r e q , r e s , q u e r y } ) {
// ## Environment processes
const productionEnvironment = process . env . DSQL _HOST _ENV ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* User Authentication
*
* @ description User authentication
* / c o n s t u s e r = a w a i t _ f u n c t i o n s _ b a c k e n d _ u s e r A u t h _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 4 _ _ _ d e f a u l t ( ) ( r e q , r e s ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Page / Site Data Data Fetching
*
* @ description Fetch data on the server before returning
* / c o n s t e m a i l = q u e r y . e m a i l ? q u e r y . e m a i l : u s e r ? . e m a i l ? u s e r . e m a i l : n u l l ;
let existingAlerts = await _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _6 _ _ _default ( ) ( ` SELECT email FROM unsubscribes WHERE email=' ${ email } ' AND type='alerts' ` ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Server props return
*
* @ description Return data fetched on the server side
* / r e t u r n {
props : {
user : user ,
email : email ,
productionEnvironment ,
existingAlerts : existingAlerts [ 0 ] ? false : true
}
} ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ } ) ,
/***/ 386 :
/***/ ( ( module ) => {
module . exports = require ( "@mui/icons-material/CottageTwoTone" ) ;
/***/ } ) ,
/***/ 5557 :
/***/ ( ( module ) => {
module . exports = require ( "@mui/icons-material/MenuBookTwoTone" ) ;
/***/ } ) ,
/***/ 2423 :
/***/ ( ( module ) => {
module . exports = require ( "lucide-react" ) ;
/***/ } ) ,
/***/ 968 :
/***/ ( ( module ) => {
module . exports = require ( "next/head" ) ;
/***/ } ) ,
/***/ 6689 :
/***/ ( ( module ) => {
module . exports = require ( "react" ) ;
/***/ } ) ,
/***/ 997 :
/***/ ( ( module ) => {
module . exports = require ( "react/jsx-runtime" ) ;
/***/ } ) ,
/***/ 2261 :
/***/ ( ( module ) => {
module . exports = require ( "serverless-mysql" ) ;
/***/ } ) ,
/***/ 4300 :
/***/ ( ( module ) => {
module . exports = require ( "buffer" ) ;
/***/ } ) ,
/***/ 6113 :
/***/ ( ( module ) => {
module . exports = require ( "crypto" ) ;
/***/ } ) ,
/***/ 7147 :
/***/ ( ( module ) => {
module . exports = require ( "fs" ) ;
/***/ } ) ,
/***/ 3685 :
/***/ ( ( module ) => {
module . exports = require ( "http" ) ;
/***/ } ) ,
/***/ 1017 :
/***/ ( ( module ) => {
module . exports = require ( "path" ) ;
/***/ } )
} ;
;
// load runtime
var _ _webpack _require _ _ = require ( "../webpack-runtime.js" ) ;
_ _webpack _require _ _ . C ( exports ) ;
var _ _webpack _exec _ _ = ( moduleId ) => ( _ _webpack _require _ _ ( _ _webpack _require _ _ . s = moduleId ) )
2024-11-05 14:18:40 +00:00
var _ _webpack _exports _ _ = _ _webpack _require _ _ . X ( 0 , [ 4017 , 8313 , 5264 , 6729 , 5449 , 913 , 4480 , 370 , 9360 , 6217 , 4097 ] , ( ) => ( _ _webpack _exec _ _ ( 5591 ) ) ) ;
2024-11-05 11:12:42 +00:00
module . exports = _ _webpack _exports _ _ ;
} ) ( ) ;