Skip to content

Commit

Permalink
fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HasarAli committed Feb 25, 2022
1 parent 1981dbe commit 74c7d93
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 113 deletions.
1 change: 1 addition & 0 deletions next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require("path");

module.exports = {
i18n: {
defaultLocale: "en",
Expand Down
1 change: 0 additions & 1 deletion src/components/AddServicePage/AddService.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const AddService = ({ user }) => {
e.preventDefault();
const form = new FormData(e.target);
const images = form.getAll("images");
console.log("in handle", serviceData);
addService(user, images, serviceData);
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from "react";
import Link from "next/link";
import { useTranslation } from "next-i18next";
import { useRouter } from "next/router";
import { FooterContainer, MainContainer } from "./Footer.styled";
import cookie from "cookie-cutter";
import { FooterContainer, MainContainer } from "./Footer.styled";

// eslint-disable-next-line arrow-body-style
const Footer = () => {
Expand All @@ -15,7 +15,6 @@ const Footer = () => {
const changeLocale = () => {
const locale = router.locale === "en" ? "ku" : "en";
cookie.set("NEXT_LOCALE", locale);
console.log(cookie.get("NEXT_LOCALE"));
router.push(router.asPath, undefined, { locale });
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/HeroComponents/LogoSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const LogoSection = () => {
<div className="logo text-center">
<h1>{t("home.makeLogo")}</h1>
<h3>{t("home.designLogo")}</h3>
<Link href="/services_search?q=logo">
<Link href="/services_search?q=logo" passHref>
<Btn>{t("home.tryKiraLogo")} </Btn>
</Link>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/LargeProfileCard/LargeProfileCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ LargeProfileCard.propTypes = {
uid: PropTypes.string.isRequired,
photoURL: PropTypes.string,
displayName: PropTypes.string.isRequired,
job: PropTypes.string,
title: PropTypes.string,
location: PropTypes.string,
about: PropTypes.string,
skills: PropTypes.array,
};

LargeProfileCard.defaultProps = {
photoURL: "",
job: "",
title: "",
location: "",
about: "",
skills: [],
Expand Down
44 changes: 21 additions & 23 deletions src/components/Modals/JoinModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,27 @@ const JoinModal = ({ showJoin, setShowJoin }) => {

const { t } = useTranslation("navbar");

return (
<>
{showJoin && (
<Background onClick={closeModal} ref={modalRef}>
<animated.div style={animation}>
<ModalWrapper showJoin={showJoin}>
<ModalContent>
<h4>{t("navbar.joinNow")} </h4>
<StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()} />
</ModalContent>
<CloseModalButton onClick={() => setShowJoin((show) => !show)} />
<ModalBubbles>
<div className="uper-bigBubble" />
<div className="uper-smallBubble" />
<div className="bottom-bigBubble" />
<div className="bottom-smallBubble" />
</ModalBubbles>
</ModalWrapper>
</animated.div>
</Background>
)}
</>
);
if (showJoin)
return (
<Background onClick={closeModal} ref={modalRef}>
<animated.div style={animation}>
<ModalWrapper showJoin={showJoin}>
<ModalContent>
<h4>{t("navbar.joinNow")} </h4>
<StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()} />
</ModalContent>
<CloseModalButton onClick={() => setShowJoin((show) => !show)} />
<ModalBubbles>
<div className="uper-bigBubble" />
<div className="uper-smallBubble" />
<div className="bottom-bigBubble" />
<div className="bottom-smallBubble" />
</ModalBubbles>
</ModalWrapper>
</animated.div>
</Background>
);
return null;
};

export default JoinModal;
10 changes: 5 additions & 5 deletions src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { MdSettings } from "react-icons/md";
import { FiLogOut } from "react-icons/fi";
import { useTranslation } from "next-i18next";
import { auth } from "src/firebase/firebase";
import Link from "next/link";
import userContext from "../../context/context";
import Searchbox from "./Searchbox";
import { JoinBtn, Img, ProfileImg, DropDown } from "./Navbar.styled";
import JoinModal from "../Modals/JoinModal";
import Link from "next/link";

const NavBar = () => {
const [showJoin, setShowJoin] = useState(false);
Expand All @@ -26,7 +26,7 @@ const NavBar = () => {
<Navbar bg="primary" collapseOnSelect expand="xl" variant="dark">
<Container>
<Navbar.Brand>
<Link href={"/"}>
<Link href="/" passHref>
<Img
src="/NavbarLogo.png"
width="104px"
Expand All @@ -49,7 +49,7 @@ const NavBar = () => {
) : (
<Nav className="w-100 d-flex justify-content-end">
<Nav.Link>
<Link href={"/add_service"}>
<Link href="/add_service" passHref>
<FaPlus size="25px" className="text-white mt-1" />
</Link>
</Nav.Link>
Expand All @@ -61,7 +61,7 @@ const NavBar = () => {

<Dropdown.Menu>
<Dropdown.Item>
<Link href={`/profile/${user.uid}`}>
<Link href={`/profile/${user.uid}`} passHref>
<div>
{user.photoURL ? (
<ProfileImg src={user.photoURL} roundedCircle fluid />
Expand All @@ -74,7 +74,7 @@ const NavBar = () => {
</Dropdown.Item>

<Dropdown.Item>
<Link href="/settings">
<Link href="/settings" passHref>
<div>
<MdSettings size="20px" />
<span className="mx-3 text-muted">{t("navbar.settings")}</span>
Expand Down
34 changes: 16 additions & 18 deletions src/components/Navbar/Searchbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,22 @@ const Searchbox = () => {

const { t } = useTranslation("navbar");
return (
<>
<SearchForm className="d-flex md-shadow mx-2" onSubmit={handleSubmit}>
<InputGroup.Text id="basic-addon1">
<IoSearch size="25px" />
<DropdownButton id="dropdown-basic-button">
<Dropdown.Item onClick={setdropdowntrue}>{t("navbar.freelancers")}</Dropdown.Item>
<Dropdown.Item onClick={setdropdownfalse}>{t("navbar.services")}</Dropdown.Item>
</DropdownButton>
</InputGroup.Text>
<input
type="search"
placeholder={t(searchPlaceholder)}
aria-label="Search"
className="input"
onChange={handleInput}
/>
</SearchForm>
</>
<SearchForm className="d-flex md-shadow mx-2" onSubmit={handleSubmit}>
<InputGroup.Text id="basic-addon1">
<IoSearch size="25px" />
<DropdownButton id="dropdown-basic-button">
<Dropdown.Item onClick={setdropdowntrue}>{t("navbar.freelancers")}</Dropdown.Item>
<Dropdown.Item onClick={setdropdownfalse}>{t("navbar.services")}</Dropdown.Item>
</DropdownButton>
</InputGroup.Text>
<input
type="search"
placeholder={t(searchPlaceholder)}
aria-label="Search"
className="input"
onChange={handleInput}
/>
</SearchForm>
);
};
export default Searchbox;
62 changes: 30 additions & 32 deletions src/components/SellerContact/SellerContact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,36 @@ const SellerContact = ({ show, setShow, email, phone, name }) => {
setShow(false);
}
};
return (
<>
{show && (
<Background onClick={closeModal} ref={modalRef}>
<animated.div style={animation}>
<ModalWrapper show={show}>
<ModalContent>
<h3 className="mb-4 text-primary">Contact me</h3>
<h4 className="mb-4">
Name:
<span className="mx-3">{name && name}</span>
</h4>
<h4 className="mb-4">
Phone Number:
{phone ? (
<span className="mx-3">{phone && phone}</span>
) : (
<span className="mx-3 text-muted">XXX</span>
)}
</h4>
<h4 className="mb-4">
Email:
<span className="mx-3">{email && email}</span>
</h4>
</ModalContent>
<CloseModalButton onClick={() => setShow((show) => !show)} />
</ModalWrapper>
</animated.div>
</Background>
)}
</>
);
if (show)
return (
<Background onClick={closeModal} ref={modalRef}>
<animated.div style={animation}>
<ModalWrapper show={show}>
<ModalContent>
<h3 className="mb-4 text-primary">Contact me</h3>
<h4 className="mb-4">
Name:
<span className="mx-3">{name && name}</span>
</h4>
<h4 className="mb-4">
Phone Number:
{phone ? (
<span className="mx-3">{phone && phone}</span>
) : (
<span className="mx-3 text-muted">XXX</span>
)}
</h4>
<h4 className="mb-4">
Email:
<span className="mx-3">{email && email}</span>
</h4>
</ModalContent>
<CloseModalButton onClick={() => setShow((show) => !show)} />
</ModalWrapper>
</animated.div>
</Background>
);
return null;
};

const Background = styled.div`
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingsPage/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { Card, Col, Row, Form, Button } from "react-bootstrap";
import React, { useState, useEffect, useContext } from "react";
import { useTranslation } from "next-i18next";
import userContext from "src/context/context";
import { Container, MainContainer } from "./SettingsPage.styled";
import { getUserInfo, updateUserInDB, uploadImage } from "../../firebase/utilities";
import userContext from "src/context/context";

const SettingsPage = () => {
const user = useContext(userContext);
Expand Down
22 changes: 12 additions & 10 deletions src/firebase/firestore/__test__/firestore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
deleteField,
Timestamp,
} from "firebase/firestore";
import { addUserAdmin, addServiceAdmin, getRandomKey } from "./helpers";
import path from "path";
import { addUserAdmin, addServiceAdmin, getRandomKey } from "./helpers";

let testEnv;

Expand All @@ -41,9 +41,12 @@ afterAll(async () => {

describe("firestore security rules", () => {
const uid = "AuthedUserId";
let auth, unauth;
let userRef, userData;
let serviceRef, serviceData;
let auth;
let unauth;
let userRef;
let userData;
let serviceRef;
let serviceData;

beforeAll(() => {
auth = testEnv.authenticatedContext(uid).firestore();
Expand Down Expand Up @@ -228,12 +231,11 @@ describe("firestore security rules", () => {

describe("users collection", () => {
let changedUserData;
beforeEach(
() =>
(changedUserData = {
displayName: "New Name",
}),
);
beforeEach(() => {
changedUserData = {
displayName: "New Name",
};
});

test("allow reads", async () => {
const otherUser = doc(unauth, "users/otherUser");
Expand Down
1 change: 1 addition & 0 deletions src/firebase/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export { default } from "./firebase";
23 changes: 8 additions & 15 deletions src/firebase/utilities.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { db, storage } from "./firebase";

const services = db.collection("services");
const users = db.collection("users");

export const uploadImage = async (path, file) => {
const fileRef = storage.ref().child(`${path}/${file.name}`);
await fileRef.put(file);
return fileRef.getDownloadURL();
};

export const addService = async (user, images, serviceData) => {
const newServiceRef = services.doc();
const { uid, displayName, photoURL } = user;
Expand All @@ -14,14 +21,6 @@ export const addService = async (user, images, serviceData) => {
serviceData.revisions = Number(serviceData.revisions);
serviceData.price = Number(serviceData.price);

console.log("commit", {
provider: {
displayName,
photoURL,
uid,
},
...serviceData,
});
return newServiceRef.set({
provider: {
displayName,
Expand Down Expand Up @@ -71,7 +70,7 @@ export const getService = async (uid) => {
};

export const getUserInfo = async (user) =>
await users
users
.doc(user.uid)
.get()
.then((doc) => doc.data());
Expand Down Expand Up @@ -104,12 +103,6 @@ export const getAllServicesUID = async () => {
return uids;
};

export const uploadImage = async (path, file) => {
const fileRef = storage.ref().child(`${path}/${file.name}`);
await fileRef.put(file);
return fileRef.getDownloadURL();
};

export const updateProfilePicture = async (user, file) => {
file.name = "profilePicture";
const photoURL = await uploadImage(user.uid, file);
Expand Down
1 change: 1 addition & 0 deletions src/pages/add_service/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AddService from "../../components/AddServicePage/AddService";
import userContext from "../../context/context";

const addService = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const user = useContext(userContext);
return <AddService user={user} />;
};
Expand Down
Loading

0 comments on commit 74c7d93

Please sign in to comment.