Skip to content

Commit

Permalink
Merge pull request #861 from itsmdasifraza/feat/836/create-user-feedb…
Browse files Browse the repository at this point in the history
…ack-form

Feat: create user feedback form
  • Loading branch information
Astitva877 authored May 23, 2024
2 parents f3db2c9 + 00073fd commit 38d3416
Show file tree
Hide file tree
Showing 15 changed files with 871 additions and 28 deletions.
45 changes: 45 additions & 0 deletions src/packages/@app/pages/Help/HelpPage.ViewModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { FeedbackService } from "@app/services/feedback.service";
import { notifications } from "@library/ui/toast/Toast";

class HelpPageViewModel {
// Private Services
private feedbackService = new FeedbackService();

constructor() {}

/**
* @description - uploads user feedback
* @param uploadFeedback - includes file
* @param type - feedback type
* @param feedbackSubject - feedback subject
* @param feedbackDescription - feedback description
* @param subCategory - feedback subcategory
* @returns
*/
public sendFeedback = async (
uploadFeedback,
type,
feedbackSubject,
feedbackDescription,
subCategory,
) => {
const files = Array.from(uploadFeedback.file.value);
const formData = new FormData();
files.forEach((file) => formData.append("files", file));
formData.append("type", type);
if (type === "Feedback" || type === "Bug") {
formData.append("subCategory", subCategory);
}
formData.append("subject", feedbackSubject);
formData.append("description", feedbackDescription);
const response = await this.feedbackService.createFeedback(formData);
if (response.isSuccessful) {
notifications.success("Feedback added successfully");
} else {
notifications.error("Feedback submission failed. Please try again.");
}
return response;
};
}

export default HelpPageViewModel;
4 changes: 3 additions & 1 deletion src/packages/@app/pages/Help/HelpPage.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script>
import { AddFeedback, DiscordCard, FeedbackToast } from "@support/features";
import DiscordPost from "@support/features/discord-post/layout/DiscordPost.svelte";
import HelpPageViewModel from "./HelpPage.ViewModel";
const _viewModel = new HelpPageViewModel();
</script>

<div class="w-100 d-flex align-items-center jutify-content-center">
Expand All @@ -14,7 +16,7 @@
</div>
<div style="width: 30%;">
<div>
<AddFeedback />
<AddFeedback onSendFeedback={_viewModel.sendFeedback} />
</div>
<div>
<DiscordCard />
Expand Down
14 changes: 14 additions & 0 deletions src/packages/@app/services/feedback.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getMultipartAuthHeaders, makeRequest } from "$lib/api/api.common";
import constants from "$lib/utils/constants";
const apiUrl: string = constants.API_URL;
export class FeedbackService {
constructor() {}

public createFeedback = async (feedback) => {
const response = await makeRequest("POST", `${apiUrl}/api/feedback`, {
body: feedback,
headers: getMultipartAuthHeaders(),
});
return response;
};
}
21 changes: 20 additions & 1 deletion src/packages/@app/styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ $theme-blue-2B5ED4: #2B5ED4;
$theme-blue-303F4F: #303F4F;
$theme-blue-1D3650: #1D3650;


$theme-violet-676A80: #676A80;
$theme-violet-2A2C3C: #2A2C3C;
$theme-violet-22232E: #22232E;
$theme-violet-272831: #272831;
$theme-violet-2E2F3D: #2E2F3D;
$theme-violet-323548: #323548;
$theme-violet-1c1d27: #1c1d27;

$theme-red-e5acb2: #e5acb2;
Expand Down Expand Up @@ -239,6 +241,8 @@ $theme-red-230408: #230408;
--text-secondary-800 : #{$theme-grey-151515};
--text-secondary-900 : #{$theme-grey-000000};

--text-tertiary-100 : #{$theme-violet-676A80};
--text-tertiary-300 : #{$theme-violet-2A2C3C};
--text-tertiary-400 : #{$theme-violet-22232E};
--text-tertiary-500 : #{$theme-violet-272831};
--text-tertiary-600 : #{$theme-violet-2E2F3D};
Expand Down Expand Up @@ -281,6 +285,8 @@ $theme-red-230408: #230408;
--bg-secondary-800 : #{$theme-grey-151515};
--bg-secondary-900 : #{$theme-grey-000000};

--bg-tertiary-100 : #{$theme-violet-676A80};
--bg-tertiary-300 : #{$theme-violet-2A2C3C};
--bg-tertiary-400 : #{$theme-violet-22232E};
--bg-tertiary-500 : #{$theme-violet-272831};
--bg-tertiary-600 : #{$theme-violet-2E2F3D};
Expand Down Expand Up @@ -321,6 +327,8 @@ $theme-red-230408: #230408;
--border-secondary-800 : #{$theme-grey-151515};
--border-secondary-900 : #{$theme-grey-000000};

