How to use userData method in argos

Best JavaScript code snippet using argos

manage-employees.js

Source:manage-employees.js Github

copy

Full Screen

1import { Button, Table } from "antd";2import { useState } from "react";3import Profile from "../../components/Profile";4import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";5import {6 faChartBar,7 faUsersCog,8 faUtensils,9 faBed,10 faConciergeBell,11 faHotel,12 faCogs,13 faUsers,14} from "@fortawesome/free-solid-svg-icons";15import { SideBar } from "../../components/SideBar";16const columns = [17 {18 title: "Id",19 dataIndex: "id",20 key: "id",21 },22 {23 title: "Username",24 dataIndex: "username",25 key: "username",26 },27 {28 title: "Position",29 dataIndex: "position",30 key: "position",31 },32 {33 title: "Department",34 dataIndex: "department",35 key: "department",36 },37 {38 title: "Gender",39 dataIndex: "gender",40 key: "gender",41 },42 {43 title: "BirthDate",44 dataIndex: "birthDate",45 key: "birthDate",46 },47 {48 title: "phone",49 dataIndex: "phone",50 key: "phone",51 },52 {53 title: "Email",54 dataIndex: "email",55 key: "email",56 },57 {58 title: "Action",59 dataIndex: "action",60 key: "action",61 },62];63const userData = {64 id: 1,65 personal: {66 name: "Someone Named",67 gender: "Female",68 birthDate: "28-08-1985",69 address: "Addis Ababa / Saris",70 phone: "(+251) 9 1234 1234",71 email: "someone@gmail.com",72 },73 extra: {74 emergencyContact: {75 name: "Emergency Center",76 phone: "(+251) 9 11",77 },78 bankNo: "100005123124",79 },80 employment: {81 position: "Manager",82 department: "Finance",83 salary: 1231,84 },85};86const UserList = () => {87 const [showProfile, setShowProfile] = useState(false);88 const [profileName, setProfileName] = useState(false);89 const dataSource = [90 {91 id: userData.id,92 username: userData.personal.name,93 position: userData.employment.position,94 department: userData.employment.department,95 gender: userData.personal.gender,96 birthDate: userData.personal.birthDate,97 phone: userData.personal.phone,98 email: userData.personal.email,99 action: [100 <Button key={0} onClick={() => dispProf("view")}>101 View102 </Button>,103 <Button key={1} onClick={() => dispProf("edit")}>104 Edit105 </Button>,106 <Button key={2}>Remove</Button>,107 ],108 },109 {110 id: userData.id,111 username: userData.personal.name,112 position: userData.employment.position,113 department: userData.employment.department,114 gender: userData.personal.gender,115 birthDate: userData.personal.birthDate,116 phone: userData.personal.phone,117 email: userData.personal.email,118 action: [119 <Button key={0} onClick={() => dispProf("view")}>120 View121 </Button>,122 <Button key={1} onClick={() => dispProf("edit")}>123 Edit124 </Button>,125 <Button key={2}>Remove</Button>,126 ],127 },128 {129 id: userData.id,130 username: userData.personal.name,131 position: userData.employment.position,132 department: userData.employment.department,133 gender: userData.personal.gender,134 birthDate: userData.personal.birthDate,135 phone: userData.personal.phone,136 email: userData.personal.email,137 action: [138 <Button key={0} onClick={() => dispProf("view")}>139 View140 </Button>,141 <Button key={1} onClick={() => dispProf("edit")}>142 Edit143 </Button>,144 <Button key={2}>Remove</Button>,145 ],146 },147 {148 id: userData.id,149 username: userData.personal.name,150 position: userData.employment.position,151 department: userData.employment.department,152 gender: userData.personal.gender,153 birthDate: userData.personal.birthDate,154 phone: userData.personal.phone,155 email: userData.personal.email,156 action: [157 <Button key={0} onClick={() => dispProf("view")}>158 View159 </Button>,160 <Button key={1} onClick={() => dispProf("edit")}>161 Edit162 </Button>,163 <Button key={2}>Remove</Button>,164 ],165 },166 {167 id: userData.id,168 username: userData.personal.name,169 position: userData.employment.position,170 department: userData.employment.department,171 gender: userData.personal.gender,172 birthDate: userData.personal.birthDate,173 phone: userData.personal.phone,174 email: userData.personal.email,175 action: [176 <Button key={0} onClick={() => dispProf("view")}>177 View178 </Button>,179 <Button key={1} onClick={() => dispProf("edit")}>180 Edit181 </Button>,182 <Button key={2}>Remove</Button>,183 ],184 },185 {186 id: userData.id,187 username: userData.personal.name,188 position: userData.employment.position,189 department: userData.employment.department,190 gender: userData.personal.gender,191 birthDate: userData.personal.birthDate,192 phone: userData.personal.phone,193 email: userData.personal.email,194 action: [195 <Button key={0} onClick={() => dispProf("view")}>196 View197 </Button>,198 <Button key={1} onClick={() => dispProf("edit")}>199 Edit200 </Button>,201 <Button key={2}>Remove</Button>,202 ],203 },204 {205 id: userData.id,206 username: userData.personal.name,207 position: userData.employment.position,208 department: userData.employment.department,209 gender: userData.personal.gender,210 birthDate: userData.personal.birthDate,211 phone: userData.personal.phone,212 email: userData.personal.email,213 action: [214 <Button key={0} onClick={() => dispProf("view")}>215 View216 </Button>,217 <Button key={1} onClick={() => dispProf("edit")}>218 Edit219 </Button>,220 <Button key={2}>Remove</Button>,221 ],222 },223 {224 id: userData.id,225 username: userData.personal.name,226 position: userData.employment.position,227 department: userData.employment.department,228 gender: userData.personal.gender,229 birthDate: userData.personal.birthDate,230 phone: userData.personal.phone,231 email: userData.personal.email,232 action: [233 <Button key={0} onClick={() => dispProf("view")}>234 View235 </Button>,236 <Button key={1} onClick={() => dispProf("edit")}>237 Edit238 </Button>,239 <Button key={2}>Remove</Button>,240 ],241 },242 {243 id: userData.id,244 username: userData.personal.name,245 position: userData.employment.position,246 department: userData.employment.department,247 gender: userData.personal.gender,248 birthDate: userData.personal.birthDate,249 phone: userData.personal.phone,250 email: userData.personal.email,251 action: [252 <Button key={0} onClick={() => dispProf("view")}>253 View254 </Button>,255 <Button key={1} onClick={() => dispProf("edit")}>256 Edit257 </Button>,258 <Button key={2}>Remove</Button>,259 ],260 },261 {262 id: userData.id,263 username: userData.personal.name,264 position: userData.employment.position,265 department: userData.employment.department,266 gender: userData.personal.gender,267 birthDate: userData.personal.birthDate,268 phone: userData.personal.phone,269 email: userData.personal.email,270 action: [271 <Button key={0} onClick={() => dispProf("view")}>272 View273 </Button>,274 <Button key={1} onClick={() => dispProf("edit")}>275 Edit276 </Button>,277 <Button key={2}>Remove</Button>,278 ],279 },280 {281 id: userData.id,282 username: userData.personal.name,283 position: userData.employment.position,284 department: userData.employment.department,285 gender: userData.personal.gender,286 birthDate: userData.personal.birthDate,287 phone: userData.personal.phone,288 email: userData.personal.email,289 action: [290 <Button key={0} onClick={() => dispProf("view")}>291 View292 </Button>,293 <Button key={1} onClick={() => dispProf("edit")}>294 Edit295 </Button>,296 <Button key={2}>Remove</Button>,297 ],298 },299 {300 id: userData.id,301 username: userData.personal.name,302 position: userData.employment.position,303 department: userData.employment.department,304 gender: userData.personal.gender,305 birthDate: userData.personal.birthDate,306 phone: userData.personal.phone,307 email: userData.personal.email,308 action: [309 <Button key={0} onClick={() => dispProf("view")}>310 View311 </Button>,312 <Button key={1} onClick={() => dispProf("edit")}>313 Edit314 </Button>,315 <Button key={2}>Remove</Button>,316 ],317 },318 {319 id: userData.id,320 username: userData.personal.name,321 position: userData.employment.position,322 department: userData.employment.department,323 gender: userData.personal.gender,324 birthDate: userData.personal.birthDate,325 phone: userData.personal.phone,326 email: userData.personal.email,327 action: [328 <Button key={0} onClick={() => dispProf("view")}>329 View330 </Button>,331 <Button key={1} onClick={() => dispProf("edit")}>332 Edit333 </Button>,334 <Button key={2}>Remove</Button>,335 ],336 },337 {338 id: userData.id,339 username: userData.personal.name,340 position: userData.employment.position,341 department: userData.employment.department,342 gender: userData.personal.gender,343 birthDate: userData.personal.birthDate,344 phone: userData.personal.phone,345 email: userData.personal.email,346 action: [347 <Button key={0} onClick={() => dispProf("view")}>348 View349 </Button>,350 <Button key={1} onClick={() => dispProf("edit")}>351 Edit352 </Button>,353 <Button key={2}>Remove</Button>,354 ],355 },356 {357 id: userData.id,358 username: userData.personal.name,359 position: userData.employment.position,360 department: userData.employment.department,361 gender: userData.personal.gender,362 birthDate: userData.personal.birthDate,363 phone: userData.personal.phone,364 email: userData.personal.email,365 action: [366 <Button key={0} onClick={() => dispProf("view")}>367 View368 </Button>,369 <Button key={1} onClick={() => dispProf("edit")}>370 Edit371 </Button>,372 <Button key={2}>Remove</Button>,373 ],374 },375 {376 id: userData.id,377 username: userData.personal.name,378 position: userData.employment.position,379 department: userData.employment.department,380 gender: userData.personal.gender,381 birthDate: userData.personal.birthDate,382 phone: userData.personal.phone,383 email: userData.personal.email,384 action: [385 <Button key={0} onClick={() => dispProf("view")}>386 View387 </Button>,388 <Button key={1} onClick={() => dispProf("edit")}>389 Edit390 </Button>,391 <Button key={2}>Remove</Button>,392 ],393 },394 {395 id: userData.id,396 username: userData.personal.name,397 position: userData.employment.position,398 department: userData.employment.department,399 gender: userData.personal.gender,400 birthDate: userData.personal.birthDate,401 phone: userData.personal.phone,402 email: userData.personal.email,403 action: [404 <Button key={0} onClick={() => dispProf("view")}>405 View406 </Button>,407 <Button key={1} onClick={() => dispProf("edit")}>408 Edit409 </Button>,410 <Button key={2}>Remove</Button>,411 ],412 },413 {414 id: userData.id,415 username: userData.personal.name,416 position: userData.employment.position,417 department: userData.employment.department,418 gender: userData.personal.gender,419 birthDate: userData.personal.birthDate,420 phone: userData.personal.phone,421 email: userData.personal.email,422 action: [423 <Button key={0} onClick={() => dispProf("view")}>424 View425 </Button>,426 <Button key={1} onClick={() => dispProf("edit")}>427 Edit428 </Button>,429 <Button key={2}>Remove</Button>,430 ],431 },432 {433 id: userData.id,434 username: userData.personal.name,435 position: userData.employment.position,436 department: userData.employment.department,437 gender: userData.personal.gender,438 birthDate: userData.personal.birthDate,439 phone: userData.personal.phone,440 email: userData.personal.email,441 action: [442 <Button key={0} onClick={() => dispProf("view")}>443 View444 </Button>,445 <Button key={1} onClick={() => dispProf("edit")}>446 Edit447 </Button>,448 <Button key={2}>Remove</Button>,449 ],450 },451 {452 id: userData.id,453 username: userData.personal.name,454 position: userData.employment.position,455 department: userData.employment.department,456 gender: userData.personal.gender,457 birthDate: userData.personal.birthDate,458 phone: userData.personal.phone,459 email: userData.personal.email,460 action: [461 <Button key={0} onClick={() => dispProf("view")}>462 View463 </Button>,464 <Button key={1} onClick={() => dispProf("edit")}>465 Edit466 </Button>,467 <Button key={2}>Remove</Button>,468 ],469 },470 {471 id: userData.id,472 username: userData.personal.name,473 position: userData.employment.position,474 department: userData.employment.department,475 gender: userData.personal.gender,476 birthDate: userData.personal.birthDate,477 phone: userData.personal.phone,478 email: userData.personal.email,479 action: [480 <Button key={0} onClick={() => dispProf("view")}>481 View482 </Button>,483 <Button key={1} onClick={() => dispProf("edit")}>484 Edit485 </Button>,486 <Button key={2}>Remove</Button>,487 ],488 },489 {490 id: userData.id,491 username: userData.personal.name,492 position: userData.employment.position,493 department: userData.employment.department,494 gender: userData.personal.gender,495 birthDate: userData.personal.birthDate,496 phone: userData.personal.phone,497 email: userData.personal.email,498 action: [499 <Button key={0} onClick={() => dispProf("view")}>500 View501 </Button>,502 <Button key={1} onClick={() => dispProf("edit")}>503 Edit504 </Button>,505 <Button key={2}>Remove</Button>,506 ],507 },508 {509 id: userData.id,510 username: userData.personal.name,511 position: userData.employment.position,512 department: userData.employment.department,513 gender: userData.personal.gender,514 birthDate: userData.personal.birthDate,515 phone: userData.personal.phone,516 email: userData.personal.email,517 action: [518 <Button key={0} onClick={() => dispProf("view")}>519 View520 </Button>,521 <Button key={1} onClick={() => dispProf("edit")}>522 Edit523 </Button>,524 <Button key={2}>Remove</Button>,525 ],526 },527 {528 id: userData.id,529 username: userData.personal.name,530 position: userData.employment.position,531 department: userData.employment.department,532 gender: userData.personal.gender,533 birthDate: userData.personal.birthDate,534 phone: userData.personal.phone,535 email: userData.personal.email,536 action: [537 <Button key={0} onClick={() => dispProf("view")}>538 View539 </Button>,540 <Button key={1} onClick={() => dispProf("edit")}>541 Edit542 </Button>,543 <Button key={2}>Remove</Button>,544 ],545 },546 {547 id: userData.id,548 username: userData.personal.name,549 position: userData.employment.position,550 department: userData.employment.department,551 gender: userData.personal.gender,552 birthDate: userData.personal.birthDate,553 phone: userData.personal.phone,554 email: userData.personal.email,555 action: [556 <Button key={0} onClick={() => dispProf("view")}>557 View558 </Button>,559 <Button key={1} onClick={() => dispProf("edit")}>560 Edit561 </Button>,562 <Button key={2}>Remove</Button>,563 ],564 },565 {566 id: userData.id,567 username: userData.personal.name,568 position: userData.employment.position,569 department: userData.employment.department,570 gender: userData.personal.gender,571 birthDate: userData.personal.birthDate,572 phone: userData.personal.phone,573 email: userData.personal.email,574 action: [575 <Button key={0} onClick={() => dispProf("view")}>576 View577 </Button>,578 <Button key={1} onClick={() => dispProf("edit")}>579 Edit580 </Button>,581 <Button key={2}>Remove</Button>,582 ],583 },584 {585 id: userData.id,586 username: userData.personal.name,587 position: userData.employment.position,588 department: userData.employment.department,589 gender: userData.personal.gender,590 birthDate: userData.personal.birthDate,591 phone: userData.personal.phone,592 email: userData.personal.email,593 action: [594 <Button key={0} onClick={() => dispProf("view")}>595 View596 </Button>,597 <Button key={1} onClick={() => dispProf("edit")}>598 Edit599 </Button>,600 <Button key={2}>Remove</Button>,601 ],602 },603 {604 id: userData.id,605 username: userData.personal.name,606 position: userData.employment.position,607 department: userData.employment.department,608 gender: userData.personal.gender,609 birthDate: userData.personal.birthDate,610 phone: userData.personal.phone,611 email: userData.personal.email,612 action: [613 <Button key={0} onClick={() => dispProf("view")}>614 View615 </Button>,616 <Button key={1} onClick={() => dispProf("edit")}>617 Edit618 </Button>,619 <Button key={2}>Remove</Button>,620 ],621 },622 {623 id: userData.id,624 username: userData.personal.name,625 position: userData.employment.position,626 department: userData.employment.department,627 gender: userData.personal.gender,628 birthDate: userData.personal.birthDate,629 phone: userData.personal.phone,630 email: userData.personal.email,631 action: [632 <Button key={0} onClick={() => dispProf("view")}>633 View634 </Button>,635 <Button key={1} onClick={() => dispProf("edit")}>636 Edit637 </Button>,638 <Button key={2}>Remove</Button>,639 ],640 },641 {642 id: userData.id,643 username: userData.personal.name,644 position: userData.employment.position,645 department: userData.employment.department,646 gender: userData.personal.gender,647 birthDate: userData.personal.birthDate,648 phone: userData.personal.phone,649 email: userData.personal.email,650 action: [651 <Button key={0} onClick={() => dispProf("view")}>652 View653 </Button>,654 <Button key={1} onClick={() => dispProf("edit")}>655 Edit656 </Button>,657 <Button key={2}>Remove</Button>,658 ],659 },660 {661 id: userData.id,662 username: userData.personal.name,663 position: userData.employment.position,664 department: userData.employment.department,665 gender: userData.personal.gender,666 birthDate: userData.personal.birthDate,667 phone: userData.personal.phone,668 email: userData.personal.email,669 action: [670 <Button key={0} onClick={() => dispProf("view")}>671 View672 </Button>,673 <Button key={1} onClick={() => dispProf("edit")}>674 Edit675 </Button>,676 <Button key={2}>Remove</Button>,677 ],678 },679 {680 id: userData.id,681 username: userData.personal.name,682 position: userData.employment.position,683 department: userData.employment.department,684 gender: userData.personal.gender,685 birthDate: userData.personal.birthDate,686 phone: userData.personal.phone,687 email: userData.personal.email,688 action: [689 <Button key={0} onClick={() => dispProf("view")}>690 View691 </Button>,692 <Button key={1} onClick={() => dispProf("edit")}>693 Edit694 </Button>,695 <Button key={2}>Remove</Button>,696 ],697 },698 {699 id: userData.id,700 username: userData.personal.name,701 position: userData.employment.position,702 department: userData.employment.department,703 gender: userData.personal.gender,704 birthDate: userData.personal.birthDate,705 phone: userData.personal.phone,706 email: userData.personal.email,707 action: [708 <Button key={0} onClick={() => dispProf("view")}>709 View710 </Button>,711 <Button key={1} onClick={() => dispProf("edit")}>712 Edit713 </Button>,714 <Button key={2}>Remove</Button>,715 ],716 },717 {718 id: userData.id,719 username: userData.personal.name,720 position: userData.employment.position,721 department: userData.employment.department,722 gender: userData.personal.gender,723 birthDate: userData.personal.birthDate,724 phone: userData.personal.phone,725 email: userData.personal.email,726 action: [727 <Button key={0} onClick={() => dispProf("view")}>728 View729 </Button>,730 <Button key={1} onClick={() => dispProf("edit")}>731 Edit732 </Button>,733 <Button key={2}>Remove</Button>,734 ],735 },736 {737 id: userData.id,738 username: userData.personal.name,739 position: userData.employment.position,740 department: userData.employment.department,741 gender: userData.personal.gender,742 birthDate: userData.personal.birthDate,743 phone: userData.personal.phone,744 email: userData.personal.email,745 action: [746 <Button key={0} onClick={() => dispProf("view")}>747 View748 </Button>,749 <Button key={1} onClick={() => dispProf("edit")}>750 Edit751 </Button>,752 <Button key={2}>Remove</Button>,753 ],754 },755 {756 id: userData.id,757 username: userData.personal.name,758 position: userData.employment.position,759 department: userData.employment.department,760 gender: userData.personal.gender,761 birthDate: userData.personal.birthDate,762 phone: userData.personal.phone,763 email: userData.personal.email,764 action: [765 <Button key={0} onClick={() => dispProf("view")}>766 View767 </Button>,768 <Button key={1} onClick={() => dispProf("edit")}>769 Edit770 </Button>,771 <Button key={2}>Remove</Button>,772 ],773 },774 {775 id: userData.id,776 username: userData.personal.name,777 position: userData.employment.position,778 department: userData.employment.department,779 gender: userData.personal.gender,780 birthDate: userData.personal.birthDate,781 phone: userData.personal.phone,782 email: userData.personal.email,783 action: [784 <Button key={0} onClick={() => dispProf("view")}>785 View786 </Button>,787 <Button key={1} onClick={() => dispProf("edit")}>788 Edit789 </Button>,790 <Button key={2}>Remove</Button>,791 ],792 },793 {794 id: userData.id,795 username: userData.personal.name,796 position: userData.employment.position,797 department: userData.employment.department,798 gender: userData.personal.gender,799 birthDate: userData.personal.birthDate,800 phone: userData.personal.phone,801 email: userData.personal.email,802 action: [803 <Button key={0} onClick={() => dispProf("view")}>804 View805 </Button>,806 <Button key={1} onClick={() => dispProf("edit")}>807 Edit808 </Button>,809 <Button key={2}>Remove</Button>,810 ],811 },812 {813 id: userData.id,814 username: userData.personal.name,815 position: userData.employment.position,816 department: userData.employment.department,817 gender: userData.personal.gender,818 birthDate: userData.personal.birthDate,819 phone: userData.personal.phone,820 email: userData.personal.email,821 action: [822 <Button key={0} onClick={() => dispProf("view")}>823 View824 </Button>,825 <Button key={1} onClick={() => dispProf("edit")}>826 Edit827 </Button>,828 <Button key={2}>Remove</Button>,829 ],830 },831 {832 id: userData.id,833 username: userData.personal.name,834 position: userData.employment.position,835 department: userData.employment.department,836 gender: userData.personal.gender,837 birthDate: userData.personal.birthDate,838 phone: userData.personal.phone,839 email: userData.personal.email,840 action: [841 <Button key={0} onClick={() => dispProf("view")}>842 View843 </Button>,844 <Button key={1} onClick={() => dispProf("edit")}>845 Edit846 </Button>,847 <Button key={2}>Remove</Button>,848 ],849 },850 {851 id: userData.id,852 username: userData.personal.name,853 position: userData.employment.position,854 department: userData.employment.department,855 gender: userData.personal.gender,856 birthDate: userData.personal.birthDate,857 phone: userData.personal.phone,858 email: userData.personal.email,859 action: [860 <Button key={0} onClick={() => dispProf("view")}>861 View862 </Button>,863 <Button key={1} onClick={() => dispProf("edit")}>864 Edit865 </Button>,866 <Button key={2}>Remove</Button>,867 ],868 },869 {870 id: userData.id,871 username: userData.personal.name,872 position: userData.employment.position,873 department: userData.employment.department,874 gender: userData.personal.gender,875 birthDate: userData.personal.birthDate,876 phone: userData.personal.phone,877 email: userData.personal.email,878 action: [879 <Button key={0} onClick={() => dispProf("view")}>880 View881 </Button>,882 <Button key={1} onClick={() => dispProf("edit")}>883 Edit884 </Button>,885 <Button key={2}>Remove</Button>,886 ],887 },888 ];889 const addUser = () => {};890 const dispProf = (val) => {891 setProfileName(val);892 setShowProfile(true);893 };894 const modalProps = {895 visible: showProfile,896 onOk: addUser,897 onCancel: () => {898 setShowProfile(false);899 },900 };901 const items = [902 {903 key: "dashboard",904 url: "/admin/dashboard",905 label: "Dashboard",906 icon: <FontAwesomeIcon icon={faChartBar} />,907 },908 {909 key: "manageEmployees",910 url: "/admin/manage-employees",911 label: "Manage Employees",912 icon: <FontAwesomeIcon icon={faUsersCog} />,913 isSelected: true,914 },915 {916 key: "manageRooms",917 url: "/admin/manage-rooms",918 label: "Manage Rooms",919 icon: <FontAwesomeIcon icon={faBed} />,920 },921 {922 key: "manageFoodAndDrinks",923 url: "/admin/manage-food-and-drinks",924 label: "Manage FoodAndDrinks",925 icon: <FontAwesomeIcon icon={faUtensils} />,926 },927 {928 key: "manageServices",929 url: "/admin/manage-services",930 label: "Manage Services",931 icon: <FontAwesomeIcon icon={faConciergeBell} />,932 },933 {934 key: "manageHall",935 url: "/admin/manage-hall",936 label: "Manage Hall",937 icon: <FontAwesomeIcon icon={faHotel} />,938 },939 {940 key: "manageRoomServices",941 url: "/admin/manage-room-services",942 label: "Manage RoomServices",943 icon: <FontAwesomeIcon icon={faCogs} />,944 },945 {946 key: "manageEmployees",947 url: "/admin/manage-employees",948 label: "Manage Employees",949 icon: <FontAwesomeIcon icon={faUsers} />,950 },951 {952 key: "viewReservedRooms",953 url: "/admin/view-reserved-rooms",954 label: "View Reserved Rooms",955 icon: <FontAwesomeIcon icon={faBed} />,956 },957 {958 key: "viewOrderedFoodAndDrinks",959 url: "/admin/view-ordered-food-and-drinks",960 label: "View Ordered Food&Drinks",961 icon: <FontAwesomeIcon icon={faUtensils} />,962 },963 {964 key: "viewOrderedRoomServices",965 url: "/admin/view-ordered-room-services",966 label: "View Ordered RoomServices",967 icon: <FontAwesomeIcon icon={faCogs} />,968 },969 ];970 return (971 <div972 className={`d-flex justify-content-center flex-fill`}973 style={{ paddingTop: "100px" }}974 >975 <div className={`mt-4`}>976 <SideBar items={items} />977 </div>978 <div className={`d-flex flex-column flex-fill`}>979 <div className="pd-big">980 <div className="aln-r pd">981 <Button982 onClick={() => dispProf("add")}983 type="default"984 className={`px-3 py-2 fs-1`}985 >986 + Add User987 </Button>988 </div>989 <Table990 dataSource={dataSource}991 columns={columns}992 pagination={{ current: 1, pageSize: 5 }}993 />994 ;995 <Profile name={profileName} data={userData} modalProps={modalProps} />996 </div>997 </div>998 </div>999 );1000};...

