-
Notifications
You must be signed in to change notification settings - Fork 0
Question & Actions Lists #15
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
75d61d7
basic component with dummy data in place
Jaz-spec 2756e51
skeleton for displaying question data in place
Jaz-spec ef938f4
commit to merge updated types
Jaz-spec 6361445
commit
Jaz-spec e724a65
data is being displayed from the db
Jaz-spec 0b098b6
added basic question saving for version 1 of a question
Jaz-spec c8f2be9
integrated action types
Jaz-spec fe51e2b
ability to retrieve previous answers
Jaz-spec b558d9b
responses marked as either answered or skipped
Jaz-spec 33cc0be
retrieved and displayed latest action in question card component
Jaz-spec 3ec4c57
public private toggle implemented
Jaz-spec f3fb76e
fixed some toggle mis-haps
Jaz-spec 87e1624
Merge branch 'question-component' of https://github.com/foundersandco…
JasonWarrenUK 31bb8f2
style: :lipstick: rationalise imports from different branches
JasonWarrenUK 3621fe6
style: :lipstick: remove dashed horrors
JasonWarrenUK 8b235b5
feat: :label: create list category type
JasonWarrenUK d36ba26
feat: :card_file_box: add preview field to question table
JasonWarrenUK 3b7e1e0
feat: :lipstick: render the correct questions/actions in list view
JasonWarrenUK 8d535b9
Merge branch 'header_component' of https://github.com/foundersandcode…
JasonWarrenUK 86e3a4b
refactor(project): :truck: reorganise components
JasonWarrenUK 79bee04
Merge branch 'main' of https://github.com/foundersandcoders/LIFT02 in…
JasonWarrenUK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 @@ | ||
| Read through the ARCHITECTURE.md and FUNCTIONAL.md files get to grips with the project | ||
| My task is to create a component that displays: | ||
|
|
||
| - A section header | ||
| - A question | ||
| - an input for the user to answer the question | ||
| - an additional input for the user to declare 'actions' | ||
| - a skip button | ||
| - a submit button | ||
| Don't do any styling, I will handle that later. I just want a template component that I can edit. | ||
| Do you have any questions for me regarding the task? If not, please suggest some code for me |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,153 @@ | ||
| <script lang="ts"> | ||
| import { getQuestionById } from '$lib/services/database'; | ||
| import SubmitButton from '../ui/SubmitButton.svelte'; | ||
| import type { DbResult } from '$lib/services/database/types'; | ||
| import type { Database } from '$lib/types/supabase'; | ||
| import { getLatestResponses } from '$lib/services/database/responses'; | ||
| import { getLatestActions } from '$lib/services/database'; | ||
| import ToggleStatus from '../ui/ToggleStatus.svelte'; | ||
|
|
||
| type Question = Database['public']['Tables']['questions']['Row']; | ||
|
|
||
| //Delete later --> for development only | ||
| const user_id = '550e8400-e29b-41d4-a716-446655440005'; | ||
|
|
||
| interface Props { | ||
| questionId: string; | ||
| } | ||
|
|
||
| let { questionId }: Props = $props(); | ||
|
|
||
| const getData = async () => { | ||
| const question = await getQuestionById(questionId); | ||
| const previousResponse = await getLatestResponse(); | ||
|
|
||
| if (previousResponse) responseInput = previousResponse; | ||
|
|
||
| return { | ||
| question: question || null, | ||
| previousResponse: previousResponse || null | ||
| }; | ||
| }; | ||
|
|
||
| const getLatestResponse = async () => { | ||
| const response = await getLatestResponses(user_id); | ||
| if (response?.data) { | ||
| const questionResponse = response.data.find((r) => r.question_id === questionId); | ||
| const previousAction = await getLatestAction(questionResponse?.id); | ||
| if (previousAction?.description) { | ||
| actionsInput = previousAction.description; | ||
| actionType = previousAction.type; | ||
| } | ||
| if (questionResponse?.visibility) isPublic = questionResponse?.visibility; | ||
| if (questionResponse?.id) responseId = questionResponse?.id; | ||
| return questionResponse?.response_text; | ||
| } | ||
| return null; | ||
| }; | ||
| let responseInput = $state(''); | ||
| let responseId = $state(''); | ||
|
|
||
| const getLatestAction = async (response_Id: string | undefined) => { | ||
| const response = await getLatestActions(user_id); | ||
| if (response?.data) { | ||
| const actionResponse = response.data.find((r) => r.response_id === response_Id); | ||
| return actionResponse; | ||
| } | ||
| return null; | ||
| }; | ||
| let actionType = $state(''); | ||
| let actionsInput = $state(''); | ||
| let isPublic = $state('private'); | ||
| $inspect(isPublic); | ||
|
|
||
| const toggleVisibility = () => { | ||
| isPublic = isPublic === 'public' ? 'private' : 'public'; | ||
| }; | ||
| </script> | ||
|
|
||
| {#await getData() then response} | ||
| {#if response.question && response.question.data} | ||
| <div class=" m-auto flex min-h-[90dvh] w-sm flex-col justify-around rounded-3xl p-5 shadow-2xl"> | ||
| <header> | ||
| <h1 class="text-center text-2xl">{response.question.data.category}</h1> | ||
| </header> | ||
|
|
||
| <ToggleStatus {isPublic} {toggleVisibility} /> | ||
|
|
||
| <div class="flex flex-col"> | ||
| <label for="response-{questionId}" class="text-xl" | ||
| >{response.question.data.question_text || 'Question'}</label | ||
| > | ||
| <textarea | ||
| id="response-{questionId}" | ||
| bind:value={responseInput} | ||
| placeholder="Enter your response here..." | ||
| rows="4" | ||
| class="text-area" | ||
| ></textarea> | ||
| </div> | ||
|
|
||
| <div> | ||
| <h2 class="text-xl">A description of what actions are for</h2> | ||
| <label for="cars">Action type:</label> | ||
| <select id="action-type-{questionId}" bind:value={actionType}> | ||
| <option>Action type</option> | ||
| <option value="workplace_adjustment">Workplace adjustment</option> | ||
| <option value="schedule_adjustment">Schedule adjustment</option> | ||
| <option value="communication">Communication</option> | ||
| <option value="schedule_flexibility">Schedule flexibility</option> | ||
| </select> | ||
|
|
||
| <div class="flex flex-col"> | ||
| <label for="actions-{questionId}">Actions needed:</label> | ||
| <textarea | ||
| id="actions-{questionId}" | ||
| bind:value={actionsInput} | ||
| placeholder="Enter your response here..." | ||
| rows="3" | ||
| class="text-area" | ||
| ></textarea> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="flex justify-around"> | ||
| <SubmitButton | ||
| text="Skip" | ||
| status="skipped" | ||
| {responseInput} | ||
| {actionsInput} | ||
| {actionType} | ||
| {isPublic} | ||
| {responseId} | ||
| /> | ||
| <SubmitButton | ||
| text="Submit" | ||
| status="answered" | ||
| {responseInput} | ||
| {actionsInput} | ||
| {actionType} | ||
| {isPublic} | ||
| {responseId} | ||
| /> | ||
| </div> | ||
| </div> | ||
| {:else} | ||
| <div class=" m-auto flex min-h-[90dvh] w-sm flex-col justify-around rounded-3xl p-5 shadow-2xl"> | ||
| Sorry! We can't load you're questions right now. Please try again later. | ||
| </div> | ||
| {/if} | ||
| {/await} | ||
|
|
||
| <style> | ||
| .text-area { | ||
| border: solid 2px var(--pink); | ||
| border-radius: 10px; | ||
| padding: 10px; | ||
| outline: none; | ||
| } | ||
|
|
||
| .text-area:focus { | ||
| border: solid 2px var(--teal); | ||
| } | ||
| </style> |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,21 @@ | ||
| <script lang="ts"> | ||
| let { devMode, profileId } = $props(); | ||
| </script> | ||
|
|
||
| <footer class="sticky bottom-0 z-50 w-full border-t border-gray-200 bg-white"> | ||
| <div id="dev-info" class="flex flex-row justify-between"> | ||
| <div class="dev"></div> | ||
|
|
||
| <div class="dev"> | ||
| {#if profileId} | ||
| <p>Profile ID: {profileId}</p> | ||
| {:else} | ||
| <p>Not Logged In</p> | ||
| {/if} | ||
| </div> | ||
|
|
||
| <div class="dev"> | ||
| <p>Dev Mode: {devMode}</p> | ||
| </div> | ||
| </div> | ||
| </footer> |
This file contains hidden or 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
File renamed without changes.
This file contains hidden or 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,33 @@ | ||
| <script lang="ts"> | ||
| import { createAction } from '$lib/services/database/actions'; | ||
| import { createResponse } from '$lib/services/database/responses'; | ||
|
|
||
| //Delete later --> for development only | ||
| const user_id = '550e8400-e29b-41d4-a716-446655440005'; | ||
| const questionId = 'bacc6ffa-b589-4bdc-8eb8-d29eeef7f153'; | ||
|
|
||
| interface Props { | ||
| text: string; | ||
| responseInput: string; | ||
| actionsInput: string; | ||
| actionType: string; | ||
| status: string; | ||
| isPublic: string; | ||
| responseId: string; | ||
| } | ||
|
|
||
| let { text, responseInput, actionsInput, actionType, status, isPublic, responseId }: Props = | ||
| $props(); | ||
|
|
||
| function handleSubmit() { | ||
| createResponse(user_id, { | ||
| response_text: responseInput, | ||
| question_id: questionId, | ||
| status: status, | ||
| visibility: isPublic | ||
| }); | ||
| createAction(user_id, { type: actionType, description: actionsInput, response_id: responseId }); | ||
| } | ||
| </script> | ||
|
|
||
| <button type="button" onclick={handleSubmit} class="rounded-2xl border p-4">{text}</button> |
This file contains hidden or 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,21 @@ | ||
| <script lang="ts"> | ||
| let { isPublic, toggleVisibility } = $props(); | ||
| </script> | ||
|
|
||
| <div class="flex items-center gap-3"> | ||
| <div class="relative inline-block h-5 w-11"> | ||
| <input | ||
| checked={toggleVisibility} | ||
| onclick={toggleVisibility} | ||
| id="switch-component" | ||
| type="checkbox" | ||
| class="peer h-5 w-11 cursor-pointer appearance-none rounded-full bg-slate-100 transition-colors duration-300 checked:bg-[var(--teal)]" | ||
| /> | ||
| <label | ||
| for="switch-component" | ||
| class="absolute top-0 left-0 h-5 w-5 cursor-pointer rounded-full border border-slate-300 bg-white shadow-sm transition-transform duration-300 peer-checked:translate-x-6 peer-checked:border-[var(--teal)]" | ||
| > | ||
| </label> | ||
| </div> | ||
| <span class=" text-sm font-medium">{isPublic}</span> | ||
| </div> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.