--border-tertiary-100 : #{$theme-violet-676A80};
--border-tertiary-300 : #{$theme-violet-2A2C3C};
--border-tertiary-400 : #{$theme-violet-22232E};
--border-tertiary-500 : #{$theme-violet-272831};
--border-tertiary-600 : #{$theme-violet-2E2F3D};
Expand Down Expand Up @@ -456,6 +464,8 @@ $sparrow-text-colors: (
secondary-800 : $theme-grey-151515,
secondary-900 : $theme-grey-000000,

tertiary-100 : $theme-violet-676A80,
tertiary-300 : $theme-violet-2A2C3C,
tertiary-400 : $theme-violet-22232E,
tertiary-500 : $theme-violet-272831,
tertiary-600 : $theme-violet-2E2F3D,
Expand Down Expand Up @@ -492,9 +502,12 @@ $sparrow-bg-colors: (
secondary-800 : $theme-grey-151515,
secondary-900 : $theme-grey-000000,

tertiary-100 : $theme-violet-676A80,
tertiary-300 : $theme-violet-2A2C3C,
tertiary-400 : $theme-violet-22232E,
tertiary-500 : $theme-violet-272831,
tertiary-600 : $theme-violet-2E2F3D,
tertiary-650 : $theme-violet-323548,
tertiary-700 : $theme-violet-1c1d27,

danger-100 : $theme-red-e5acb2,
Expand Down Expand Up @@ -529,6 +542,8 @@ $sparrow-border-colors: (
secondary-800 : $theme-grey-151515,
secondary-900 : $theme-grey-000000,

tertiary-100 : $theme-violet-676A80,
tertiary-300 : $theme-violet-2A2C3C,
tertiary-400 : $theme-violet-22232E,
tertiary-500 : $theme-violet-272831,
tertiary-600 : $theme-violet-2E2F3D,
Expand Down Expand Up @@ -682,4 +697,8 @@ span {

textarea {
resize: none;
}

.toast-container {
z-index: 1000000 !important; /* Increase the z-index as needed */
}
5 changes: 1 addition & 4 deletions src/packages/@library/forms/Input/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@
{/if}
{#if type === "text" && isHovered && !disabled}
<span class="position-fixed" style="top:76px; right: 525px">
<PencilIcon height={"14px"} width={"14px"} color={"white"}
/>
<PencilIcon height={"14px"} width={"14px"} color={"white"} />
</span>
{/if}
</div>
Expand All @@ -120,7 +119,5 @@
input {
caret-color: var(--border-primary-300);
border: 1px solid transparent;
cursor:pointer;
}
</style>
26 changes: 24 additions & 2 deletions src/packages/@library/forms/select/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@
/**
* Determines the background state for the Select header.
*/
export let headerTheme: "dark" | "transparent" | "violet" | "dark-violet" =
"dark";
export let headerTheme:
| "dark"
| "transparent"
| "violet"
| "violet2"
| "dark-violet" = "dark";
/**
* Determines the background state for the Select body.
Expand Down Expand Up @@ -199,6 +203,9 @@
case "violet":
selectBackgroundClass = "select-background-violet";
break;
case "violet2":
selectBackgroundClass = "select-background-violet2";
break;
case "dark-violet":
selectBackgroundClass = "select-background-dark-violet";
break;
Expand Down Expand Up @@ -278,6 +285,9 @@
case "violet":
x = "violet";
break;
case "violet2":
x = "violet2";
break;
case "dark-violet":
x = "dark-violet";
break;
Expand All @@ -300,6 +310,9 @@
case "violet":
x = "violet";
break;
case "violet2":
x = "violet2";
break;
case "dark-violet":
x = "dark-violet";
}
Expand Down Expand Up @@ -543,6 +556,9 @@
.select-background-violet {
background-color: var(--bg-tertiary-400);
}
.select-background-violet2 {
background-color: var(--bg-tertiary-300);
}
.select-background-dark-violet {
background-color: var(--bg-secondary-600);
}
Expand All @@ -557,6 +573,9 @@
.select-btn-state-active-violet {
background-color: var(--bg-tertiary-600);
}
.select-btn-state-active-violet2 {
background-color: var(--bg-tertiary-600);
}
.select-btn-state-active-dark-violet {
background-color: var(--bg-tertiary-600);
}
Expand All @@ -571,6 +590,9 @@
.select-btn-state-clicked-violet {
background-color: var(--bg-tertiary-700);
}
.select-btn-state-clicked-violet2 {
background-color: var(--bg-tertiary-700);
}
.select-btn-state-clicked-dark-violet {
background-color: var(--bg-tertiary-700);
}
Expand Down
105 changes: 104 additions & 1 deletion src/packages/@library/forms/textarea/Textarea.svelte
Original file line number Diff line number Diff line change
@@ -1 +1,104 @@
<textarea name="" id=""></textarea>
<script lang="ts">
import { createEventDispatcher } from "svelte";
/**
* placeholder - dummy text
*/
export let placeholder = "placeholder";
/**
* height
*/
export let height = "30px";
/**
* width
*/
export let width = "auto";
/**
* identifies input is disabled or not
*/
export let disabled = false;
/**
* input class
*/
let componentClass = "";
export { componentClass as class };
/**
* input style
*/
let componentStyle = "";
export { componentStyle as style };
/**
* input value
*/
export let value = "";
/**
* border color
*/
export let defaultBorderColor = "transparent";
export let hoveredBorderColor = "red";
export let focusedBorderColor = "green";
export let maxlength = 500;
/**
* input states
*/
let isHovered = false;
let isFocused = false;
const dispatch = createEventDispatcher();
const extractBorderHighlight = (_isHovered: boolean, _isFocused: boolean) => {
if (_isFocused) {
return focusedBorderColor;
} else if (_isHovered) {
if (disabled) return defaultBorderColor;
return hoveredBorderColor;
} else {
if (disabled) return defaultBorderColor;
return defaultBorderColor;
}
};
</script>

<div
class="position-relative"
style="height:{height}; width: {width}; !important"
>
<textarea
on:mouseenter={() => {
isHovered = true;
}}
on:mouseleave={() => {
isHovered = false;
}}
on:focus={() => {
isFocused = true;
}}
on:blur={() => {
isFocused = false;
dispatch("blur", event?.target?.value);
}}
{value}
on:input={(event) => {
value = event?.target?.value;
dispatch("input", event?.target?.value);
}}
class="w-100 {componentClass}"
{placeholder}
style=" {componentStyle} height: 100%; border-color:{extractBorderHighlight(
isHovered,
isFocused,
)};"
{disabled}
{maxlength}
/>
</div>

<style>
textarea {
caret-color: var(--border-primary-300);
border: 1px solid transparent;
}
</style>
18 changes: 18 additions & 0 deletions src/packages/@library/icons/Attachment.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
export let height = "24px";
export let width = "24px";
export let color = "grey";
</script>

<svg
{width}
{height}
viewBox="0 0 10 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6.94611 9.50439C6.46945 10.33 5.77406 10.8653 4.85996 11.1102C3.94586 11.3551 3.07601 11.2393 2.2504 10.7626C1.42479 10.2859 0.889517 9.59056 0.644585 8.67646C0.399653 7.76236 0.515521 6.89251 0.992188 6.0669L3.53594 1.66099C3.87969 1.0656 4.38026 0.679827 5.03766 0.503678C5.69506 0.327528 6.32146 0.411328 6.91685 0.755078C7.51224 1.09883 7.89801 1.5994 8.07416 2.2568C8.25031 2.9142 8.16651 3.5406 7.82276 4.13599L5.41651 8.30374C5.20568 8.66891 4.89991 8.90518 4.49921 9.01255C4.09851 9.11992 3.71557 9.06818 3.3504 8.85735C2.98523 8.64652 2.74896 8.34075 2.64159 7.94005C2.53422 7.53935 2.58595 7.15641 2.79679 6.79124L5.34054 2.38533L6.29316 2.93533L3.74941 7.34124C3.68983 7.44444 3.6743 7.54926 3.70282 7.65569C3.73134 7.76213 3.7972 7.84514 3.9004 7.90472C4.0036 7.96431 4.10842 7.97984 4.21486 7.95132C4.32129 7.9228 4.4043 7.85694 4.46389 7.75374L6.87014 3.58599C7.0547 3.24799 7.10031 2.89856 7.00698 2.53772C6.91365 2.17688 6.70027 1.90021 6.36685 1.70771C6.03343 1.51521 5.68515 1.46761 5.32202 1.56491C4.95888 1.66221 4.68107 1.87757 4.48857 2.21099L1.94482 6.6169C1.61146 7.17595 1.52981 7.76654 1.69986 8.38867C1.86992 9.01079 2.23676 9.48456 2.8004 9.80998C3.3561 10.1308 3.94188 10.207 4.55775 10.0387C5.17361 9.87029 5.65219 9.50887 5.99348 8.95439L8.67473 4.31033L9.62736 4.86033L6.94611 9.50439Z"
fill={color}
/>
</svg>
18 changes: 18 additions & 0 deletions src/packages/@library/icons/Cross.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
export let height = "24px";
export let width = "24px";
export let color = "grey";
</script>

<svg
{width}
{height}
viewBox="0 0 9 12"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M7.63744 3.80313C7.89785 3.54271 7.89785 3.11979 7.63744 2.85937C7.37702 2.59896 6.9541 2.59896 6.69369 2.85937L4.49993 5.05521L2.3041 2.86146C2.04368 2.60104 1.62077 2.60104 1.36035 2.86146C1.09993 3.12187 1.09993 3.54479 1.36035 3.80521L3.55618 5.99896L1.36243 8.19479C1.10202 8.45521 1.10202 8.87813 1.36243 9.13854C1.62285 9.39896 2.04577 9.39896 2.30618 9.13854L4.49993 6.94271L6.69577 9.13646C6.95619 9.39687 7.3791 9.39687 7.63952 9.13646C7.89994 8.87604 7.89994 8.45312 7.63952 8.19271L5.44369 5.99896L7.63744 3.80313Z"
fill={color}
/>
</svg>
Loading

0 comments on commit 38d3416

Please sign in to comment.