Skip to content

Commit

Permalink
Merge pull request #18 from Jittojoyes98/develop
Browse files Browse the repository at this point in the history
Deletion and rearrangements
  • Loading branch information
Jittojoyes98 authored Oct 5, 2023
2 parents 908ee39 + f4bf9d8 commit 1a16a52
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Editor/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const Editor = () => {
</div>
);
}
console.log(components);

return (
<div className="editor-wrapper">
Expand Down
6 changes: 3 additions & 3 deletions src/Input/Input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const Input = ({
}, []);
const iconComponents = useIconMapper({ isActive: select || hover });

const [deleteQuestion] = useQuestions((state) => {
return [state.deleteQuestion];
const [deleteQuestion, reorderQuestion] = useQuestions((state) => {
return [state.deleteQuestion, state.reorderQuestion];
});

const handleDelete = (e) => {
e.stopPropagation();
deleteQuestion(component.id);
deleteQuestion(component.id, component.form_id);
};

return (
Expand Down
11 changes: 9 additions & 2 deletions src/_services/QuestionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ export const useQuestions = create((set, get) => ({
set(() => ({ error: error.message, loading: false }));
}
},
deleteQuestion: async (question_id) => {
deleteQuestion: async (question_id, form_id) => {
set(() => ({ loading: true }));

try {
const { data, errorReorder } = await supabase.rpc(
"delete_question_with_order",
{
formid: form_id,
questionid: question_id,
}
);
const { error } = await supabase
.from("question")
.delete()
Expand All @@ -53,6 +59,7 @@ export const useQuestions = create((set, get) => ({
set(() => ({ error: error.message, loading: false }));
}
},
reorderQuestion: async (form_id) => {},
updateQuestionName: async (question_id, name) => {
set(() => ({ loading: true }));
try {
Expand Down
1 change: 1 addition & 0 deletions src/_styles/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $overlay-background: rgb(17, 116, 203);
$select-input-border: #007be5;
$description-text: rgba(0, 0, 0, 0.7);
$response-text: rgb(187, 187, 187);
$delete-color: rgb(140, 3, 3);

$button-text-color: #05051b;
$button-hover-color: #077f7f;
Expand Down

0 comments on commit 1a16a52

Please sign in to comment.