-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from itsmdasifraza/feat/836/create-user-feedb…
…ack-form Feat: create user feedback form
- Loading branch information
Showing
15 changed files
with
871 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.