Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rearrangements and no forms style #16

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions assets/empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 22 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"babel-loader": "^9.1.2",
"css-loader": "^6.7.3",
"dotenv-webpack": "^8.0.1",
"file-loader": "^6.2.0",
"gh-pages": "^5.0.0",
"html-webpack-plugin": "^5.5.0",
"node-sass": "^8.0.0",
Expand Down
19 changes: 13 additions & 6 deletions src/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DashboardCard from "./DashboardCard";
import CreateForm from "../_ui/CreateFormModal/CreateForm";
import { useCreateFormStore } from "../_services/CreateFormService";
import CreateButton from "../_ui/CreateButton/CreateButton";
import dropDownSvg from "../../assets/empty.svg";

const Dashboard = () => {
const { currentUser, setCurrentUser, signOut } = useAuthContext();
Expand Down Expand Up @@ -73,21 +74,27 @@ const Dashboard = () => {
<div>date created</div>
</div>
</div>
<div className="dashboard-card-wrapper">
{data?.length > 0 ? (

{data?.length > 0 ? (
<div className="dashboard-card-wrapper ">
<div className="form-cards">
{/* show all cards here */}
{data.map((form, id) => {
return <DashboardCard key={id} formData={form} />;
})}
</div>
) : (
</div>
) : (
<div className="dashboard-card-wrapper dashboard-card">
<Box className="form-empty">
<p>Nothing here</p>
<img src={dropDownSvg} alt="dog" />
<p className="form-empty-text">
Come on in, {currentUser?.email?.split("@")[0]}
</p>
<CreateButton handleOpenCreate={handleOpenCreate} />
</Box>
)}
</div>
</div>
)}
</div>
</div>
</div>
Expand Down
43 changes: 31 additions & 12 deletions src/Editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,25 @@ const Editor = () => {
});

const closeProperties = editorStore((state) => state.closeProperties);
const [loading, error, createQuestion, getQuestion, questions, fetchAgain] =
useQuestions((state) => {
return [
state.loading,
state.error,
state.createQuestion,
state.getQuestion,
state.data,
state.fetchAgain,
];
});
const [
loading,
error,
createQuestion,
getQuestion,
questions,
fetchAgain,
changeOrderId,
] = useQuestions((state) => {
return [
state.loading,
state.error,
state.createQuestion,
state.getQuestion,
state.data,
state.fetchAgain,
state.changeOrderId,
];
});
const { formid } = useParams();
const divs = useInputIcons();
const setActiveIdOnStart = useDndStore((state) => state.setActiveIdOnStart);
Expand Down Expand Up @@ -123,7 +131,18 @@ const Editor = () => {
setComponents((inpt) => {
const activeIndex = inpt.indexOf(active.id);
const overIndex = inpt.indexOf(over.id);
return arrayMove(inpt, activeIndex, overIndex);
let currentActiveOrderId = inpt[activeIndex].order_id;
let currentOverOrderId = inpt[overIndex].order_id;
changeOrderId(
inpt[activeIndex].id,
inpt[overIndex].id,
currentActiveOrderId,
currentOverOrderId
);
inpt = arrayMove(inpt, activeIndex, overIndex);
inpt[activeIndex].order_id = currentOverOrderId;
inpt[overIndex].order_id = currentActiveOrderId;
return inpt;
});
}
};
Expand Down
15 changes: 10 additions & 5 deletions src/HomePage/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React from "react";

const HomePage = () => {
return (
<>
return (
<div className="home-wrapper">
<div className="home-main">
<h1>Welcome to dropform</h1>
<h2>We create form through drag and drop with highly customisable UI for your forms</h2>
</>
)
<h2>
We create form through drag and drop with highly customisable UI for
your forms
</h2>
</div>
</div>
);
};

export default HomePage;
23 changes: 23 additions & 0 deletions src/_services/QuestionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,27 @@ export const useQuestions = create((set, get) => ({
set(() => ({ error: error.message, loading: false }));
}
},
changeOrderId: async (
question_id_over,
question_id_active,
order_id_over,
order_id_active
) => {
set(() => ({ loading: true }));
try {
const { errorOver } = await supabase
.from("question")
.update({ order_id: order_id_active })
.eq("id", question_id_over);
const { errorActive } = await supabase
.from("question")
.update({ order_id: order_id_over })
.eq("id", question_id_active);

// let currentFetch = get().fetchAgain;
set(() => ({ loading: false }));
} catch (error) {
set(() => ({ error: error.message, loading: false }));
}
},
}));
12 changes: 12 additions & 0 deletions src/_styles/dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
.right-dashboard {
padding-left: 32px;
padding-right: 32px;
height: 100%;
}
.right-dashboard-menu {
border-bottom: 1px solid $dashboard-divider;
Expand All @@ -70,6 +71,17 @@
}
.dashboard-card-wrapper {
padding: 24px 32px 80px;
height: 100%;
}
.dashboard-card {
display: flex;
justify-content: center;
align-items: center;
}
.form-empty-text {
font-size: 24px;
line-height: 32px;
// font-family: ;
}
.form-cards {
display: flex;
Expand Down
11 changes: 11 additions & 0 deletions src/_styles/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ img {

.content {
margin-top: 88px;
// height: 100%;
}
.content-other {
margin-top: 24px;
Expand Down Expand Up @@ -432,6 +433,16 @@ img {
.auth-form-wrapper {
height: 100%;
}
.home-wrapper {
.home-main {
width: 80%;
margin: 0px auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
}
}
}

// screens
Expand Down