Skip to content

Commit

Permalink
fix ability to unassign user (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
maradondt authored Sep 18, 2023
1 parent 65a131d commit 835d243
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/app/src/people/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export interface WantedSummaryProps {
show: boolean;
setIsModalSideButton: (any) => void;
setIsExtraStyle: (any) => void;
formSubmit: (any) => void;
formSubmit: (any, close?: boolean) => void;
title: string;
org_uuid?: string;
id?: number;
Expand Down
15 changes: 8 additions & 7 deletions frontend/app/src/people/main/FocusView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ function FocusedView(props: FocusViewProps) {
return newBody;
}

async function submitForm(body: any) {
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
async function submitForm(body: any, shouldCloseModal: boolean = true) {
let newBody = cloneDeep(body);
try {
newBody = await preSubmitFunctions(newBody);
Expand All @@ -219,12 +220,10 @@ function FocusedView(props: FocusViewProps) {
if (!info) return console.log('no meInfo');
setLoading(true);
try {
if (newBody?.assignee?.owner_pubkey) {
newBody.assignee = newBody.assignee.owner_pubkey;
}
if (body?.assignee?.owner_pubkey) {
newBody.assignee = body.assignee.owner_pubkey;
if (typeof newBody?.assignee !== 'string' || !newBody?.assignee) {
newBody.assignee = newBody.assignee?.owner_pubkey ?? 'emptyid';
}

if (body.one_sentence_summary !== '') {
newBody.title = body.one_sentence_summary;
} else {
Expand All @@ -238,7 +237,9 @@ function FocusedView(props: FocusViewProps) {
if (window.location.href.includes('wanted')) {
await main.getPersonCreatedWanteds({}, info.pubkey);
}
closeModal();
if(shouldCloseModal) {
closeModal();
}
} catch (e) {
console.log('e', e);
}
Expand Down
20 changes: 19 additions & 1 deletion frontend/app/src/people/widgetViews/summaries/WantedSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,25 @@ function WantedSummary(props: WantedSummaryProps) {

const changeAssignedPerson = useCallback(() => {
setIsAssigned(false);
}, []);

setAssignedPerson(null);
const newValue = {
title: titleString,
wanted_type: wanted_type,
one_sentence_summary: one_sentence_summary,
ticketUrl: ticket_url,
github_description: github_description,
description: description,
price: price,
assignee: '',
coding_language: coding_languages?.map((x: string) => ({ label: x, value: x })),
estimated_session_length: estimated_session_length,
show: show,
type: type,
created: created
};
formSubmit && formSubmit(newValue, false);
}, [coding_languages, created, description, estimated_session_length, formSubmit, github_description, one_sentence_summary, price, show, ticket_url, titleString, type, wanted_type]);

useEffect(() => {
(async () => {
Expand Down

0 comments on commit 835d243

Please sign in to comment.