Skip to content

Commit

Permalink
Show save status in smart editor
Browse files Browse the repository at this point in the history
  • Loading branch information
eriksson-daniel committed Sep 11, 2024
1 parent 6e62503 commit 6a2dc0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const Editor = ({ smartDocument }: EditorProps) => {
{showHistory ? <History oppgaveId={oppgave.id} smartDocument={smartDocument} /> : null}
</MainContainer>

<StatusBar />
<StatusBar oppgaveId={oppgave.id} dokumentId={id} />
</Plate>
</Container>
);
Expand Down
22 changes: 21 additions & 1 deletion frontend/src/plate/status-bar/status-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import { styled } from 'styled-components';
import { isoDateTimeToPretty } from '@app/domain/date';
import { Zoom } from '@app/plate/status-bar/zoom';
import { useGetSmartDocumentVersionsQuery } from '@app/redux-api/oppgaver/queries/documents';

export const StatusBar = () => (
interface Props {
oppgaveId: string;
dokumentId: string;
}

export const StatusBar = (props: Props) => (
<Container>
<Zoom />
<VersionStatus {...props} />
</Container>
);

const VersionStatus = ({ oppgaveId, dokumentId }: Props) => {
const { data = [] } = useGetSmartDocumentVersionsQuery({ dokumentId, oppgaveId });

const last = data[data.length - 1];

if (last === undefined) {
return null;
}

return <span>Sist lagret: {isoDateTimeToPretty(last.timestamp)}</span>;
};

const Container = styled.div`
width: 100%;
padding-top: 2px;
Expand Down

0 comments on commit 6a2dc0b

Please sign in to comment.