Full Screen

Full Screen

helpers.js

Source:helpers.js Github

copy

Full Screen

1'use strict';2var async = require('async');3var validator = require('validator');4var winston = require('winston');5var nconf = require('nconf');6var user = require('../../user');7var groups = require('../../groups');8var plugins = require('../../plugins');9var meta = require('../../meta');10var utils = require('../../utils');11var privileges = require('../../privileges');12var helpers = module.exports;13helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {14 async.waterfall([15 function (next) {16 user.getUidByUserslug(userslug, next);17 },18 function (uid, next) {19 if (!uid) {20 return callback(null, null);21 }22 async.parallel({23 userData: function (next) {24 user.getUserData(uid, next);25 },26 isTargetAdmin: function (next) {27 user.isAdministrator(uid, next);28 },29 userSettings: function (next) {30 user.getSettings(uid, next);31 },32 isAdmin: function (next) {33 user.isAdministrator(callerUID, next);34 },35 isGlobalModerator: function (next) {36 user.isGlobalModerator(callerUID, next);37 },38 isModerator: function (next) {39 user.isModeratorOfAnyCategory(callerUID, next);40 },41 isFollowing: function (next) {42 user.isFollowing(callerUID, uid, next);43 },44 ips: function (next) {45 user.getIPs(uid, 4, next);46 },47 profile_menu: function (next) {48 plugins.fireHook('filter:user.profileMenu', {49 uid: uid,50 callerUID: callerUID,51 links: [{52 id: 'info',53 route: 'info',54 name: '[[user:account_info]]',55 visibility: {56 self: false,57 other: false,58 moderator: true,59 globalMod: true,60 admin: true,61 },62 }, {63 id: 'consent',64 route: 'consent',65 name: '[[user:consent.title]]',66 visibility: {67 self: true,68 other: false,69 moderator: false,70 globalMod: false,71 admin: false,72 },73 }],74 }, next);75 },76 groups: function (next) {77 groups.getUserGroups([uid], next);78 },79 sso: function (next) {80 plugins.fireHook('filter:auth.list', { uid: uid, associations: [] }, next);81 },82 canEdit: function (next) {83 privileges.users.canEdit(callerUID, uid, next);84 },85 canBanUser: function (next) {86 privileges.users.canBanUser(callerUID, uid, next);87 },88 isBlocked: function (next) {89 user.blocks.is(uid, callerUID, next);90 },91 }, next);92 },93 function (results, next) {94 if (!results.userData) {95 return callback(new Error('[[error:invalid-uid]]'));96 }97 var userData = results.userData;98 var userSettings = results.userSettings;99 var isAdmin = results.isAdmin;100 var isGlobalModerator = results.isGlobalModerator;101 var isModerator = results.isModerator;102 var isSelf = parseInt(callerUID, 10) === parseInt(userData.uid, 10);103 userData.joindateISO = utils.toISOString(userData.joindate);104 userData.lastonlineISO = utils.toISOString(userData.lastonline || userData.joindate);105 userData.age = Math.max(0, userData.birthday ? Math.floor((new Date().getTime() - new Date(userData.birthday).getTime()) / 31536000000) : 0);106 userData.emailClass = 'hide';107 if (!isAdmin && !isGlobalModerator && !isSelf && (!userSettings.showemail || parseInt(meta.config.hideEmail, 10) === 1)) {108 userData.email = '';109 } else if (!userSettings.showemail) {110 userData.emailClass = '';111 }112 if (!isAdmin && !isGlobalModerator && !isSelf && (!userSettings.showfullname || parseInt(meta.config.hideFullname, 10) === 1)) {113 userData.fullname = '';114 }115 if (isAdmin || isSelf || ((isGlobalModerator || isModerator) && !results.isTargetAdmin)) {116 userData.ips = results.ips;117 }118 if (!isAdmin && !isGlobalModerator && !isModerator) {119 userData.moderationNote = undefined;120 }121 userData.isBlocked = results.isBlocked;122 if (isAdmin || isSelf) {123 userData.blocksCount = parseInt(userData.blocksCount, 10) || 0;124 }125 userData.yourid = callerUID;126 userData.theirid = userData.uid;127 userData.isTargetAdmin = results.isTargetAdmin;128 userData.isAdmin = isAdmin;129 userData.isGlobalModerator = isGlobalModerator;130 userData.isModerator = isModerator;131 userData.isAdminOrGlobalModerator = isAdmin || isGlobalModerator;132 userData.isAdminOrGlobalModeratorOrModerator = isAdmin || isGlobalModerator || isModerator;133 userData.isSelfOrAdminOrGlobalModerator = isSelf || isAdmin || isGlobalModerator;134 userData.canEdit = results.canEdit;135 userData.canBan = results.canBanUser;136 userData.canChangePassword = isAdmin || (isSelf && parseInt(meta.config['password:disableEdit'], 10) !== 1);137 userData.isSelf = isSelf;138 userData.isFollowing = results.isFollowing;139 userData.showHidden = isSelf || isAdmin || (isGlobalModerator && !results.isTargetAdmin);140 userData.groups = Array.isArray(results.groups) && results.groups.length ? results.groups[0] : [];141 userData.disableSignatures = meta.config.disableSignatures !== undefined && parseInt(meta.config.disableSignatures, 10) === 1;142 userData['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;143 userData['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1;144 userData['email:confirmed'] = !!parseInt(userData['email:confirmed'], 10);145 userData.profile_links = filterLinks(results.profile_menu.links, {146 self: isSelf,147 other: !isSelf,148 moderator: isModerator,149 globalMod: isGlobalModerator,150 admin: isAdmin,151 });152 userData.sso = results.sso.associations;153 userData.status = user.getStatus(userData);154 userData.banned = parseInt(userData.banned, 10) === 1;155 userData.website = validator.escape(String(userData.website || ''));156 userData.websiteLink = !userData.website.startsWith('http') ? 'http://' + userData.website : userData.website;157 userData.websiteName = userData.website.replace(validator.escape('http://'), '').replace(validator.escape('https://'), '');158 userData.followingCount = parseInt(userData.followingCount, 10) || 0;159 userData.followerCount = parseInt(userData.followerCount, 10) || 0;160 userData.email = validator.escape(String(userData.email || ''));161 userData.fullname = validator.escape(String(userData.fullname || ''));162 userData.location = validator.escape(String(userData.location || ''));163 userData.signature = validator.escape(String(userData.signature || ''));164 userData.aboutme = validator.escape(String(userData.aboutme || ''));165 userData.birthday = validator.escape(String(userData.birthday || ''));166 userData.moderationNote = validator.escape(String(userData.moderationNote || ''));167 if (userData['cover:url']) {168 userData['cover:url'] = userData['cover:url'].startsWith('http') ? userData['cover:url'] : (nconf.get('relative_path') + userData['cover:url']);169 } else {170 userData['cover:url'] = require('../../coverPhoto').getDefaultProfileCover(userData.uid);171 }172 userData['cover:position'] = validator.escape(String(userData['cover:position'] || '50% 50%'));173 userData['username:disableEdit'] = !userData.isAdmin && parseInt(meta.config['username:disableEdit'], 10) === 1;174 userData['email:disableEdit'] = !userData.isAdmin && parseInt(meta.config['email:disableEdit'], 10) === 1;175 next(null, userData);176 },177 ], callback);178};179helpers.getBaseUser = function (userslug, callerUID, callback) {180 winston.warn('helpers.getBaseUser deprecated please use helpers.getUserDataByUserSlug');181 helpers.getUserDataByUserSlug(userslug, callerUID, callback);182};183function filterLinks(links, states) {184 return links.filter(function (link, index) {185 // "public" is the old property, if visibility is defined, discard `public`186 if (link.hasOwnProperty('public') && !link.hasOwnProperty('visibility')) {187 winston.warn('[account/profileMenu (' + link.id + ')] Use of the `.public` property is deprecated, use `visibility` now');188 return link && (link.public || states.self);189 }190 // Default visibility191 link.visibility = Object.assign({192 self: true,193 other: true,194 moderator: true,195 globalMod: true,196 admin: true,197 }, link.visibility);198 var permit = Object.keys(states).some(function (state) {199 return states[state] && link.visibility[state];200 });201 links[index].public = permit;202 return permit;203 });...

Full Screen

Full Screen

edit.js

Source:edit.js Github

copy

Full Screen

1'use strict';2var async = require('async');3var db = require('../../database');4var user = require('../../user');5var meta = require('../../meta');6var plugins = require('../../plugins');7var helpers = require('../helpers');8var groups = require('../../groups');9var accountHelpers = require('./helpers');10var privileges = require('../../privileges');11var file = require('../../file');12var editController = module.exports;13editController.get = function (req, res, callback) {14 async.waterfall([15 function (next) {16 async.parallel({17 userData: function (next) {18 accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next);19 },20 canUseSignature: function (next) {21 privileges.global.can('signature', req.uid, next);22 },23 }, next);24 },25 function (results, next) {26 var userData = results.userData;27 if (!userData) {28 return callback();29 }30 userData.maximumSignatureLength = parseInt(meta.config.maximumSignatureLength, 10) || 255;31 userData.maximumAboutMeLength = parseInt(meta.config.maximumAboutMeLength, 10) || 1000;32 userData.maximumProfileImageSize = parseInt(meta.config.maximumProfileImageSize, 10);33 userData.allowProfilePicture = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:profile-picture'], 10) || 0);34 userData.allowCoverPicture = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:cover-picture'], 10) || 0);35 userData.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads, 10) === 1;36 userData.allowMultipleBadges = parseInt(meta.config.allowMultipleBadges, 10) === 1;37 userData.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1;38 userData.allowWebsite = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:website'], 10) || 0);39 userData.allowAboutMe = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:aboutme'], 10) || 0);40 userData.allowSignature = results.canUseSignature && (!userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:signature'], 10) || 0));41 userData.profileImageDimension = parseInt(meta.config.profileImageDimension, 10) || 200;42 userData.defaultAvatar = user.getDefaultAvatar();43 userData.groups = userData.groups.filter(function (group) {44 return group && group.userTitleEnabled && !groups.isPrivilegeGroup(group.name) && group.name !== 'registered-users';45 });46 if (!userData.allowMultipleBadges) {47 userData.groupTitle = userData.groupTitleArray[0];48 }49 userData.groups.forEach(function (group) {50 group.selected = userData.groupTitleArray.includes(group.name);51 });52 userData.title = '[[pages:account/edit, ' + userData.username + ']]';53 userData.breadcrumbs = helpers.buildBreadcrumbs([54 {55 text: userData.username,56 url: '/user/' + userData.userslug,57 },58 {59 text: '[[user:edit]]',60 },61 ]);62 userData.editButtons = [];63 plugins.fireHook('filter:user.account.edit', userData, next);64 },65 function (userData) {66 res.render('account/edit', userData);67 },68 ], callback);69};70editController.password = function (req, res, next) {71 renderRoute('password', req, res, next);72};73editController.username = function (req, res, next) {74 renderRoute('username', req, res, next);75};76editController.email = function (req, res, next) {77 renderRoute('email', req, res, next);78};79function renderRoute(name, req, res, next) {80 async.waterfall([81 function (next) {82 getUserData(req, next, next);83 },84 function (userData) {85 if (!userData) {86 return next();87 }88 if ((name === 'username' && userData['username:disableEdit']) || (name === 'email' && userData['email:disableEdit'])) {89 return next();90 }91 if (name === 'password') {92 userData.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10);93 userData.minimumPasswordStrength = parseInt(meta.config.minimumPasswordStrength || 1, 10);94 }95 userData.title = '[[pages:account/edit/' + name + ', ' + userData.username + ']]';96 userData.breadcrumbs = helpers.buildBreadcrumbs([97 {98 text: userData.username,99 url: '/user/' + userData.userslug,100 },101 {102 text: '[[user:edit]]',103 url: '/user/' + userData.userslug + '/edit',104 },105 {106 text: '[[user:' + name + ']]',107 },108 ]);109 res.render('account/edit/' + name, userData);110 },111 ], next);112}113function getUserData(req, next, callback) {114 var userData;115 async.waterfall([116 function (next) {117 accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next);118 },119 function (data, next) {120 userData = data;121 if (!userData) {122 return callback(null, null);123 }124 db.getObjectField('user:' + userData.uid, 'password', next);125 },126 function (password, next) {127 userData.hasPassword = !!password;128 next(null, userData);129 },130 ], callback);131}132editController.uploadPicture = function (req, res, next) {133 var userPhoto = req.files.files[0];134 var updateUid;135 async.waterfall([136 function (next) {137 user.getUidByUserslug(req.params.userslug, next);138 },139 function (uid, next) {140 updateUid = uid;141 privileges.users.canEdit(req.uid, uid, next);142 },143 function (isAllowed, next) {144 if (!isAllowed) {145 return helpers.notAllowed(req, res);146 }147 user.checkMinReputation(req.uid, updateUid, 'min:rep:profile-picture', next);148 },149 function (next) {150 user.uploadCroppedPicture({151 uid: updateUid,152 file: userPhoto,153 }, next);154 },155 ], function (err, image) {156 file.delete(userPhoto.path);157 if (err) {158 return next(err);159 }160 res.json([{161 name: userPhoto.name,162 url: image.url,163 }]);164 });165};166editController.uploadCoverPicture = function (req, res, next) {167 var params = JSON.parse(req.body.params);168 var coverPhoto = req.files.files[0];169 async.waterfall([170 function (next) {171 user.checkMinReputation(req.uid, params.uid, 'min:rep:cover-picture', next);172 },173 function (next) {174 user.updateCoverPicture({175 file: coverPhoto,176 uid: params.uid,177 }, next);178 },179 ], function (err, image) {180 file.delete(coverPhoto.path);181 if (err) {182 return next(err);183 }184 res.json([{185 url: image.url,186 }]);187 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyUserData = require('argosy-user-data')4var _ = require('lodash')5var service = argosy()6service.pipe(argosyUserData()).pipe(service)7service.accept({8 userData: pattern({9 })10}, function (msg, cb) {11 service.userData(msg.key, msg.value, function (err, data) {12 cb(null, data)13 })14})15service.accept({16 getUserData: pattern({17 })18}, function (msg, cb) {19 service.getUserData(msg.key, function (err, data) {20 cb(null, data)21 })22})23service.accept({24 getUserData: pattern({25 })26}, function (msg, cb) {27 service.getUserData(msg.key, msg.value, function (err, data) {28 cb(null, data)29 })30})31service.accept({32 getUserData: pattern({33 })34}, function (msg, cb) {35 service.getUserData(msg.key, msg.value, msg.options, function (err, data) {36 cb(null, data)37 })38})39service.accept({40 getUserData: pattern({41 })42}, function (msg, cb) {43 service.getUserData(msg.key, msg.options, function (err, data) {44 cb(null, data)45 })46})47service.accept({48 getUserData: pattern({49 })50}, function (msg, cb) {51 service.getUserData(msg.options, function (err, data) {52 cb(null, data)53 })54})55service.accept({56 getUserData: pattern({})57}, function (msg, cb) {58 service.getUserData(function (err, data) {59 cb(null, data)60 })61})62service.accept({63 getUserData: pattern({64 })65}, function (msg, cb) {66 service.getUserData(msg.key, msg.value, msg.options, function (err, data) {67 cb(null, data)68 })69})70service.accept({

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyUserData = require('argosy-user-data')4var argosyService = argosy()5argosyService.use(argosyUserData())6argosyService.use(argosyPattern({7}, function (msg, respond) {8 this.userData.set('hello', 'world')9 respond(null, this.userData.get('hello'))10}))11argosyService.listen(3000)12var argosy = require('argosy')13var argosyPattern = require('argosy-pattern')14var argosyUserData = require('argosy-user-data')15var argosyService = argosy()16argosyService.use(argosyUserData())17argosyService.use(argosyPattern({18}, function (msg, respond) {19 respond(null, this.userData.get('hello'))20}))21argosyService.listen(3001)

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var service = argosy()4 .use('userData', pattern({5 }, {6 }))7 .listen(8000)8var argosy = require('argosy')9var argosyPattern = require('argosy-pattern')10var service = argosy()11 .use('userData', pattern({12 }, {13 }))14 .client()15 .act('userData:1', function (err, data) {16 })

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var argosyServices = require('argosy-services')3var services = argosyServices({4 services: {5 hello: function (name, cb) {6 cb(null, 'hello ' + name)7 }8 }9})10var services2 = argosyServices({11 services: {12 hello: function (name, cb) {13 cb(null, 'hello ' + name)14 }15 }16})17var services3 = argosyServices({18 services: {19 hello: function (name, cb) {20 cb(null, 'hello ' + name)21 }22 }23})24var services4 = argosyServices({25 services: {26 hello: function (name, cb) {27 cb(null, 'hello ' + name)28 }29 }30})31var services5 = argosyServices({32 services: {33 hello: function (name, cb) {34 cb(null, 'hello ' + name)35 }36 }37})38var services6 = argosyServices({39 services: {40 hello: function (name, cb) {41 cb(null, 'hello ' + name)42 }43 }44})45var services7 = argosyServices({46 services: {47 hello: function (name, cb) {48 cb(null, 'hello ' + name)49 }50 }51})52var services8 = argosyServices({53 services: {54 hello: function (name, cb) {55 cb(null, 'hello ' + name)56 }57 }58})59var services9 = argosyServices({60 services: {61 hello: function (name, cb) {62 cb(null, 'hello ' + name)63 }64 }65})66var services10 = argosyServices({67 services: {68 hello: function (name, cb) {69 cb(null, 'hello ' + name)70 }71 }72})73var argosy1 = argosy().use(services)74var argosy2 = argosy().use(services2)75var argosy3 = argosy().use(services3)76var argosy4 = argosy().use(services4)77var argosy5 = argosy().use(services5)78var argosy6 = argosy().use(services6)

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function (options) {2 return {3 actions: {4 test: function (msg, respond) {5 seneca.act('role:userData,cmd:get', { userId: msg.userId }, function (err, result) {6 if (err) return respond(err)7 respond(null, result)8 })9 }10 }11 }12}13var seneca = require('seneca')()14seneca.use('mongo-store', {15})16seneca.ready(function () {17 var product = seneca.make$('product')18 product.save$(function (err, product) {19 console.log(product)20 })21})

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var pattern = require('argosy-pattern')3var service = argosy()4service.use('user', pattern({5 userData: pattern.object({6 })7}))8service.act('user:userData', {name: 'John', email: '

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful